well that was painful to fix

This commit is contained in:
Gurge44 committed 2025-10-07 14:24:21 +02:00
1 parent cb122dd004
commit 398ca02bc6
9 files changed
+40 -83

No files matched your search

+3 -1
View File
@@ -2,7 +2,9 @@
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitIncludes>
<Path>Main.cs</Path>
</explicitIncludes>
<explicitExcludes />
</component>
</project>
+2 -2
View File
@@ -943,7 +943,7 @@ internal static class ExtendedPlayerControl
if (player.GetCustomRole() is not CustomRoles.Necromancer and not CustomRoles.Deathknight and not CustomRoles.Refugee and not CustomRoles.Sidekick) return;
}
if (!player.CanUseKillButton() && !AntiBlackout.SkipTasks) return;
if (!player.CanUseKillButton() && !AntiBlackout.SkipTasks && !IntroCutsceneDestroyPatch.PreventKill) return;
player.AddKillTimerToDict(cd: time);
if (target == null) target = player;
@@ -1356,7 +1356,7 @@ internal static class ExtendedPlayerControl
public static bool CanUseKillButton(this PlayerControl pc)
{
if (AntiBlackout.SkipTasks || TimeMaster.Rewinding || !Main.IntroDestroyed || !pc.IsAlive()) return false;
if (AntiBlackout.SkipTasks || TimeMaster.Rewinding || !Main.IntroDestroyed || IntroCutsceneDestroyPatch.PreventKill || !pc.IsAlive()) return false;
switch (Options.CurrentGameMode)
{
-5
View File
@@ -193,8 +193,6 @@ public class PlayerState(byte playerId)
Utils.NotifyRoles(SpecifySeer: Player);
Utils.NotifyRoles(SpecifyTarget: Player);
HudSpritePatch.ResetButtonIcons = true;
}
CheckMurderPatch.TimeSinceLastKill.Remove(PlayerId);
@@ -228,9 +226,6 @@ public class PlayerState(byte playerId)
SetAddonCountTypes(role);
if (Main.IntroDestroyed && GameStates.InGame)
HudSpritePatch.ResetButtonIcons = true;
Logger.Info($" ID {PlayerId} ({Player?.GetRealName()}) => {role}, CountTypes => {countTypes}", "SetSubRole");
}
+7 -7
View File
@@ -473,14 +473,14 @@ public static class ToggleOptionPatch
OptionItem item = OptionItem.AllOptions[index];
CustomGameMode gm = Options.CurrentGameMode;
Color32 color = gm == CustomGameMode.Standard ? item.Tab switch
Color32 color = gm == CustomGameMode.Standard ? (TabGroup)(ModGameOptionsMenu.TabIndex - 3) switch
{
TabGroup.ImpostorRoles => new(255, 25, 25, 255),
TabGroup.CrewmateRoles => new(140, 255, 255, 255),
TabGroup.NeutralRoles => new(255, 171, 27, 255),
TabGroup.CovenRoles => new(123, 63, 187, 255),
_ => new(0, 165, 255, 255)
} : Main.GameModeColors.TryGetValue(gm, out var c) ? c : new(0, 165, 255, 255);
TabGroup.ImpostorRoles => new Color32(255, 25, 25, 255),
TabGroup.CrewmateRoles => new Color32(140, 255, 255, 255),
TabGroup.NeutralRoles => new Color32(255, 171, 27, 255),
TabGroup.CovenRoles => new Color32(123, 63, 187, 255),
_ => new Color32(0, 165, 255, 255)
} : Main.GameModeColors.TryGetValue(gm, out var c) ? c : new Color32(0, 165, 255, 255);
__instance.CheckMark.sprite = Utils.LoadSprite("EHR.Resources.Images.Checkmark.png", 100f);
__instance.CheckMark.color = color;
var renderer = __instance.CheckMark.transform.parent.FindChild("ActiveSprite").GetComponent<SpriteRenderer>();
+6 -3
View File
@@ -380,10 +380,10 @@ internal static class HudManagerPatch
else
button = null;
if (button != null)
if (button == __instance.AbilityButton)
{
button.SetUsesRemaining((int)abilityUseLimit);
button.usesRemainingSprite.color = Utils.GetRoleColor(role);
button.SetUsesRemaining((int)abilityUseLimit);
}
}
}
@@ -1152,7 +1152,10 @@ internal static class TaskPanelBehaviourPatch
if (Options.CurrentGameMode is CustomGameMode.Standard or CustomGameMode.MoveAndStop or CustomGameMode.HideAndSeek or CustomGameMode.Speedrun)
{
var tabText = __instance.tab.transform.FindChild("TabText_TMP").GetComponent<TextMeshPro>();
tabText.SetText($"{TranslationController.Instance.GetString(StringNames.Tasks)}{Utils.GetTaskCount(PlayerControl.LocalPlayer.PlayerId, Utils.IsActive(SystemTypes.Comms))}");
bool fakeTasks = Options.CurrentGameMode == CustomGameMode.Standard && !Utils.HasTasks(PlayerControl.LocalPlayer.Data, forRecompute: false);
string sideText = TranslationController.Instance.GetString(fakeTasks ? StringNames.FakeTasks : StringNames.Tasks);
if (fakeTasks) sideText = Utils.ColorString(Utils.GetRoleColor(CustomRoles.ImpostorEHR), sideText.TrimEnd(':'));
tabText.SetText($"{sideText}{Utils.GetTaskCount(PlayerControl.LocalPlayer.PlayerId, Utils.IsActive(SystemTypes.Comms))}");
}
else
{
+10 -40
View File
@@ -19,19 +19,9 @@ public static class CustomButton
//[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public static class HudSpritePatch
{
private static Sprite Kill;
private static Sprite Ability;
private static Sprite Vent;
private static Sprite Sabotage;
private static Sprite Pet;
private static Sprite Report;
public static Sprite[] DefaultIcons = [];
private static long LastErrorTime;
public static bool ResetButtonIcons;
public static void Postfix(HudManager __instance)
{
try
@@ -41,39 +31,19 @@ public static class HudSpritePatch
if (!Main.EnableCustomButton.Value || !Main.ProcessShapeshifts || Mastermind.ManipulatedPlayers.ContainsKey(player.PlayerId) || ExileController.Instance || GameStates.IsMeeting) return;
if ((!SetHudActivePatch.IsActive && !MeetingStates.FirstMeeting) || !player.IsAlive()) return;
if (ResetButtonIcons || !AmongUsClient.Instance.IsGameStarted || !Main.IntroDestroyed || GameStates.IsLobby || GameStates.IsNotJoined || !GameStates.InGame)
{
Kill = null;
Ability = null;
Vent = null;
Sabotage = null;
Pet = null;
Report = null;
ResetButtonIcons = false;
return;
}
bool shapeshifting = player.IsShifted();
if (!AmongUsClient.Instance.IsGameStarted || !Main.IntroDestroyed || GameStates.IsLobby || GameStates.IsNotJoined || !GameStates.InGame || IntroCutsceneDestroyPatch.PreventKill) return;
if (DefaultIcons.Length == 0) return;
if (!Kill) Kill = DefaultIcons[0];
if (!Ability) Ability = DefaultIcons[1];
if (!Vent) Vent = DefaultIcons[2];
if (!Sabotage) Sabotage = DefaultIcons[3];
if (!Pet) Pet = DefaultIcons[4];
if (!Report) Report = DefaultIcons[5];
Sprite newKillButton = Kill;
Sprite newAbilityButton = Ability;
Sprite newVentButton = Vent;
Sprite newSabotageButton = Sabotage;
Sprite newPetButton = Pet;
Sprite newReportButton = Report;
Sprite newKillButton = DefaultIcons[0];
Sprite newAbilityButton = DefaultIcons[1];
Sprite newVentButton = DefaultIcons[2];
Sprite newSabotageButton = DefaultIcons[3];
Sprite newPetButton = DefaultIcons[4];
Sprite newReportButton = DefaultIcons[5];
bool usesPetInsteadOfKill = player.UsesPetInsteadOfKill();
bool shapeshifting = player.IsShifted();
switch (player.GetCustomRole())
{
@@ -112,7 +82,7 @@ public static class HudSpritePatch
}
case CustomRoles.Echo:
{
newAbilityButton = player.IsShifted() ? Kill : CustomButton.Get("Puttpuer");
newAbilityButton = player.IsShifted() ? newKillButton : CustomButton.Get("Puttpuer");
break;
}
case CustomRoles.Shifter:
@@ -488,7 +458,7 @@ public static class HudSpritePatch
foreach (var button in new ActionButton[] { __instance.KillButton, __instance.AbilityButton, __instance.ImpostorVentButton, __instance.SabotageButton, __instance.PetButton, __instance.ReportButton })
{
button.OverrideColor(roleColor);
button.buttonLabelText.color = roleColor;
button.buttonLabelText.SetOutlineColor(roleColor);
}
return;
+12 -18
View File
@@ -20,7 +20,7 @@ static class ShowRoleMoveNextPatchAndroid
{
public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __result)
{
if (AmongUsClient.Instance.AmHost || __instance.__1__state != 1 || !__result) return;
if (__instance.__1__state != 1 || !__result) return;
GameStates.InGame = true;
SetUpRoleTextPatch.Postfix(__instance.__4__this);
@@ -32,7 +32,7 @@ static class ShowRoleMoveNextPatch
{
public static void Postfix(IntroCutscene._ShowRole_d__41 __instance, ref bool __result)
{
if (AmongUsClient.Instance.AmHost || __instance.__1__state != 1 || !__result) return;
if (__instance.__1__state != 1 || !__result) return;
GameStates.InGame = true;
SetUpRoleTextPatch.Postfix(__instance.__4__this);
@@ -45,14 +45,10 @@ static class ShowRoleMoveNextPatch
[HarmonyPatch(typeof(HudManager), nameof(HudManager.CoShowIntro))]
static class CoShowIntroPatch
{
public static bool IntroStarted;
public static bool Prefix(HudManager __instance)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsModHost) return true;
IntroStarted = true;
Utils.SetupLongRoleDescriptions();
LateTask.New(() =>
@@ -151,7 +147,7 @@ static class CoShowIntroPatch
}
}
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowRole))]
//[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowRole))]
internal static class SetUpRoleTextPatch
{
public static bool IsInIntro;
@@ -1050,11 +1046,14 @@ internal static class BeginImpostorPatch
[HarmonyPatch(typeof(HudManager), nameof(HudManager.OnGameStart))]
internal static class IntroCutsceneDestroyPatch
{
public static bool PreventKill;
public static void Postfix( /*IntroCutscene __instance*/)
{
if (!GameStates.IsInGame) return;
Main.IntroDestroyed = true;
PreventKill = true;
LateTask.New(() => PreventKill = false, 5f, "PreventKillReset");
// Set roleAssigned as false for overriding roles for modded players
// for vanilla clients we use "Data.Disconnected"
@@ -1088,15 +1087,15 @@ internal static class IntroCutsceneDestroyPatch
{
x.ResetKillCooldown(false);
if (Main.AllPlayerKillCooldown.TryGetValue(x.PlayerId, out float kcd) && kcd - 2f > 0f)
x.SetKillCooldown(kcd - 2f);
if (Main.AllPlayerKillCooldown.TryGetValue(x.PlayerId, out float kcd))
x.SetKillCooldown(kcd);
});
}, 2f, "FixKillCooldownTask");
}
else
{
int kcd = Options.StartingKillCooldown.GetInt();
LateTask.New(() => aapc.Do(x => x.SetKillCooldown(kcd - 2)), 2f, "FixKillCooldownTask");
LateTask.New(() => aapc.Do(x => x.SetKillCooldown(kcd)), 2f, "FixKillCooldownTask");
}
}
}
@@ -1121,7 +1120,7 @@ internal static class IntroCutsceneDestroyPatch
{
lp.RpcResetAbilityCooldown();
lp.SetKillCooldown(10f);
}, 0.2f, log: false);
}, 0.8f, log: false);
StartGameHostPatch.RpcSetRoleReplacer.SetActualSelfRolesAfterOverride();
}, 0.1f, log: false);
@@ -1277,9 +1276,7 @@ internal static class IntroCutsceneDestroyPatch
pc.TP(new Vector2(3.32f, -26.57f));
}
}
if (HudSpritePatch.DefaultIcons.Length > 0) return;
HudManager hud = FastDestroyableSingleton<HudManager>.Instance;
HudSpritePatch.DefaultIcons =
@@ -1299,7 +1296,4 @@ internal static class IntroCutsceneDestroyPatch
PlayerControl.LocalPlayer.NetTransform.SnapTo(new(15.5f, 0.0f), (ushort)(PlayerControl.LocalPlayer.NetTransform.lastSequenceId + 8));
}, 4f, "Airship Spawn FailSafe");
}
}
}
-5
View File
@@ -286,8 +286,6 @@ internal static class ChangeRoleSettings
GameEndChecker.Ended = false;
ReportDeadBodyPatch.MeetingStarted = false;
HudSpritePatch.ResetButtonIcons = true;
ShipStatusFixedUpdatePatch.ClosestVent = [];
ShipStatusFixedUpdatePatch.CanUseClosestVent = [];
@@ -306,7 +304,6 @@ internal static class ChangeRoleSettings
Main.LastNotifyNames = [];
CheckForEndVotingPatch.EjectionText = string.Empty;
CoShowIntroPatch.IntroStarted = false;
Arsonist.CurrentDousingTarget = byte.MaxValue;
Revolutionist.CurrentDrawTarget = byte.MaxValue;
@@ -474,8 +471,6 @@ internal static class StartGameHostPatch
public static readonly Dictionary<CustomRoles, List<byte>> BasisChangingAddons = [];
private static Dictionary<RoleTypes, int> RoleTypeNums = [];
public static readonly Dictionary<byte, bool> DataDisconnected = [];
private static RoleOptionsCollectionV10 RoleOpt => Main.NormalOptions.roleOptions;
private static void UpdateRoleTypeNums()
-2
View File
@@ -1174,8 +1174,6 @@ internal static class ReportDeadBodyPatch
Damocles.CountRepairSabotage = false;
Stressed.CountRepairSabotage = false;
HudSpritePatch.ResetButtonIcons = true;
if (Options.CurrentGameMode == CustomGameMode.Standard)
{
foreach (byte id in Main.DiedThisRound)