public static void clearAndReloadRoles() { Jester.clearAndReload(); Mayor.clearAndReload(); Engineer.clearAndReload(); Sheriff.clearAndReload(); Lighter.clearAndReload(); Godfather.clearAndReload(); Mafioso.clearAndReload(); Janitor.clearAndReload(); Detective.clearAndReload(); TimeMaster.clearAndReload(); Medic.clearAndReload(); Shifter.clearAndReload(); Swapper.clearAndReload(); Lovers.clearAndReload(); Seer.clearAndReload(); Morphling.clearAndReload(); Camouflager.clearAndReload(); Spy.clearAndReload(); Child.clearAndReload(); }
public static void Postfix(HudManager __instance) { // Engineer Repair engineerRepairButton = new CustomButton( () => { engineerRepairButton.Timer = 0f; MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(usedRepairWriter); RPCProcedure.engineerUsedRepair(); foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks) { if (task.TaskType == TaskTypes.FixLights) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerFixLights, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.engineerFixLights(); } else if (task.TaskType == TaskTypes.RestoreOxy) { ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64); ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64); } else if (task.TaskType == TaskTypes.ResetReactor) { ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 16); } else if (task.TaskType == TaskTypes.ResetSeismic) { ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16); } else if (task.TaskType == TaskTypes.FixComms) { ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 0); ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 1); } } }, () => { return(Engineer.engineer != null && Engineer.engineer == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { bool sabotageActive = false; foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks) { if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms) { sabotageActive = true; } } return(sabotageActive && !Engineer.usedRepair && PlayerControl.LocalPlayer.CanMove); }, false, Engineer.getButtonSprite(), Vector3.zero, __instance ); // Janitor Clean janitorCleanButton = new CustomButton( () => { foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(PlayerControl.LocalPlayer.GetTruePosition(), PlayerControl.LocalPlayer.MaxReportDistance, Constants.PlayersOnlyMask)) { if (collider2D.tag == "DeadBody") { DeadBody component = collider2D.GetComponent <DeadBody>(); if (component && !component.Reported) { Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition(); Vector2 truePosition2 = component.TruePosition; if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false)) { GameData.PlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JanitorClean, Hazel.SendOption.None, -1); writer.Write(playerInfo.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.janitorClean(playerInfo.PlayerId); janitorCleanButton.Timer = janitorCleanButton.MaxTimer; break; } } } } }, () => { return(Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(__instance.ReportButton.renderer.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove); }, true, Janitor.getButtonSprite(), Vector3.zero, __instance ); // Sheriff Kill sheriffKillButton = new CustomButton( () => { if (Medic.shielded != null && Medic.shielded == Sheriff.currentTarget) { MessageWriter attemptWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(attemptWriter); RPCProcedure.shieldedMurderAttempt(); return; } byte targetId = 0; if (Sheriff.currentTarget.Data.IsImpostor || (Sheriff.jesterCanDieToSheriff && Jester.jester != null && Jester.jester == Sheriff.currentTarget)) { targetId = Sheriff.currentTarget.PlayerId; } else { targetId = PlayerControl.LocalPlayer.PlayerId; } MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.None, -1); killWriter.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(killWriter); RPCProcedure.sheriffKill(targetId); sheriffKillButton.Timer = sheriffKillButton.MaxTimer; Sheriff.currentTarget = null; }, () => { return(Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(Sheriff.currentTarget && PlayerControl.LocalPlayer.CanMove); }, true, __instance.KillButton.renderer.sprite, Vector3.zero, __instance ); // Time Master Rewind Time timeMasterRewindTimeButton = new CustomButton( () => { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TimeMasterRewindTime, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.timeMasterRewindTime(); timeMasterRewindTimeButton.Timer = timeMasterRewindTimeButton.MaxTimer; }, () => { return(TimeMaster.timeMaster != null && TimeMaster.timeMaster == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(PlayerControl.LocalPlayer.CanMove); }, true, TimeMaster.getButtonSprite(), Vector3.zero, __instance ); // Medic Shield medicShieldButton = new CustomButton( () => { medicShieldButton.Timer = 0f; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.None, -1); writer.Write(Medic.currentTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.medicSetShielded(Medic.currentTarget.PlayerId); }, () => { return(Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(!Medic.usedShield && Medic.currentTarget && PlayerControl.LocalPlayer.CanMove); }, false, Medic.getButtonSprite(), Vector3.zero, __instance ); // Shifter shift shifterShiftButton = new CustomButton( () => { shifterShiftButton.Timer = shifterShiftButton.MaxTimer; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.None, -1); writer.Write(Shifter.currentTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.shifterShift(Shifter.currentTarget.PlayerId); }, () => { return(Shifter.shifter != null && Shifter.shifter == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(Shifter.currentTarget && PlayerControl.LocalPlayer.CanMove); }, true, Shifter.getButtonSprite(), Vector3.zero, __instance ); // Seer reveal seerRevealButton = new CustomButton( () => { seerRevealButton.Timer = seerRevealButton.MaxTimer; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SeerReveal, Hazel.SendOption.None, -1); writer.Write(Seer.currentTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.seerReveal(Seer.currentTarget.PlayerId); }, () => { return(Seer.seer != null && Seer.seer == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(Seer.currentTarget && PlayerControl.LocalPlayer.CanMove); }, false, Seer.getButtonSprite(), Vector3.zero, __instance ); // Morphling morph morphlingButton = new CustomButton( () => { if (Morphling.sampledTarget != null) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.None, -1); writer.Write(Morphling.sampledTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.morphlingMorph(Morphling.sampledTarget.PlayerId); Morphling.sampledTarget = null; morphlingButton.HasEffect = true; // Trigger effect on this click } else if (Morphling.currentTarget != null) { Morphling.sampledTarget = Morphling.currentTarget; morphlingButton.Sprite = Morphling.getMorphSprite(); morphlingButton.HasEffect = false; // Block effect on this click } }, () => { return(Morphling.morphling != null && Morphling.morphling == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return((Morphling.currentTarget || Morphling.sampledTarget) && PlayerControl.LocalPlayer.CanMove); }, true, Morphling.getSampleSprite(), new Vector3(0f, 1.3f, 0f), __instance, true, 10f, () => { morphlingButton.Timer = morphlingButton.MaxTimer; morphlingButton.Sprite = Morphling.getSampleSprite(); } ); // Camouflager camouflage camouflagerButton = new CustomButton( () => { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CamouflagerCamouflage, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.camouflagerCamouflage(); }, () => { return(Camouflager.camouflager != null && Camouflager.camouflager == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); }, () => { return(PlayerControl.LocalPlayer.CanMove); }, true, Camouflager.getButtonSprite(), new Vector3(0f, 1.3f, 0f), __instance, true, 10f, () => { camouflagerButton.Timer = camouflagerButton.MaxTimer; } ); }