mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
some fixes
This commit is contained in:
1 parent
17bbcc954e
commit
b95616ee66
6 files changed
+28
-31
No files matched your search
+2
-2
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using AmongUs.QuickChat;
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using EHR.Patches.ReversePatches;
|
||||
using HarmonyLib;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
@@ -1251,8 +1252,7 @@ internal static class InitializePlayerTimeoutPatch
|
||||
{
|
||||
player.Visible = false;
|
||||
bool exit = false;
|
||||
AssertWithTimeoutPatch.AllowCall = true;
|
||||
yield return player.AssertWithTimeout((Func<bool>)(() => GameData.Instance != null && player.Data != null && !player.Data.IsIncomplete), (Action)(() =>
|
||||
yield return player.AssertWithTimeout_Unpatched((Func<bool>)(() => GameData.Instance != null && player.Data != null && !player.Data.IsIncomplete), (Action)(() =>
|
||||
{
|
||||
if (player == null || player.Pointer == IntPtr.Zero)
|
||||
{
|
||||
|
||||
@@ -350,7 +350,9 @@ public static class Translator
|
||||
|
||||
public static string FixRoleName(this string infoLong, CustomRoles role)
|
||||
{
|
||||
return OriginalRoleNames.TryGetValue(role, out var d) && d.TryGetValue(GetUserTrueLang(), out var o) ? infoLong.Replace(o, role.ToColoredString(), StringComparison.OrdinalIgnoreCase) : infoLong;
|
||||
if (!OriginalRoleNames.TryGetValue(role, out var d) || !d.TryGetValue(GetUserTrueLang(), out var o)) return infoLong;
|
||||
string modifiedName = role.ToColoredString();
|
||||
return infoLong.Contains(modifiedName) ? infoLong : infoLong.Replace(o, modifiedName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool LangHasSensitiveOutlineText()
|
||||
|
||||
@@ -2045,7 +2045,7 @@ internal static class ChatCommands
|
||||
if (GameStates.IsLobby || !player.FriendCode.GetDevUser().up) return;
|
||||
|
||||
string subArgs = text.Remove(0, 8);
|
||||
string setRole = FixRoleNameInput(subArgs.Trim());
|
||||
string setRole = subArgs.Trim().Replace("着", "者");
|
||||
|
||||
foreach (CustomRoles rl in Main.CustomRoleValues)
|
||||
{
|
||||
@@ -2713,9 +2713,8 @@ internal static class ChatCommands
|
||||
private static void RCommand(PlayerControl player, string text, string[] args)
|
||||
{
|
||||
string subArgs = text.Remove(0, 2);
|
||||
byte to = player.AmOwner && ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) || ClientControlGUI.BroadcastRoleInfo)
|
||||
? byte.MaxValue : player.PlayerId;
|
||||
ClientControlGUI.BroadcastRoleInfo = false;
|
||||
byte to = player.AmOwner && ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) || ClientControlGUI.BroadcastRoleInfo) ? byte.MaxValue : player.PlayerId;
|
||||
ClientControlGUI.BroadcastRoleInfo = false;
|
||||
SendRolesInfo(subArgs, to);
|
||||
}
|
||||
|
||||
@@ -3262,17 +3261,6 @@ internal static class ChatCommands
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string FixRoleNameInput(string text)
|
||||
{
|
||||
text = text.Replace("着", "者").Trim().ToLower();
|
||||
|
||||
return text switch
|
||||
{
|
||||
"schrodingers cat" or "schrodingerscat" or "cat" => "Schrödinger's Cat",
|
||||
_ => text
|
||||
};
|
||||
}
|
||||
|
||||
public static bool GetRoleByName(string name, out CustomRoles role)
|
||||
{
|
||||
role = new();
|
||||
@@ -3291,7 +3279,7 @@ internal static class ChatCommands
|
||||
result += mc[i]; //匹配结果是完整的数字,此处可以不做拼接的
|
||||
}
|
||||
|
||||
name = FixRoleNameInput(result.Replace("是", string.Empty).Trim());
|
||||
name = result.Replace("是", string.Empty).Trim().Replace("着", "者");
|
||||
}
|
||||
else
|
||||
name = name.Trim().ToLower();
|
||||
@@ -3324,10 +3312,6 @@ internal static class ChatCommands
|
||||
}
|
||||
|
||||
role = role.Trim().ToLower();
|
||||
if (role.StartsWith("/r")) _ = role.Replace("/r", string.Empty);
|
||||
if (role.StartsWith("/up")) _ = role.Replace("/up", string.Empty);
|
||||
if (role.EndsWith("\r\n")) _ = role.Replace("\r\n", string.Empty);
|
||||
if (role.EndsWith("\n")) _ = role.Replace("\n", string.Empty);
|
||||
|
||||
if (role == "")
|
||||
{
|
||||
@@ -3335,7 +3319,8 @@ internal static class ChatCommands
|
||||
return;
|
||||
}
|
||||
|
||||
role = FixRoleNameInput(role).ToLower().Trim().Replace(" ", string.Empty);
|
||||
string originalInput = role;
|
||||
role = role.Replace("着", "者").ToLower().Trim().Replace(" ", string.Empty);
|
||||
|
||||
foreach (CustomRoles rl in Main.CustomRoleValues)
|
||||
{
|
||||
@@ -3343,7 +3328,7 @@ internal static class ChatCommands
|
||||
|
||||
string roleName = Regex.Replace(GetString(rl.ToString()).RemoveHtmlTags().ToLower().Trim().TrimStart('*'), @"[^\p{L}-]+", string.Empty);
|
||||
|
||||
if (role == roleName)
|
||||
if (role == roleName || (originalInput is "schrodingers cat" or "schrodingerscat" or "cat" && rl == CustomRoles.SchrodingersCat))
|
||||
{
|
||||
if ((isDev || isUp) && GameStates.IsLobby)
|
||||
{
|
||||
|
||||
@@ -2603,13 +2603,9 @@ internal static class PlayerControlLocalSetRolePatch
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.AssertWithTimeout))]
|
||||
internal static class AssertWithTimeoutPatch
|
||||
{
|
||||
public static bool AllowCall;
|
||||
|
||||
public static bool Prefix()
|
||||
{
|
||||
bool allow = AllowCall;
|
||||
AllowCall = false;
|
||||
return allow;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace EHR.Patches.ReversePatches;
|
||||
|
||||
public static class ReversePatches
|
||||
{
|
||||
[HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.AssertWithTimeout))]
|
||||
internal static Il2CppSystem.Collections.IEnumerator AssertWithTimeout_Unpatched(this PlayerControl __instance, Func<bool> assertion, Action onTimeout, float timeoutInSeconds)
|
||||
{
|
||||
throw new Exception("Reverse Patch Stub");
|
||||
}
|
||||
}
|
||||
@@ -2498,7 +2498,7 @@
|
||||
"Berserker.LowerKillCooldown": "Lower Kill Cooldown",
|
||||
"Blockade": "Blockade",
|
||||
"BlockadeInfo": "Place Blockades",
|
||||
"BlockadeInfoLong": "(Neutrals):\\nAs the Blockade, you can vanish/pet/shapeshift to place blockades. No one other than you can go through them. All blockades disappear when a meeting starts.",
|
||||
"BlockadeInfoLong": "(Neutrals):\\nAs the Blockade, you can vanish/pet/shapeshift to place blockades. No one other than you can go through them. All blockades disappear when a meeting starts.\\nKill everyone to win!",
|
||||
"Blockade.BlockadeRadius": "Blockade Radius",
|
||||
"BloodKnight": "Blood Knight",
|
||||
"BloodKnightInfo": "Killing gives you a temporary shield",
|
||||
|
||||
Reference in new issue
Block a user