mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Massive Optimization + Added Summoner
This commit is contained in:
1 parent
66a0e02242
commit
317db05689
238 files changed
+2333
-1581
No files matched your search
+7
-12
@@ -9,7 +9,6 @@ using UnityEngine;
|
||||
|
||||
namespace EHR.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(TextBoxTMP))]
|
||||
public static class TextBoxPatch
|
||||
{
|
||||
private static TextMeshPro PlaceHolderText;
|
||||
@@ -18,8 +17,7 @@ public static class TextBoxPatch
|
||||
|
||||
public static bool IsInvalidCommand;
|
||||
|
||||
#if !ANDROID
|
||||
[HarmonyPatch(nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPrefix]
|
||||
public static bool AllowAllCharacters(TextBoxTMP __instance, [HarmonyArgument(0)] string input, [HarmonyArgument(1)] string inputCompo = "")
|
||||
{
|
||||
@@ -101,9 +99,8 @@ public static class TextBoxPatch
|
||||
__instance.SetPipePosition();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
[HarmonyPatch(nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPostfix]
|
||||
public static void ShowCommandHelp(TextBoxTMP __instance)
|
||||
{
|
||||
@@ -275,7 +272,7 @@ public static class TextBoxPatch
|
||||
|
||||
if (additionalInfo.Length == 0 && argName.Replace('[', '{').Replace(']', '}') is "{id}" or "{id1}" or "{id2}")
|
||||
{
|
||||
Dictionary<byte, string> allIds = Main.AllPlayerControls.ToDictionary(x => x.PlayerId, x => x.PlayerId.ColoredPlayerName());
|
||||
Dictionary<byte, string> allIds = Main.EnumeratePlayerControls().ToDictionary(x => x.PlayerId, x => x.PlayerId.ColoredPlayerName());
|
||||
additionalInfo = $"<b><u>{Translator.GetString("PlayerIdList").TrimEnd(' ')}</u></b>\n{string.Join('\n', allIds.Select(x => $"<b>{x.Key}</b> \uffeb <b>{x.Value}</b>"))}";
|
||||
OptionShower.CurrentPage = 0;
|
||||
}
|
||||
@@ -285,7 +282,7 @@ public static class TextBoxPatch
|
||||
bool IsInvalidArg() =>
|
||||
arg != argName && argName switch
|
||||
{
|
||||
"{id}" or "{id1}" or "{id2}" => !byte.TryParse(arg, out byte id) || Main.AllPlayerControls.All(x => x.PlayerId != id),
|
||||
"{id}" or "{id1}" or "{id2}" => !byte.TryParse(arg, out byte id) || Main.EnumeratePlayerControls().All(x => x.PlayerId != id),
|
||||
"{number}" or "{level}" or "{duration}" or "{number1}" or "{number2}" => !int.TryParse(arg, out int num) || num < 0,
|
||||
"{team}" => arg is not "crew" and not "imp",
|
||||
"{role}" => !ChatCommands.GetRoleByName(arg, out _),
|
||||
@@ -300,7 +297,7 @@ public static class TextBoxPatch
|
||||
argName switch
|
||||
{
|
||||
"{sourcepreset}" or "{targetpreset}" => int.TryParse(arg, out int preset) && preset is >= 1 and <= 10,
|
||||
"{id}" or "{id1}" or "{id2}" => byte.TryParse(arg, out byte id) && Main.AllPlayerControls.Any(x => x.PlayerId == id),
|
||||
"{id}" or "{id1}" or "{id2}" => byte.TryParse(arg, out byte id) && Main.EnumeratePlayerControls().Any(x => x.PlayerId == id),
|
||||
"{team}" => arg is "crew" or "imp",
|
||||
"{role}" or "[role]" => ChatCommands.GetRoleByName(arg, out _),
|
||||
"{addon}" => ChatCommands.GetRoleByName(arg, out CustomRoles role) && role.IsAdditionRole(),
|
||||
@@ -377,8 +374,7 @@ public static class TextBoxPatch
|
||||
catch { }
|
||||
}
|
||||
|
||||
#if !ANDROID
|
||||
[HarmonyPatch(nameof(TextBoxTMP.Update))]
|
||||
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.Update))]
|
||||
[HarmonyPrefix]
|
||||
public static bool UpdatePatch(TextBoxTMP __instance)
|
||||
{
|
||||
@@ -401,10 +397,9 @@ public static class TextBoxPatch
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Originally by KARPED1EM. Reference: https://github.com/KARPED1EM/TownOfNext/blob/TONX/TONX/Patches/TextBoxPatch.cs
|
||||
[HarmonyPatch(nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
|
||||
[HarmonyPrefix]
|
||||
public static void ModifyCharacterLimit(TextBoxTMP __instance)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user