From 6c1012712283120e68c1c3c56fb9be20a437c556 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Thu, 6 Feb 2025 18:28:52 +0100 Subject: [PATCH] use SendOption.None --- EHR.csproj | 2 +- Modules/CustomNetObject.cs | 4 +- Modules/CustomSounds.cs | 4 +- Modules/EAC.cs | 48 ++++++- Modules/ExtendedPlayerControl.cs | 136 +++++++++--------- Modules/Extensions/HazelExtensions.cs | 4 + .../GameOptionsSender/GameOptionsSender.cs | 2 +- Modules/GameState.cs | 4 +- Modules/GuessManager.cs | 4 +- Modules/NameColorManager.cs | 2 +- Modules/NameNotifyManager.cs | 2 +- Modules/RPC.cs | 38 ++--- Modules/Utils.cs | 26 ++-- Patches/CheckGameEndPatch.cs | 2 +- Patches/OnGameStartedPatch.cs | 35 ++--- Patches/PhantomRolePatch.cs | 4 +- Patches/PlayerControlPatch.cs | 46 +++++- Patches/PlayerJoinAndLeftPatch.cs | 8 +- Patches/ShipStatusPatch.cs | 116 ++++----------- Patches/TaskAssignPatch.cs | 5 +- Roles/AddOns/Crewmate/Stressed.cs | 2 +- Roles/AddOns/Crewmate/Workhorse.cs | 2 +- Roles/AddOns/GhostRoles/Haunter.cs | 2 +- Roles/AddOns/GhostRoles/Specter.cs | 2 +- Roles/AddOns/Impostor/Damocles.cs | 2 +- Roles/Crewmate/Alchemist.cs | 6 +- Roles/Crewmate/Benefactor.cs | 2 +- Roles/Crewmate/Cleanser.cs | 2 +- Roles/Crewmate/Dad.cs | 3 +- Roles/Crewmate/Druid.cs | 2 +- Roles/Crewmate/Jailer.cs | 4 +- Roles/Crewmate/Medic.cs | 2 +- Roles/Crewmate/NiceHacker.cs | 2 +- Roles/Crewmate/NiceSwapper.cs | 2 +- Roles/Crewmate/Psychic.cs | 2 +- Roles/Crewmate/Ricochet.cs | 2 +- Roles/Crewmate/SabotageMaster.cs | 4 +- Roles/Crewmate/Scout.cs | 2 +- Roles/Crewmate/Spy.cs | 2 +- Roles/Crewmate/SwordsMan.cs | 2 +- Roles/Crewmate/Tether.cs | 2 +- Roles/Crewmate/Tornado.cs | 2 +- Roles/Impostor/Assassin.cs | 4 +- Roles/Impostor/BallLightning.cs | 2 +- Roles/Impostor/BountyHunter.cs | 2 +- Roles/Impostor/Capitalism.cs | 2 +- Roles/Impostor/Chronomancer.cs | 2 +- Roles/Impostor/Councillor.cs | 2 +- Roles/Impostor/Crewpostor.cs | 2 +- Roles/Impostor/EvilDiviner.cs | 2 +- Roles/Impostor/EvilTracker.cs | 2 +- Roles/Impostor/FireWorks.cs | 12 +- Roles/Impostor/Greedier.cs | 2 +- Roles/Impostor/Hitman.cs | 2 +- Roles/Impostor/Librarian.cs | 2 +- Roles/Impostor/Mafia.cs | 2 +- Roles/Impostor/Mafioso.cs | 4 +- Roles/Impostor/Penguin.cs | 2 +- Roles/Impostor/QuickShooter.cs | 2 +- Roles/Impostor/Sniper.cs | 2 +- Roles/Impostor/Swooper.cs | 2 +- Roles/Impostor/Wildling.cs | 2 +- Roles/Impostor/Witch.cs | 4 +- Roles/Impostor/YinYanger.cs | 2 +- Roles/Neutral/Agitater.cs | 2 +- Roles/Neutral/Bandit.cs | 2 +- Roles/Neutral/Bubble.cs | 2 +- Roles/Neutral/Collector.cs | 2 +- Roles/Neutral/DarkHide.cs | 6 +- Roles/Neutral/Doomsayer.cs | 2 +- Roles/Neutral/Doppelganger.cs | 2 +- Roles/Neutral/Executioner.cs | 6 +- Roles/Neutral/Gamer.cs | 2 +- Roles/Neutral/Glitch.cs | 2 +- Roles/Neutral/Hookshot.cs | 2 +- Roles/Neutral/Lawyer.cs | 6 +- Roles/Neutral/Mycologist.cs | 2 +- Roles/Neutral/Pelican.cs | 2 +- Roles/Neutral/PlagueBearer.cs | 2 +- Roles/Neutral/PlagueDoctor.cs | 2 +- Roles/Neutral/Romantic.cs | 4 +- Roles/Neutral/Totocalcio.cs | 2 +- Roles/Neutral/WeaponMaster.cs | 2 +- Roles/Neutral/Werewolf.cs | 6 +- 84 files changed, 334 insertions(+), 329 deletions(-) diff --git a/EHR.csproj b/EHR.csproj index c7c0a547e..ab5ed3268 100644 --- a/EHR.csproj +++ b/EHR.csproj @@ -7,7 +7,7 @@ EHR Gurge44 preview - C:\Program Files\Epic Games\AmongUs + D:\AmongUs true True $(MSBuildProjectName) diff --git a/Modules/CustomNetObject.cs b/Modules/CustomNetObject.cs index f1ceda2a7..ec75c979f 100644 --- a/Modules/CustomNetObject.cs +++ b/Modules/CustomNetObject.cs @@ -129,7 +129,7 @@ namespace EHR LateTask.New(() => { - var sender = CustomRpcSender.Create("FixModdedClientCNOText", SendOption.Reliable); + var sender = CustomRpcSender.Create("FixModdedClientCNOText", HazelExtensions.SendOption); sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixModdedClientCNO, player.GetClientId()) .WriteNetObject(playerControl) @@ -300,7 +300,7 @@ namespace EHR // Fix for Non-Host Modded foreach (PlayerControl visiblePC in Main.AllPlayerControls.ExceptBy(HiddenList, x => x.PlayerId)) { - var sender = CustomRpcSender.Create("FixModdedClientCNOText", SendOption.Reliable); + var sender = CustomRpcSender.Create("FixModdedClientCNOText", HazelExtensions.SendOption); sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixModdedClientCNO, visiblePC.GetClientId()) .WriteNetObject(playerControl) diff --git a/Modules/CustomSounds.cs b/Modules/CustomSounds.cs index cf65f28a9..00fb04b5e 100644 --- a/Modules/CustomSounds.cs +++ b/Modules/CustomSounds.cs @@ -22,7 +22,7 @@ public static class CustomSoundsManager return; } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.Reliable, pc.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, HazelExtensions.SendOption, pc.GetClientId()); writer.Write(sound); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -31,7 +31,7 @@ public static class CustomSoundsManager { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, HazelExtensions.SendOption); writer.Write(sound); AmongUsClient.Instance.FinishRpcImmediately(writer); Play(sound); diff --git a/Modules/EAC.cs b/Modules/EAC.cs index 682b4185a..48a55c1a7 100644 --- a/Modules/EAC.cs +++ b/Modules/EAC.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; +using AmongUs.QuickChat; using HarmonyLib; using Hazel; using InnerNet; @@ -114,6 +115,49 @@ internal static class EAC } } + break; + case RpcCalls.SendQuickChat: + QuickChatPhraseType quickChatPhraseType = (QuickChatPhraseType)sr.ReadByte(); + + switch (quickChatPhraseType) + { + case QuickChatPhraseType.Empty: + HandleCheat(pc, "Empty message in quick chat"); + return true; + case QuickChatPhraseType.PlayerId: + { + byte playerID = sr.ReadByte(); + + if (playerID == 255) + { + HandleCheat(pc, "Sending invalid player in quick chat"); + return true; + } + + if (GameStates.InGame && GameData.Instance.GetPlayerById(playerID) == null) + { + HandleCheat(pc, "Sending non existing player in quick chat"); + return true; + } + + break; + } + } + + if (quickChatPhraseType != QuickChatPhraseType.ComplexPhrase) break; + sr.ReadUInt16(); + int num = sr.ReadByte(); + + switch (num) + { + case 0: + HandleCheat(pc, "Complex phrase without arguments"); + return true; + case > 3: + HandleCheat(pc, "Trying to crash or lag other players"); + return true; + } + break; case RpcCalls.CheckColor when !pc.IsHost(): if (!GameStates.IsLobby) @@ -170,7 +214,7 @@ internal static class EAC case RpcCalls.Shapeshift when !pc.IsHost(): { Report(pc, "Directly Shapeshift"); - MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.Shapeshift, SendOption.Reliable); + MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.Shapeshift, HazelExtensions.SendOption); swriter.WriteNetObject(pc); swriter.Write(false); AmongUsClient.Instance.FinishRpcImmediately(swriter); @@ -183,7 +227,7 @@ internal static class EAC { string sreason = "Direct Phantom RPCs " + rpc; Report(pc, sreason); - MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.StartAppear, SendOption.Reliable); + MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.StartAppear, HazelExtensions.SendOption); swriter.Write(false); AmongUsClient.Instance.FinishRpcImmediately(swriter); HandleCheat(pc, sreason); diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 13408ccd2..52a253ac5 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -43,7 +43,7 @@ internal static class ExtendedPlayerControl if (AmongUsClient.Instance.AmHost) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, HazelExtensions.SendOption); writer.Write(player.PlayerId); writer.WritePacked((int)role); writer.Write(replaceAllAddons); @@ -55,7 +55,7 @@ internal static class ExtendedPlayerControl { if (AmongUsClient.Instance.AmHost) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, HazelExtensions.SendOption); writer.Write(PlayerId); writer.WritePacked((int)role); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -100,59 +100,57 @@ internal static class ExtendedPlayerControl public static void RpcSetVentInteraction(this PlayerControl player) { - VentilationSystemDeterioratePatch.SerializeV2(ShipStatus.Instance.Systems[SystemTypes.Ventilation].CastFast(), player); + var ventilationSystem = ShipStatus.Instance.Systems[SystemTypes.Ventilation].TryCast(); + if (ventilationSystem != null) VentilationSystemDeterioratePatch.SerializeV2(ventilationSystem, player); } - public static void SetChatVisible(this PlayerControl player) // Credit: NikoCat233 + // From: https://github.com/Rabek009/MoreGamemodes/blob/master/Modules/ExtendedPlayerControl.cs + public static void SetChatVisible(this PlayerControl player, bool visible) { - if (!GameStates.IsInGame || !AmongUsClient.Instance.AmHost || GameStates.IsMeeting) return; - - if (player.IsHost()) + if (player.AmOwner) { - HudManager.Instance.Chat.SetVisible(true); + HudManager.Instance.Chat.SetVisible(visible); + HudManager.Instance.Chat.HideBanButton(); return; } - if (player.IsModClient()) - { - MessageWriter modsend = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowChat, SendOption.Reliable, player.OwnerId); - modsend.WritePacked(player.OwnerId); - modsend.Write(true); - AmongUsClient.Instance.FinishRpcImmediately(modsend); - return; - } - - uint customNetId = AmongUsClient.Instance.NetIdCnt++; - MessageWriter vanillasend = MessageWriter.Get(SendOption.Reliable); - vanillasend.StartMessage(6); - vanillasend.Write(AmongUsClient.Instance.GameId); - vanillasend.Write(player.OwnerId); - - vanillasend.StartMessage((byte)GameDataTag.SpawnFlag); - vanillasend.WritePacked(1); // 1 Meeting Hud Spawn id - vanillasend.WritePacked(-2); // Owned by host - vanillasend.Write((byte)SpawnFlags.None); - vanillasend.WritePacked(1); - vanillasend.WritePacked(customNetId); - - vanillasend.StartMessage(1); - vanillasend.WritePacked(0); - vanillasend.EndMessage(); - - vanillasend.EndMessage(); - vanillasend.EndMessage(); - - vanillasend.StartMessage(6); - vanillasend.Write(AmongUsClient.Instance.GameId); - vanillasend.Write(player.OwnerId); - vanillasend.StartMessage((byte)GameDataTag.RpcFlag); - vanillasend.WritePacked(customNetId); - vanillasend.Write((byte)RpcCalls.CloseMeeting); - vanillasend.EndMessage(); - vanillasend.EndMessage(); - - AmongUsClient.Instance.SendOrDisconnect(vanillasend); - vanillasend.Recycle(); + bool isDead = player.Data.IsDead; + MessageWriter writer = MessageWriter.Get(); + writer.StartMessage(6); + writer.Write(AmongUsClient.Instance.GameId); + writer.WritePacked(player.GetClientId()); + writer.StartMessage(4); + writer.WritePacked(HudManager.Instance.MeetingPrefab.SpawnId); + writer.WritePacked(-2); + writer.Write((byte)SpawnFlags.None); + writer.WritePacked(1); + uint netIdCnt = AmongUsClient.Instance.NetIdCnt; + AmongUsClient.Instance.NetIdCnt = netIdCnt + 1U; + writer.WritePacked(netIdCnt); + writer.StartMessage(1); + writer.WritePacked(0); + writer.EndMessage(); + writer.EndMessage(); + player.Data.IsDead = visible; + writer.StartMessage(1); + writer.WritePacked(player.Data.NetId); + player.Data.Serialize(writer, true); + writer.EndMessage(); + writer.StartMessage(2); + writer.WritePacked(netIdCnt); + writer.Write((byte)RpcCalls.CloseMeeting); + writer.EndMessage(); + player.Data.IsDead = isDead; + writer.StartMessage(1); + writer.WritePacked(player.Data.NetId); + player.Data.Serialize(writer, true); + writer.EndMessage(); + writer.StartMessage(5); + writer.WritePacked(netIdCnt); + writer.EndMessage(); + writer.EndMessage(); + AmongUsClient.Instance.SendOrDisconnect(writer); + writer.Recycle(); } public static void RpcExile(this PlayerControl player) @@ -266,7 +264,7 @@ internal static class ExtendedPlayerControl int clientId = seer.GetClientId(); if (clientId == -1) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, SendOption.Reliable, clientId); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, HazelExtensions.SendOption, clientId); writer.Write(seer.Data.NetId); writer.Write(name); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -285,12 +283,20 @@ internal static class ExtendedPlayerControl } player.Data.DefaultOutfit.PetSequenceId += 10; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetPetStr, SendOption.Reliable, clientId); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetPetStr, HazelExtensions.SendOption, clientId); writer.Write(petId); writer.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr)); AmongUsClient.Instance.FinishRpcImmediately(writer); } + public static void RpcResetTasks(this PlayerControl player) + { + if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || player == null) return; + + player.Data.RpcSetTasks(new Il2CppStructArray(0)); + Main.PlayerStates[player.PlayerId].InitTask(player); + } + public static void RpcSetRoleDesync(this PlayerControl player, RoleTypes role, int clientId) { if (player == null) return; @@ -541,7 +547,7 @@ internal static class ExtendedPlayerControl { if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGeneralOptions, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGeneralOptions, HazelExtensions.SendOption); writer.Write(player.PlayerId); writer.WritePacked((int)player.GetCustomRole()); writer.Write(Main.PlayerStates[player.PlayerId].IsDead); @@ -580,7 +586,7 @@ internal static class ExtendedPlayerControl return; } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.EnterVent, SendOption.Reliable, seer.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.EnterVent, HazelExtensions.SendOption, seer.GetClientId()); writer.WritePacked(ventId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -598,7 +604,7 @@ internal static class ExtendedPlayerControl return; } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.ExitVent, SendOption.Reliable, seer.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.ExitVent, HazelExtensions.SendOption, seer.GetClientId()); writer.WritePacked(ventId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -615,7 +621,7 @@ internal static class ExtendedPlayerControl return; } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.BootFromVent, SendOption.Reliable, seer.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.BootFromVent, HazelExtensions.SendOption, seer.GetClientId()); writer.WritePacked(ventId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -712,7 +718,7 @@ internal static class ExtendedPlayerControl } else if (player.IsModClient()) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.KillFlash, SendOption.Reliable, player.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.KillFlash, HazelExtensions.SendOption, player.GetClientId()); AmongUsClient.Instance.FinishRpcImmediately(writer); } else if (!ReactorCheck) player.ReactorFlash(); // Reactor flash @@ -749,7 +755,7 @@ internal static class ExtendedPlayerControl // Other Clients if (!killer.IsHost()) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable, killer.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption, killer.GetClientId()); writer.WriteNetObject(target); writer.Write((int)MurderResultFlags.FailedProtected); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -849,7 +855,7 @@ internal static class ExtendedPlayerControl if (AmongUsClient.Instance.AmHost && playerId.IsPlayerModClient() && !playerId.IsHost() && rpc) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAbilityUseLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAbilityUseLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(limit); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -937,7 +943,7 @@ internal static class ExtendedPlayerControl PlayerControl.LocalPlayer.SetKillTimer(time); else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillTimer, SendOption.Reliable, player.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillTimer, HazelExtensions.SendOption, player.GetClientId()); writer.Write(time); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -956,7 +962,7 @@ internal static class ExtendedPlayerControl killer.MurderPlayer(target, ResultFlags); else { - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable, killer.GetClientId()); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption, killer.GetClientId()); messageWriter.WriteNetObject(target); messageWriter.Write((byte)ResultFlags); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); @@ -999,7 +1005,7 @@ internal static class ExtendedPlayerControl public static void RpcDesyncRepairSystem(this PlayerControl target, SystemTypes systemType, int amount) { - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, target.GetClientId()); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, target.GetClientId()); messageWriter.Write((byte)systemType); messageWriter.WriteNetObject(target); messageWriter.Write((byte)amount); @@ -1190,7 +1196,7 @@ internal static class ExtendedPlayerControl return; } - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(target.NetId, (byte)RpcCalls.SetScanner, SendOption.Reliable, seerClientId); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(target.NetId, (byte)RpcCalls.SetScanner, HazelExtensions.SendOption, seerClientId); messageWriter.Write(on); messageWriter.Write(cnt); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); @@ -1342,7 +1348,7 @@ internal static class ExtendedPlayerControl public static void RpcSetDousedPlayer(this PlayerControl player, PlayerControl target, bool isDoused) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDousedPlayer, SendOption.Reliable); //RPCによる同期 + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDousedPlayer, HazelExtensions.SendOption); //RPCによる同期 writer.Write(player.PlayerId); writer.Write(target.PlayerId); writer.Write(isDoused); @@ -1351,7 +1357,7 @@ internal static class ExtendedPlayerControl public static void RpcSetDrawPlayer(this PlayerControl player, PlayerControl target, bool isDoused) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDrawPlayer, SendOption.Reliable); //RPCによる同期 + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDrawPlayer, HazelExtensions.SendOption); //RPCによる同期 writer.Write(player.PlayerId); writer.Write(target.PlayerId); writer.Write(isDoused); @@ -1360,7 +1366,7 @@ internal static class ExtendedPlayerControl public static void RpcSetRevealtPlayer(this PlayerControl player, PlayerControl target, bool isDoused) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRevealedPlayer, SendOption.Reliable); //RPCによる同期 + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRevealedPlayer, HazelExtensions.SendOption); //RPCによる同期 writer.Write(player.PlayerId); writer.Write(target.PlayerId); writer.Write(isDoused); @@ -1468,7 +1474,7 @@ internal static class ExtendedPlayerControl public static void RpcExileV2(this PlayerControl player) { player.Exiled(); - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, HazelExtensions.SendOption); AmongUsClient.Instance.FinishRpcImmediately(writer); FixedUpdatePatch.LoversSuicide(player.PlayerId); } diff --git a/Modules/Extensions/HazelExtensions.cs b/Modules/Extensions/HazelExtensions.cs index 9d81d4550..ac3730507 100644 --- a/Modules/Extensions/HazelExtensions.cs +++ b/Modules/Extensions/HazelExtensions.cs @@ -5,6 +5,10 @@ namespace EHR; public static class HazelExtensions { + // ------------------------------------------------------------------------------------------------------------------------- + + public static SendOption SendOption => GameStates.CurrentServerType == GameStates.ServerType.Vanilla ? SendOption.None : SendOption.Reliable; + public static void Write(this MessageWriter writer, Vector2 vector) { NetHelpers.WriteVector2(vector, writer); diff --git a/Modules/GameOptionsSender/GameOptionsSender.cs b/Modules/GameOptionsSender/GameOptionsSender.cs index 841bcb598..b159335ef 100644 --- a/Modules/GameOptionsSender/GameOptionsSender.cs +++ b/Modules/GameOptionsSender/GameOptionsSender.cs @@ -58,7 +58,7 @@ public abstract class GameOptionsSender { try { - MessageWriter writer = MessageWriter.Get(SendOption.Reliable); + MessageWriter writer = MessageWriter.Get(HazelExtensions.SendOption); writer.StartMessage(targetClientId == -1 ? Tags.GameData : Tags.GameDataTo); diff --git a/Modules/GameState.cs b/Modules/GameState.cs index 5adc80ad6..20f87e228 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -339,9 +339,6 @@ public class PlayerState(byte playerId) RPC.SendDeathReason(PlayerId, deathReason); Utils.CheckAndSpawnAdditionalRefugee(Utils.GetPlayerInfoById(PlayerId)); - - if (Utils.DoRPC && !CustomGameMode.Standard.IsActiveOrIntegrated()) - Main.AllPlayerControls.DoIf(x => x.IsNonHostModClient(), x => Player.RpcSetRoleDesync(RoleTypes.CrewmateGhost, x.GetClientId())); } } @@ -387,6 +384,7 @@ public class TaskState } HasTasks = true; + CompletedTasksCount = 0; AllTasksCount = player.Data.Tasks.Count; Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags()}: TaskCounts = {CompletedTasksCount}/{AllTasksCount}", "TaskState.Init"); } diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index a0ce3607f..a6fcce952 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -605,7 +605,7 @@ public static class GuessManager else meetingHud.ClearVote(); } - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GuessKill, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GuessKill, HazelExtensions.SendOption); writer.Write(pc.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -1034,7 +1034,7 @@ public static class GuessManager // Modded non-host client guess role/add-on private static void SendRPC(int playerId, CustomRoles role) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (int)CustomRPC.Guess, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (int)CustomRPC.Guess, HazelExtensions.SendOption); writer.Write(playerId); writer.Write((int)role); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Modules/NameColorManager.cs b/Modules/NameColorManager.cs index 821d1df85..306c04812 100644 --- a/Modules/NameColorManager.cs +++ b/Modules/NameColorManager.cs @@ -282,7 +282,7 @@ public static class NameColorManager { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNameColorData, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNameColorData, HazelExtensions.SendOption); writer.Write(seerId); writer.Write(targetId); writer.Write(colorCode); diff --git a/Modules/NameNotifyManager.cs b/Modules/NameNotifyManager.cs index 99ee3af28..387ddad32 100644 --- a/Modules/NameNotifyManager.cs +++ b/Modules/NameNotifyManager.cs @@ -72,7 +72,7 @@ public static class NameNotifyManager { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncNameNotify, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncNameNotify, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(text); writer.Write(expireTS.ToString()); diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 3d7d64324..8ef8e12f8 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -314,7 +314,7 @@ internal static class RPCHandlerPatch LateTask.New(() => { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, __instance.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, __instance.GetClientId()); AmongUsClient.Instance.FinishRpcImmediately(writer); }, 1f, "Retry Version Check Task"); } @@ -1148,7 +1148,7 @@ internal static class RPC int amountAllOptions = OptionItem.AllOptions.Count; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCustomSettings, SendOption.Reliable, targetId); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCustomSettings, HazelExtensions.SendOption, targetId); writer.Write(startAmount); writer.Write(lastAmount); @@ -1170,7 +1170,7 @@ internal static class RPC { if (AmongUsClient.Instance.AmHost) PlaySound(PlayerID, sound); - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaySound, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaySound, HazelExtensions.SendOption); writer.Write(PlayerID); writer.Write((byte)sound); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1180,7 +1180,7 @@ internal static class RPC { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllPlayerNames, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllPlayerNames, HazelExtensions.SendOption); writer.Write(Main.AllPlayerNames.Count); foreach (KeyValuePair name in Main.AllPlayerNames) @@ -1203,7 +1203,7 @@ internal static class RPC { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowPopUp, SendOption.Reliable, pc.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowPopUp, HazelExtensions.SendOption, pc.GetClientId()); writer.Write(msg); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -1212,7 +1212,7 @@ internal static class RPC { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllClientRealNames, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllClientRealNames, HazelExtensions.SendOption); writer.WritePacked(Main.AllClientRealNames.Count); foreach (KeyValuePair name in Main.AllClientRealNames) @@ -1226,7 +1226,7 @@ internal static class RPC public static void ExileAsync(PlayerControl player) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, HazelExtensions.SendOption); AmongUsClient.Instance.FinishRpcImmediately(writer); player.Exiled(); } @@ -1257,7 +1257,7 @@ internal static class RPC public static void SendDeathReason(byte playerId, PlayerState.DeathReason deathReason) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDeathReason, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDeathReason, HazelExtensions.SendOption); writer.Write(playerId); writer.Write((int)deathReason); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1333,14 +1333,14 @@ internal static class RPC { if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLoversPlayers, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLoversPlayers, HazelExtensions.SendOption); writer.Write(Main.LoversPlayers.Count); foreach (PlayerControl lp in Main.LoversPlayers) writer.Write(lp.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void SendRpcLogger(uint targetNetId, byte callId, int targetClientId = -1) + public static void SendRpcLogger(uint targetNetId, byte callId, SendOption sendOption, int targetClientId = -1) { if (!DebugModeManager.AmDebugger) return; @@ -1355,7 +1355,7 @@ internal static class RPC } catch { } - Logger.Info($"FromNetID: {targetNetId} ({from}) / TargetClientID: {targetClientId} ({target}) / CallID: {callId} ({rpcName})", "SendRPC"); + Logger.Info($"FromNetID: {targetNetId} ({from}) / TargetClientID: {targetClientId} ({target}) / CallID: {callId} ({rpcName}) / SendOption: {sendOption}", "SendRPC"); } public static string GetRpcName(byte callId) @@ -1376,7 +1376,7 @@ internal static class RPC Arsonist.CurrentDousingTarget = targetId; else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDousingTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDousingTarget, HazelExtensions.SendOption); writer.Write(arsonistId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1389,7 +1389,7 @@ internal static class RPC Revolutionist.CurrentDrawTarget = targetId; else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDrawTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDrawTarget, HazelExtensions.SendOption); writer.Write(arsonistId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1402,7 +1402,7 @@ internal static class RPC Revolutionist.CurrentDrawTarget = targetId; else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentRevealTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentRevealTarget, HazelExtensions.SendOption); writer.Write(arsonistId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1432,7 +1432,7 @@ internal static class RPC if (!AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRealKiller, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRealKiller, HazelExtensions.SendOption); writer.Write(targetId); writer.Write(killerId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1462,17 +1462,17 @@ internal static class PlayerPhysicsRPCHandlerPatch [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.StartRpc))] internal static class StartRpcPatch { - public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId) + public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(2)] SendOption option = SendOption.Reliable) { - RPC.SendRpcLogger(targetNetId, callId); + RPC.SendRpcLogger(targetNetId, callId, option); } } [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.StartRpcImmediately))] internal static class StartRpcImmediatelyPatch { - public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(3)] int targetClientId = -1) + public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(2)] SendOption option, [HarmonyArgument(3)] int targetClientId = -1) { - RPC.SendRpcLogger(targetNetId, callId, targetClientId); + RPC.SendRpcLogger(targetNetId, callId, option, targetClientId); } } \ No newline at end of file diff --git a/Modules/Utils.cs b/Modules/Utils.cs index bf403adf2..86b672e8f 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -60,6 +60,8 @@ public static class Utils public static long GameStartTimeStamp; public static readonly Dictionary LongRoleDescriptions = []; + + private static int NumSnapToRPCsThisRound; public static long TimeStamp => (long)(DateTime.Now.ToUniversalTime() - TimeStampStartTime).TotalSeconds; public static bool DoRPC => AmongUsClient.Instance.AmHost && Main.AllPlayerControls.Any(x => x.IsModClient() && !x.IsHost()); public static int TotalTaskCount => Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumLongTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumShortTasks); @@ -113,18 +115,8 @@ public static class Utils public static void CheckAndSetVentInteractions() { - var shouldPerformVentInteractions = false; - - foreach (PlayerControl pc in Main.AllPlayerControls) - { - if (VentilationSystemDeterioratePatch.BlockVentInteraction(pc)) - { - VentilationSystemDeterioratePatch.LastClosestVent[pc.PlayerId] = pc.GetVentsFromClosest()[0].Id; - shouldPerformVentInteractions = true; - } - } - - if (shouldPerformVentInteractions) SetAllVentInteractions(); + if (Main.AllPlayerControls.Any(VentilationSystemDeterioratePatch.BlockVentInteraction)) + SetAllVentInteractions(); } public static void TPAll(Vector2 location, bool log = true) @@ -143,7 +135,6 @@ public static class Utils if (pc.inVent || pc.inMovingPlat || pc.onLadder || !pc.IsAlive() || pc.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || pc.MyPhysics.Animations.IsPlayingEnterVentAnimation()) { if (log) Logger.Warn($"Target ({pc.GetNameWithRole().RemoveHtmlTags()}) is in an un-teleportable state - Teleporting canceled", "TP"); - return false; } } @@ -159,7 +150,8 @@ public static class Utils } var newSid = (ushort)(nt.lastSequenceId + 8); - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(nt.NetId, (byte)RpcCalls.SnapTo, SendOption.Reliable); + var sendOption = NumSnapToRPCsThisRound < 100 ? SendOption.Reliable : HazelExtensions.SendOption; + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(nt.NetId, (byte)RpcCalls.SnapTo, sendOption); NetHelpers.WriteVector2(location, messageWriter); messageWriter.Write(newSid); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); @@ -169,6 +161,7 @@ public static class Utils CheckInvalidMovementPatch.LastPosition[pc.PlayerId] = location; CheckInvalidMovementPatch.ExemptedPlayers.Add(pc.PlayerId); + NumSnapToRPCsThisRound++; return true; } @@ -587,7 +580,7 @@ public static class Utils public static MessageWriter CreateRPC(CustomRPC rpc) { - return AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)rpc, SendOption.Reliable); + return AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)rpc, HazelExtensions.SendOption); } public static void EndRPC(MessageWriter writer) @@ -722,7 +715,8 @@ public static class Utils public static void SetAllVentInteractions() { - VentilationSystemDeterioratePatch.SerializeV2(ShipStatus.Instance.Systems[SystemTypes.Ventilation].CastFast()); + var ventilationSystem = ShipStatus.Instance.Systems[SystemTypes.Ventilation].TryCast(); + if (ventilationSystem != null) VentilationSystemDeterioratePatch.SerializeV2(ventilationSystem); } public static bool HasTasks(NetworkedPlayerInfo p, bool ForRecompute = true) diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index 7c665c9c3..ac14d3dc3 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -430,7 +430,7 @@ internal static class GameEndChecker } // Sync of CustomWinnerHolder info - MessageWriter winnerWriter = self.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EndGame, SendOption.Reliable); + MessageWriter winnerWriter = self.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EndGame, HazelExtensions.SendOption); WriteTo(winnerWriter); self.FinishRpcImmediately(winnerWriter); diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index 0bf968311..7702d278a 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -308,7 +308,6 @@ internal static class ChangeRoleSettings Main.AllPlayerKillCooldown[pc.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.KillCooldown); ReportDeadBodyPatch.CanReport[pc.PlayerId] = true; ReportDeadBodyPatch.WaitReport[pc.PlayerId] = []; - VentilationSystemDeterioratePatch.LastClosestVent[pc.PlayerId] = 0; RoleResult[pc.PlayerId] = CustomRoles.NotAssigned; pc.cosmetics.nameText.text = pc.name; RandomSpawn.CustomNetworkTransformHandleRpcPatch.HasSpawned.Clear(); @@ -990,7 +989,7 @@ internal static class StartGameHostPatch playerInfo.IsDead = data; } - MessageWriter stream = MessageWriter.Get(SendOption.Reliable); + MessageWriter stream = MessageWriter.Get(HazelExtensions.SendOption); stream.StartMessage(5); stream.Write(AmongUsClient.Instance.GameId); @@ -1075,7 +1074,7 @@ internal static class StartGameHostPatch { foreach (PlayerControl pc in Main.AllPlayerControls) { - Senders[pc.PlayerId] = new CustomRpcSender($"{pc.name}'s SetRole Sender", SendOption.Reliable, false) + Senders[pc.PlayerId] = new CustomRpcSender($"{pc.name}'s SetRole Sender", HazelExtensions.SendOption, false) .StartMessage(pc.GetClientId()); } } @@ -1180,34 +1179,16 @@ internal static class StartGameHostPatch public static void Release() { BlockSetRole = false; - Senders.Do(kvp => kvp.Value.SendMessage()); + Senders.Values.Do(s => s.SendMessage()); - if (!CustomRoles.DoubleAgent.IsEnable()) return; - - try + System.Collections.IEnumerator ReleaseAsync() { - RoleResult.DoIf(x => x.Value == CustomRoles.DoubleAgent, k => + foreach (var sender in Senders.Values) { - var da = k.Key.GetPlayer(); - if (da == null) return; - - var ci = da.GetClientId(); - if (ci == -1) return; - - RoleResult.DoIf(x => x.Value.IsImpostor(), x => - { - var imp = x.Key.GetPlayer(); - if (imp == null) return; - - var previousRoleType = RoleMap[(k.Key, x.Key)].RoleType; - - imp.RpcSetRoleDesync(RoleTypes.Crewmate, ci); - - LateTask.New(() => imp.RpcSetRoleDesync(previousRoleType, ci), 7f, log: false); - }); - }); + sender.SendMessage(); + yield return new WaitForSeconds(0.3f); + } } - catch (Exception e) { Utils.ThrowException(e); } } public static void EndReplace() diff --git a/Patches/PhantomRolePatch.cs b/Patches/PhantomRolePatch.cs index 682cdfd46..82e4089c0 100644 --- a/Patches/PhantomRolePatch.cs +++ b/Patches/PhantomRolePatch.cs @@ -29,7 +29,7 @@ public static class PhantomRolePatch } __instance.SetRoleInvisibility(true); - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, SendOption.Reliable, AmongUsClient.Instance.HostId); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, HazelExtensions.SendOption, AmongUsClient.Instance.HostId); messageWriter.Write(maxDuration); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); return false; @@ -45,7 +45,7 @@ public static class PhantomRolePatch return false; } - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, SendOption.Reliable, AmongUsClient.Instance.HostId); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, HazelExtensions.SendOption, AmongUsClient.Instance.HostId); messageWriter.Write(shouldAnimate); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); return false; diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 744816a70..973884a76 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -81,7 +81,7 @@ internal static class RpcMurderPlayerPatch if (AmongUsClient.Instance.AmClient) __instance.MurderPlayer(target, murderResultFlags); - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption); messageWriter.WriteNetObject(target); messageWriter.Write((int)murderResultFlags); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); @@ -99,7 +99,7 @@ internal static class CmdCheckMurderPatch __instance.CheckMurder(target); else if (!CustomGameMode.FFA.IsActiveOrIntegrated()) { - MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckMurder, SendOption.Reliable); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckMurder, HazelExtensions.SendOption); messageWriter.WriteNetObject(target); AmongUsClient.Instance.FinishRpcImmediately(messageWriter); } @@ -1218,9 +1218,6 @@ internal static class FixedUpdatePatch if (AmongUsClient.Instance.AmHost && __instance.AmOwner) CustomNetObject.FixedUpdate(); - if (AmongUsClient.Instance.AmHost && __instance.IsAlive()) - VentilationSystemDeterioratePatch.CheckVentInteraction(__instance); - byte id = __instance.PlayerId; if (AmongUsClient.Instance.AmHost && GameStates.IsInTask && ReportDeadBodyPatch.CanReport[id] && ReportDeadBodyPatch.WaitReport[id].Count > 0) @@ -2349,4 +2346,43 @@ static class BootFromVentPatch { return !GameStates.IsInTask || ExileController.Instance || __instance == null || __instance.myPlayer == null || !__instance.myPlayer.IsAlive() || !__instance.myPlayer.Is(CustomRoles.Nimble); } +} + +// From https://github.com/Rabek009/MoreGamemodes - by Rabek009 +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSetColor))] +static class RpcSetColorPatch +{ + public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte bodyColor) + { + if (!AmongUsClient.Instance.AmHost) return true; + + if (AmongUsClient.Instance.AmClient) + __instance.SetColor(bodyColor); + + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.SetColor, SendOption.None); + messageWriter.Write(__instance.Data.NetId); + messageWriter.Write(bodyColor); + AmongUsClient.Instance.FinishRpcImmediately(messageWriter); + return false; + } +} + +// From https://github.com/Rabek009/MoreGamemodes - by Rabek009 +[HarmonyPatch(typeof(CustomNetworkTransform), nameof(CustomNetworkTransform.RpcSnapTo))] +static class RpcSnapToPatch +{ + public static bool Prefix(CustomNetworkTransform __instance, [HarmonyArgument(0)] Vector2 position) + { + if (!AmongUsClient.Instance.AmHost) return true; + + if (AmongUsClient.Instance.AmClient) + __instance.SnapTo(position, (ushort)(__instance.lastSequenceId + 1)); + + ushort num = (ushort)(__instance.lastSequenceId + 2); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.SnapTo, SendOption.None); + NetHelpers.WriteVector2(position, messageWriter); + messageWriter.Write(num); + AmongUsClient.Instance.FinishRpcImmediately(messageWriter); + return false; + } } \ No newline at end of file diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 2a649c625..cf12bad78 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -362,7 +362,7 @@ internal static class InnerNetClientSpawnPatch { if (client.Character == null) return; - MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, client.Character.OwnerId); + MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, client.Character.OwnerId); AmongUsClient.Instance.FinishRpcImmediately(sender); }, 3f, "RPC Request Retry Version Check"); @@ -383,7 +383,7 @@ internal static class InnerNetClientSpawnPatch // Non-host modded client else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncLobbyTimer, SendOption.Reliable, client.Id); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncLobbyTimer, HazelExtensions.SendOption, client.Id); writer.WritePacked((int)GameStartManagerPatch.TimerStartTS); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -498,7 +498,7 @@ internal static class PlayerControlCheckNamePatch { if (__instance != null && !__instance.Data.Disconnected && !__instance.IsModClient()) { - MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, __instance.OwnerId); + MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, __instance.OwnerId); AmongUsClient.Instance.FinishRpcImmediately(sender); } }, 0.6f, "Retry Version Check", false); @@ -524,7 +524,7 @@ internal static class InnerNetClientFixedUpdatePatch } [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.SetColor))] -internal static class RpcSetColorPatch +internal static class SetColorPatch { public static void Postfix(PlayerControl __instance, byte bodyColor) { diff --git a/Patches/ShipStatusPatch.cs b/Patches/ShipStatusPatch.cs index 106054a4a..10a77b142 100644 --- a/Patches/ShipStatusPatch.cs +++ b/Patches/ShipStatusPatch.cs @@ -431,12 +431,10 @@ internal static class ShipStatusSerializePatch { public static void Prefix(ShipStatus __instance, [HarmonyArgument(1)] bool initialState) { - if (!AmongUsClient.Instance.AmHost) return; - - if (initialState) return; + if (!AmongUsClient.Instance.AmHost || initialState) return; bool cancel = Main.AllPlayerControls.Any(VentilationSystemDeterioratePatch.BlockVentInteraction); - var ventilationSystem = __instance.Systems[SystemTypes.Ventilation].CastFast(); + var ventilationSystem = __instance.Systems[SystemTypes.Ventilation].TryCast(); if (cancel && ventilationSystem is { IsDirty: true }) { @@ -447,33 +445,20 @@ internal static class ShipStatusSerializePatch } [HarmonyPatch(typeof(VentilationSystem), nameof(VentilationSystem.Deteriorate))] -internal static class VentilationSystemDeterioratePatch +static class VentilationSystemDeterioratePatch { public static Dictionary LastClosestVent = []; - private static readonly Dictionary LastCanUseVent = []; - private static readonly Dictionary LastClosestVentForUpdate = []; - private static readonly Dictionary CheckBufferTime = []; public static void Postfix(VentilationSystem __instance) { - if (!AmongUsClient.Instance.AmHost) return; + if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask) return; - if (!GameStates.InGame) return; - - foreach (PlayerControl pc in Main.AllPlayerControls) + foreach (var pc in PlayerControl.AllPlayerControls) { if (BlockVentInteraction(pc)) { - var players = 0; - - foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers) - if (playerInfo != null && !playerInfo.Disconnected) - ++players; - - int closestVentId = pc.GetClosestVent().Id; - if (closestVentId == LastClosestVent[pc.PlayerId] && players >= 3) continue; - - LastClosestVent[pc.PlayerId] = closestVentId; + if (LastClosestVent.TryGetValue(pc.PlayerId, out var ventId) && pc.GetClosestVent().Id == ventId) continue; + LastClosestVent[pc.PlayerId] = pc.GetClosestVent().Id; MessageWriter writer = MessageWriter.Get(); writer.StartMessage(6); writer.Write(AmongUsClient.Instance.GameId); @@ -482,26 +467,29 @@ internal static class VentilationSystemDeterioratePatch writer.WritePacked(ShipStatus.Instance.NetId); writer.StartMessage((byte)SystemTypes.Ventilation); int vents = ShipStatus.Instance.AllVents.Count(vent => !pc.CanUseVent(vent.Id)); - List AllPlayers = []; + List allPlayers = []; - foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers) + foreach (var playerInfo in GameData.Instance.AllPlayers) + { if (playerInfo != null && !playerInfo.Disconnected) - AllPlayers.Add(playerInfo); + allPlayers.Add(playerInfo); + } - int maxVents = Math.Min(vents, AllPlayers.Count); - var blockedVents = 0; + int maxVents = Math.Min(vents, allPlayers.Count); + int blockedVents = 0; writer.WritePacked(maxVents); - foreach (Vent vent in pc.GetVentsFromClosest()) + foreach (var vent in pc.GetVentsFromClosest()) { if (!pc.CanUseVent(vent.Id)) { - writer.Write(AllPlayers[blockedVents].PlayerId); + writer.Write(allPlayers[blockedVents].PlayerId); writer.Write((byte)vent.Id); ++blockedVents; } - if (blockedVents >= maxVents) break; + if (blockedVents >= maxVents) + break; } writer.WritePacked(__instance.PlayersInsideVents.Count); @@ -523,15 +511,14 @@ internal static class VentilationSystemDeterioratePatch public static bool BlockVentInteraction(PlayerControl pc) { - return !pc.AmOwner && (!pc.IsModClient() || (!pc.IsHost() && CustomGameMode.RoomRush.IsActiveOrIntegrated())) && !pc.Data.IsDead && (pc.IsImpostor() || pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom) && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id)); + return !pc.AmOwner && !pc.IsModClient() && !pc.Data.IsDead && pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id)); } public static void SerializeV2(VentilationSystem __instance, PlayerControl player = null) { - foreach (PlayerControl pc in Main.AllPlayerControls) + foreach (var pc in PlayerControl.AllPlayerControls) { if (pc.AmOwner) continue; - if (player != null && pc != player) continue; if (BlockVentInteraction(pc)) @@ -544,26 +531,29 @@ internal static class VentilationSystemDeterioratePatch writer.WritePacked(ShipStatus.Instance.NetId); writer.StartMessage((byte)SystemTypes.Ventilation); int vents = ShipStatus.Instance.AllVents.Count(vent => !pc.CanUseVent(vent.Id)); - List AllPlayers = []; + List allPlayers = []; - foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers) + foreach (var playerInfo in GameData.Instance.AllPlayers) + { if (playerInfo != null && !playerInfo.Disconnected) - AllPlayers.Add(playerInfo); + allPlayers.Add(playerInfo); + } - int maxVents = Math.Min(vents, AllPlayers.Count); - var blockedVents = 0; + int maxVents = Math.Min(vents, allPlayers.Count); + int blockedVents = 0; writer.WritePacked(maxVents); - foreach (Vent vent in pc.GetVentsFromClosest()) + foreach (var vent in pc.GetVentsFromClosest()) { if (!pc.CanUseVent(vent.Id)) { - writer.Write(AllPlayers[blockedVents].PlayerId); + writer.Write(allPlayers[blockedVents].PlayerId); writer.Write((byte)vent.Id); ++blockedVents; } - if (blockedVents >= maxVents) break; + if (blockedVents >= maxVents) + break; } writer.WritePacked(__instance.PlayersInsideVents.Count); @@ -598,50 +588,6 @@ internal static class VentilationSystemDeterioratePatch } } } - - public static void CheckVentInteraction(PlayerControl pc) - { - if (!GameStates.IsInTask || ExileController.Instance || !ShipStatus.Instance) return; - - const int bufferTimeWait = 10; - - if (!CheckBufferTime.TryGetValue(pc.PlayerId, out int bufferTime)) - { - CheckBufferTime[pc.PlayerId] = bufferTimeWait; - return; - } - - if (bufferTime > 0) - { - CheckBufferTime[pc.PlayerId]--; - return; - } - - CheckBufferTime[pc.PlayerId] = bufferTimeWait; - - - int closestVent = pc.GetClosestVent().Id; - - if (!LastClosestVentForUpdate.TryGetValue(pc.PlayerId, out int lastClosestVent)) - { - LastClosestVentForUpdate[pc.PlayerId] = closestVent; - return; - } - - bool canUse = pc.CanUseVent(closestVent); - - if (!LastCanUseVent.TryGetValue(pc.PlayerId, out bool couldUse)) - { - LastCanUseVent[pc.PlayerId] = canUse; - return; - } - - if (couldUse != canUse || lastClosestVent != closestVent) - { - LastCanUseVent[pc.PlayerId] = canUse; - pc.RpcSetVentInteraction(); - } - } } [HarmonyPatch(typeof(VentilationSystem), nameof(VentilationSystem.IsVentCurrentlyBeingCleaned))] diff --git a/Patches/TaskAssignPatch.cs b/Patches/TaskAssignPatch.cs index 69d4c6e4d..0ef3e88e9 100644 --- a/Patches/TaskAssignPatch.cs +++ b/Patches/TaskAssignPatch.cs @@ -266,9 +266,10 @@ internal static class RpcSetTasksPatch NormalPlayerTask[] allTasks = ShortTasks.ToArray().Concat(LongTasks.ToArray()).ToArray(); Il2CppSystem.Text.StringBuilder sb = new(); - foreach (TaskTypes taskType in usedTaskTypes) { GetTaskFromTaskType(taskType).AppendTaskText(sb); } + foreach (TaskTypes taskType in usedTaskTypes) + GetTaskFromTaskType(taskType)?.AppendTaskText(sb); - Logger.Info($" Assigned tasks:\n{sb.Replace("\r\n", "\n").ToString()}", pc.GetRealName(), multiLine: true); + Logger.Info($" Changed Assigned tasks:\n{sb.Replace("\r\n", "\n").ToString()}", pc.GetRealName(), multiLine: true); PlayerTask GetTaskFromTaskType(TaskTypes type) => allTasks.FirstOrDefault(t => t.TaskType == type); } diff --git a/Roles/AddOns/Crewmate/Stressed.cs b/Roles/AddOns/Crewmate/Stressed.cs index f80688a42..a4d771a3d 100644 --- a/Roles/AddOns/Crewmate/Stressed.cs +++ b/Roles/AddOns/Crewmate/Stressed.cs @@ -152,7 +152,7 @@ public class Stressed : IAddon { if (!Utils.DoRPC || !IsEnable) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncStressedTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncStressedTimer, HazelExtensions.SendOption); writer.Write(id); writer.Write(time); writer.Write(lastUpdate.ToString()); diff --git a/Roles/AddOns/Crewmate/Workhorse.cs b/Roles/AddOns/Crewmate/Workhorse.cs index 94ca6a69f..243644609 100644 --- a/Roles/AddOns/Crewmate/Workhorse.cs +++ b/Roles/AddOns/Crewmate/Workhorse.cs @@ -101,7 +101,7 @@ public class Workhorse : IAddon if (AmongUsClient.Instance.AmHost) { Add(pc.PlayerId); - pc.Data.RpcSetTasks(new(0)); // Redistribute tasks + pc.RpcResetTasks(); pc.SyncSettings(); Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc); } diff --git a/Roles/AddOns/GhostRoles/Haunter.cs b/Roles/AddOns/GhostRoles/Haunter.cs index 677421c9d..9ed1de748 100644 --- a/Roles/AddOns/GhostRoles/Haunter.cs +++ b/Roles/AddOns/GhostRoles/Haunter.cs @@ -45,7 +45,7 @@ internal class Haunter : IGhostRole taskState.CompletedTasksCount = 0; taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks); - pc.Data.RpcSetTasks(new(0)); + pc.RpcResetTasks(); pc.SyncSettings(); pc.RpcResetAbilityCooldown(); Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc); diff --git a/Roles/AddOns/GhostRoles/Specter.cs b/Roles/AddOns/GhostRoles/Specter.cs index 318d98539..0c894815b 100644 --- a/Roles/AddOns/GhostRoles/Specter.cs +++ b/Roles/AddOns/GhostRoles/Specter.cs @@ -24,7 +24,7 @@ internal class Specter : IGhostRole taskState.CompletedTasksCount = 0; taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks); - pc.Data.RpcSetTasks(new(0)); + pc.RpcResetTasks(); pc.SyncSettings(); pc.RpcResetAbilityCooldown(); Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc); diff --git a/Roles/AddOns/Impostor/Damocles.cs b/Roles/AddOns/Impostor/Damocles.cs index 80557ac20..57599482a 100644 --- a/Roles/AddOns/Impostor/Damocles.cs +++ b/Roles/AddOns/Impostor/Damocles.cs @@ -91,7 +91,7 @@ public class Damocles : IAddon { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncDamoclesTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncDamoclesTimer, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(Timer[playerId]); writer.Write(LastUpdate[playerId].ToString()); diff --git a/Roles/Crewmate/Alchemist.cs b/Roles/Crewmate/Alchemist.cs index 4e9607565..409e15f43 100644 --- a/Roles/Crewmate/Alchemist.cs +++ b/Roles/Crewmate/Alchemist.cs @@ -103,7 +103,7 @@ public class Alchemist : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistPotion, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistPotion, HazelExtensions.SendOption); writer.Write(AlchemistId); writer.Write(IsProtected); writer.Write(PotionID); @@ -250,7 +250,7 @@ public class Alchemist : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistTimer, HazelExtensions.SendOption); writer.Write(AlchemistId); writer.Write(InvisTime.ToString()); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -284,7 +284,7 @@ public class Alchemist : RoleBase { ventedId = ventId; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(instance.NetId, 34, SendOption.Reliable, pc.GetClientId()); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(instance.NetId, 34, HazelExtensions.SendOption, pc.GetClientId()); writer.WritePacked(ventId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Benefactor.cs b/Roles/Crewmate/Benefactor.cs index 22881a3f2..8879c0cbb 100644 --- a/Roles/Crewmate/Benefactor.cs +++ b/Roles/Crewmate/Benefactor.cs @@ -61,7 +61,7 @@ internal class Benefactor : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBenefactorMarkedTask, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBenefactorMarkedTask, HazelExtensions.SendOption); writer.Write(benefactorId); writer.Write(taskIndex); writer.Write(isShield); diff --git a/Roles/Crewmate/Cleanser.cs b/Roles/Crewmate/Cleanser.cs index 3d0141779..6e416902d 100644 --- a/Roles/Crewmate/Cleanser.cs +++ b/Roles/Crewmate/Cleanser.cs @@ -73,7 +73,7 @@ public class Cleanser : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCleanserCleanLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCleanserCleanLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(CleanserUses); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Dad.cs b/Roles/Crewmate/Dad.cs index fa1953170..a56b72ee3 100644 --- a/Roles/Crewmate/Dad.cs +++ b/Roles/Crewmate/Dad.cs @@ -301,7 +301,8 @@ public class Dad : RoleBase if (completedTaskCount + 1 >= totalTaskCount) { - pc.Data.RpcSetTasks(new(0)); + pc.RpcResetTasks(); + pc.SyncSettings(); DoneTasks = true; GameData.Instance.RecomputeTaskCounts(); } diff --git a/Roles/Crewmate/Druid.cs b/Roles/Crewmate/Druid.cs index b41cc084e..30adca92a 100644 --- a/Roles/Crewmate/Druid.cs +++ b/Roles/Crewmate/Druid.cs @@ -85,7 +85,7 @@ public class Druid : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTrigger, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTrigger, HazelExtensions.SendOption); writer.Write(add); writer.Write(playerId); writer.Write(position.x); diff --git a/Roles/Crewmate/Jailer.cs b/Roles/Crewmate/Jailer.cs index 5f500ec58..cf320bfa6 100644 --- a/Roles/Crewmate/Jailer.cs +++ b/Roles/Crewmate/Jailer.cs @@ -77,14 +77,14 @@ public class Jailor : RoleBase if (!setTarget) { - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorExeLimit, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorExeLimit, HazelExtensions.SendOption); writer.Write(jailerId); writer.Write(JailorDidVote); AmongUsClient.Instance.FinishRpcImmediately(writer); return; } - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorTarget, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorTarget, HazelExtensions.SendOption); writer.Write(jailerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Medic.cs b/Roles/Crewmate/Medic.cs index 71f02702e..802600d30 100644 --- a/Roles/Crewmate/Medic.cs +++ b/Roles/Crewmate/Medic.cs @@ -113,7 +113,7 @@ public class Medic : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectList, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectList, HazelExtensions.SendOption); writer.Write(ProtectList.Count); ProtectList.Do(x => writer.Write(x)); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/NiceHacker.cs b/Roles/Crewmate/NiceHacker.cs index 182eea4ce..6910d6e20 100644 --- a/Roles/Crewmate/NiceHacker.cs +++ b/Roles/Crewmate/NiceHacker.cs @@ -93,7 +93,7 @@ public class NiceHacker : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceHackerLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceHackerLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(secondsLeft); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/NiceSwapper.cs b/Roles/Crewmate/NiceSwapper.cs index ec45dd7f0..bf7842697 100644 --- a/Roles/Crewmate/NiceSwapper.cs +++ b/Roles/Crewmate/NiceSwapper.cs @@ -255,7 +255,7 @@ public class NiceSwapper : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceSwapperVotes, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceSwapperVotes, HazelExtensions.SendOption); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Crewmate/Psychic.cs b/Roles/Crewmate/Psychic.cs index f65decb92..956157271 100644 --- a/Roles/Crewmate/Psychic.cs +++ b/Roles/Crewmate/Psychic.cs @@ -69,7 +69,7 @@ public class Psychic : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPsychicRedList, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPsychicRedList, HazelExtensions.SendOption); writer.Write(PsychicId); writer.Write(RedPlayer.Count); foreach (byte pc in RedPlayer) writer.Write(pc); diff --git a/Roles/Crewmate/Ricochet.cs b/Roles/Crewmate/Ricochet.cs index 5dbd40d51..a0d1aec80 100644 --- a/Roles/Crewmate/Ricochet.cs +++ b/Roles/Crewmate/Ricochet.cs @@ -63,7 +63,7 @@ public class Ricochet : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetTarget, HazelExtensions.SendOption); writer.Write(RicochetId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/SabotageMaster.cs b/Roles/Crewmate/SabotageMaster.cs index 6a358e02b..fd8442753 100644 --- a/Roles/Crewmate/SabotageMaster.cs +++ b/Roles/Crewmate/SabotageMaster.cs @@ -80,7 +80,7 @@ public class SabotageMaster : RoleBase MaxFixedViaPet = new IntegerOptionItem(Id + 21, "SMMaxFixedViaPet", new(1, 30, 1), 1, TabGroup.CrewmateRoles) .SetParent(CanFixSabotageFromAnywhereWithPet); - + CanVent = new BooleanOptionItem(Id + 22, "CanVent", true, TabGroup.CrewmateRoles) .SetParent(Options.CustomRoleSpawnChances[CustomRoles.SabotageMaster]); } @@ -150,7 +150,7 @@ public class SabotageMaster : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSabotageMasterLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSabotageMasterLimit, HazelExtensions.SendOption); writer.Write(SMId); writer.Write(UsedSkillCount); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Scout.cs b/Roles/Crewmate/Scout.cs index d70acfb90..e4a42e455 100644 --- a/Roles/Crewmate/Scout.cs +++ b/Roles/Crewmate/Scout.cs @@ -80,7 +80,7 @@ public class Scout : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrackerTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrackerTarget, HazelExtensions.SendOption); writer.Write(trackerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Spy.cs b/Roles/Crewmate/Spy.cs index a08361d77..ab3bd90c3 100644 --- a/Roles/Crewmate/Spy.cs +++ b/Roles/Crewmate/Spy.cs @@ -65,7 +65,7 @@ public class Spy : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncSpy, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncSpy, HazelExtensions.SendOption); writer.Write(operate); switch (operate) diff --git a/Roles/Crewmate/SwordsMan.cs b/Roles/Crewmate/SwordsMan.cs index 181619082..7025c6a1e 100644 --- a/Roles/Crewmate/SwordsMan.cs +++ b/Roles/Crewmate/SwordsMan.cs @@ -82,7 +82,7 @@ public class SwordsMan : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwordsManKill, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwordsManKill, HazelExtensions.SendOption); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Crewmate/Tether.cs b/Roles/Crewmate/Tether.cs index 66ca34bad..ab7835832 100644 --- a/Roles/Crewmate/Tether.cs +++ b/Roles/Crewmate/Tether.cs @@ -68,7 +68,7 @@ public class Tether : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherTarget, HazelExtensions.SendOption); writer.Write(TetherId); writer.Write(Target); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Tornado.cs b/Roles/Crewmate/Tornado.cs index af04b8ab7..3fee0a806 100644 --- a/Roles/Crewmate/Tornado.cs +++ b/Roles/Crewmate/Tornado.cs @@ -93,7 +93,7 @@ internal class Tornado : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AddTornado, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AddTornado, HazelExtensions.SendOption); writer.Write(add); writer.Write(pos.x); writer.Write(pos.y); diff --git a/Roles/Impostor/Assassin.cs b/Roles/Impostor/Assassin.cs index 1e7dcb634..061a82a0e 100644 --- a/Roles/Impostor/Assassin.cs +++ b/Roles/Impostor/Assassin.cs @@ -16,7 +16,7 @@ internal class Assassin : RoleBase private static OptionItem MarkCooldownOpt; public static OptionItem AssassinateCooldownOpt; private static OptionItem CanKillAfterAssassinateOpt; - + private float AssassinateCooldown; private bool CanKillAfterAssassinate; private bool IsUndertaker; @@ -77,7 +77,7 @@ internal class Assassin : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayer, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(MarkedPlayer); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/BallLightning.cs b/Roles/Impostor/BallLightning.cs index 41fab01b2..06544c42e 100644 --- a/Roles/Impostor/BallLightning.cs +++ b/Roles/Impostor/BallLightning.cs @@ -60,7 +60,7 @@ public class BallLightning : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGhostPlayer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGhostPlayer, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(IsGhost(playerId)); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/BountyHunter.cs b/Roles/Impostor/BountyHunter.cs index 2a7212bf5..d832279be 100644 --- a/Roles/Impostor/BountyHunter.cs +++ b/Roles/Impostor/BountyHunter.cs @@ -86,7 +86,7 @@ public class BountyHunter : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBountyTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBountyTarget, HazelExtensions.SendOption); writer.Write(BountyId); writer.Write(Target); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Capitalism.cs b/Roles/Impostor/Capitalism.cs index 1d18951e1..3cbfc5de2 100644 --- a/Roles/Impostor/Capitalism.cs +++ b/Roles/Impostor/Capitalism.cs @@ -64,7 +64,7 @@ internal class Capitalism : RoleBase taskState.AllTasksCount += amount; CapitalismAddTask.Remove(player.PlayerId); taskState.CompletedTasksCount++; - player.Data.RpcSetTasks(new(0)); // Redistribute tasks + player.RpcResetTasks(); player.SyncSettings(); Utils.NotifyRoles(SpecifySeer: player, SpecifyTarget: player); return false; diff --git a/Roles/Impostor/Chronomancer.cs b/Roles/Impostor/Chronomancer.cs index 554bf1fad..fd67693cb 100644 --- a/Roles/Impostor/Chronomancer.cs +++ b/Roles/Impostor/Chronomancer.cs @@ -41,7 +41,7 @@ public class Chronomancer : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncChronomancer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncChronomancer, HazelExtensions.SendOption); writer.Write(ChronomancerId); writer.Write(IsRampaging); writer.Write(ChargePercent); diff --git a/Roles/Impostor/Councillor.cs b/Roles/Impostor/Councillor.cs index e9eec8640..46cdcd276 100644 --- a/Roles/Impostor/Councillor.cs +++ b/Roles/Impostor/Councillor.cs @@ -299,7 +299,7 @@ public class Councillor : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MeetingKill, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MeetingKill, HazelExtensions.SendOption); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Impostor/Crewpostor.cs b/Roles/Impostor/Crewpostor.cs index 5deab4022..12017153d 100644 --- a/Roles/Impostor/Crewpostor.cs +++ b/Roles/Impostor/Crewpostor.cs @@ -114,7 +114,7 @@ internal class Crewpostor : RoleBase } else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCpTasksDone, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCpTasksDone, HazelExtensions.SendOption); writer.Write(cpID); writer.Write(tasksDone); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/EvilDiviner.cs b/Roles/Impostor/EvilDiviner.cs index 448025d39..8eec75da8 100644 --- a/Roles/Impostor/EvilDiviner.cs +++ b/Roles/Impostor/EvilDiviner.cs @@ -89,7 +89,7 @@ public class EvilDiviner : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilDiviner, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilDiviner, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/EvilTracker.cs b/Roles/Impostor/EvilTracker.cs index 4b43fcc7f..806fb1fe3 100644 --- a/Roles/Impostor/EvilTracker.cs +++ b/Roles/Impostor/EvilTracker.cs @@ -179,7 +179,7 @@ public class EvilTracker : RoleBase if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilTrackerTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilTrackerTarget, HazelExtensions.SendOption); writer.Write(trackerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/FireWorks.cs b/Roles/Impostor/FireWorks.cs index 75f11cf45..5736ef8f7 100644 --- a/Roles/Impostor/FireWorks.cs +++ b/Roles/Impostor/FireWorks.cs @@ -89,7 +89,7 @@ public class FireWorks : RoleBase if (!On || !Utils.DoRPC) return; Logger.Info($"Player{playerId}:SendRPC", "FireWorks"); - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SendFireWorksState, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SendFireWorksState, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(nowFireWorksCount); writer.Write((int)state); @@ -106,14 +106,8 @@ public class FireWorks : RoleBase { if (pc == null || pc.Data.IsDead) return false; - try - { - return CanKill.GetBool() || (state & FireWorksState.CanUseKill) != 0; - } - catch - { - return false; - } + try { return CanKill.GetBool() || (state & FireWorksState.CanUseKill) != 0; } + catch { return false; } } public override void OnPet(PlayerControl pc) diff --git a/Roles/Impostor/Greedier.cs b/Roles/Impostor/Greedier.cs index 838f26d54..95c948ac8 100644 --- a/Roles/Impostor/Greedier.cs +++ b/Roles/Impostor/Greedier.cs @@ -92,7 +92,7 @@ public class Greedier : RoleBase // Also used for Imitator as the NK version of { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGreedierOe, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGreedierOe, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(IsOdd); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Hitman.cs b/Roles/Impostor/Hitman.cs index 6945f7c0e..3a1281132 100644 --- a/Roles/Impostor/Hitman.cs +++ b/Roles/Impostor/Hitman.cs @@ -69,7 +69,7 @@ public class Hitman : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHitmanTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHitmanTarget, HazelExtensions.SendOption); writer.Write(HitmanId); writer.Write(TargetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Librarian.cs b/Roles/Impostor/Librarian.cs index 1afff9c1e..48eb445c7 100644 --- a/Roles/Impostor/Librarian.cs +++ b/Roles/Impostor/Librarian.cs @@ -91,7 +91,7 @@ public class Librarian : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLibrarianMode, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLibrarianMode, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(isInSilenceMode); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Mafia.cs b/Roles/Impostor/Mafia.cs index 576924328..c9953d4aa 100644 --- a/Roles/Impostor/Mafia.cs +++ b/Roles/Impostor/Mafia.cs @@ -182,7 +182,7 @@ internal class Mafia : RoleBase private static void SendRPC(byte playerId) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MafiaRevenge, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MafiaRevenge, HazelExtensions.SendOption); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Impostor/Mafioso.cs b/Roles/Impostor/Mafioso.cs index d59e353b2..2e9b316bf 100644 --- a/Roles/Impostor/Mafioso.cs +++ b/Roles/Impostor/Mafioso.cs @@ -119,7 +119,7 @@ public class Mafioso : RoleBase { if (!IsEnable || !DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoData, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoData, HazelExtensions.SendOption); writer.Write(MafiosoId); writer.Write(Tier); writer.Write(XP); @@ -148,7 +148,7 @@ public class Mafioso : RoleBase { if (!IsEnable || !DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoPistolCD, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoPistolCD, HazelExtensions.SendOption); writer.Write(MafiosoId); writer.Write(Pistol1CD); writer.Write(Pistol2CD); diff --git a/Roles/Impostor/Penguin.cs b/Roles/Impostor/Penguin.cs index e21747061..a2b5b1911 100644 --- a/Roles/Impostor/Penguin.cs +++ b/Roles/Impostor/Penguin.cs @@ -134,7 +134,7 @@ public class Penguin : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PenguinSync, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PenguinSync, HazelExtensions.SendOption); writer.Write(PenguinId); writer.Write(1); writer.Write(AbductVictim?.PlayerId ?? 255); diff --git a/Roles/Impostor/QuickShooter.cs b/Roles/Impostor/QuickShooter.cs index 75042b005..67241c600 100644 --- a/Roles/Impostor/QuickShooter.cs +++ b/Roles/Impostor/QuickShooter.cs @@ -57,7 +57,7 @@ internal class QuickShooter : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetQuickShooterShotLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetQuickShooterShotLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(ShotLimit[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Sniper.cs b/Roles/Impostor/Sniper.cs index b50ead554..25ec3dbb5 100644 --- a/Roles/Impostor/Sniper.cs +++ b/Roles/Impostor/Sniper.cs @@ -115,7 +115,7 @@ public class Sniper : RoleBase { if (!On || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SniperSync, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SniperSync, HazelExtensions.SendOption); writer.Write(sniperId); writer.Write(shotNotify.Count); foreach (byte sn in shotNotify) writer.Write(sn); diff --git a/Roles/Impostor/Swooper.cs b/Roles/Impostor/Swooper.cs index bd64fd685..7e20a84fc 100644 --- a/Roles/Impostor/Swooper.cs +++ b/Roles/Impostor/Swooper.cs @@ -133,7 +133,7 @@ public class Swooper : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSwooperTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSwooperTimer, HazelExtensions.SendOption); writer.Write(SwooperId); writer.Write(InvisTime.ToString()); writer.Write(lastTime.ToString()); diff --git a/Roles/Impostor/Wildling.cs b/Roles/Impostor/Wildling.cs index c9badbaf2..9e81c5605 100644 --- a/Roles/Impostor/Wildling.cs +++ b/Roles/Impostor/Wildling.cs @@ -125,7 +125,7 @@ public class Wildling : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBkTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBkTimer, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(TimeStamp.ToString()); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Witch.cs b/Roles/Impostor/Witch.cs index d9bf6ebf3..4ed99f303 100644 --- a/Roles/Impostor/Witch.cs +++ b/Roles/Impostor/Witch.cs @@ -75,14 +75,14 @@ public class Witch : RoleBase if (doSpell) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoSpell, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoSpell, HazelExtensions.SendOption); writer.Write(witchId); writer.Write(target); AmongUsClient.Instance.FinishRpcImmediately(writer); } else { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillOrSpell, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillOrSpell, HazelExtensions.SendOption); writer.Write(witchId); writer.Write(spellMode); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/YinYanger.cs b/Roles/Impostor/YinYanger.cs index 5c70b9ca8..3d711e924 100644 --- a/Roles/Impostor/YinYanger.cs +++ b/Roles/Impostor/YinYanger.cs @@ -54,7 +54,7 @@ public class YinYanger : RoleBase { if (!DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncYinYanger, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncYinYanger, HazelExtensions.SendOption); writer.Write(YinYangerId); writer.Write(isClear); if (!isClear) writer.Write(playerId); diff --git a/Roles/Neutral/Agitater.cs b/Roles/Neutral/Agitater.cs index 4a213a8c7..5c174bcab 100644 --- a/Roles/Neutral/Agitater.cs +++ b/Roles/Neutral/Agitater.cs @@ -246,7 +246,7 @@ public class Agitater : RoleBase private void SendRPC(byte newbomb, byte oldbomb) { - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcPassBomb, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcPassBomb, HazelExtensions.SendOption); writer.Write(AgitaterId); writer.Write(newbomb); writer.Write(oldbomb); diff --git a/Roles/Neutral/Bandit.cs b/Roles/Neutral/Bandit.cs index 8d4df40df..9d51b437c 100644 --- a/Roles/Neutral/Bandit.cs +++ b/Roles/Neutral/Bandit.cs @@ -86,7 +86,7 @@ public class Bandit : RoleBase { if (!On || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBanditStealLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBanditStealLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(TotalSteals[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Bubble.cs b/Roles/Neutral/Bubble.cs index e57b4a0db..fd5a053d5 100644 --- a/Roles/Neutral/Bubble.cs +++ b/Roles/Neutral/Bubble.cs @@ -88,7 +88,7 @@ internal class Bubble : RoleBase { if (!IsEnable || !DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBubble, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBubble, HazelExtensions.SendOption); writer.Write(remove); writer.Write(clear); writer.Write(id); diff --git a/Roles/Neutral/Collector.cs b/Roles/Neutral/Collector.cs index 9d152f23d..d90bcc276 100644 --- a/Roles/Neutral/Collector.cs +++ b/Roles/Neutral/Collector.cs @@ -47,7 +47,7 @@ public class Collector : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCollectorVotes, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCollectorVotes, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(CollectVote[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/DarkHide.cs b/Roles/Neutral/DarkHide.cs index cbbd0e721..fd65297a1 100644 --- a/Roles/Neutral/DarkHide.cs +++ b/Roles/Neutral/DarkHide.cs @@ -78,7 +78,7 @@ public class DarkHide : RoleBase { if (!IsEnable || !Utils.DoRPC || !AmongUsClient.Instance.AmHost) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDarkHiderKillCount, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDarkHiderKillCount, HazelExtensions.SendOption); writer.Write(player.PlayerId); writer.Write(IsWinKill); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -113,7 +113,7 @@ public class DarkHide : RoleBase if (succeeded && SnatchesWin.GetBool()) IsWinKill = true; DRpcSetKillCount(killer); - MessageWriter SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, killer.GetClientId()); + MessageWriter SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, killer.GetClientId()); SabotageFixWriter.Write((byte)SystemTypes.Electrical); SabotageFixWriter.WriteNetObject(killer); AmongUsClient.Instance.FinishRpcImmediately(SabotageFixWriter); @@ -122,7 +122,7 @@ public class DarkHide : RoleBase { if (target.PlayerId == killer.PlayerId || target.Data.Disconnected) continue; - SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, target.GetClientId()); + SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, target.GetClientId()); SabotageFixWriter.Write((byte)SystemTypes.Electrical); SabotageFixWriter.WriteNetObject(target); AmongUsClient.Instance.FinishRpcImmediately(SabotageFixWriter); diff --git a/Roles/Neutral/Doomsayer.cs b/Roles/Neutral/Doomsayer.cs index cac73a823..dcea7aef8 100644 --- a/Roles/Neutral/Doomsayer.cs +++ b/Roles/Neutral/Doomsayer.cs @@ -99,7 +99,7 @@ public class Doomsayer : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, HazelExtensions.SendOption); writer.Write(player.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Neutral/Doppelganger.cs b/Roles/Neutral/Doppelganger.cs index ddef0c920..d0940d619 100644 --- a/Roles/Neutral/Doppelganger.cs +++ b/Roles/Neutral/Doppelganger.cs @@ -104,7 +104,7 @@ public class Doppelganger : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoppelgangerStealLimit, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoppelgangerStealLimit, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(TotalSteals[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Executioner.cs b/Roles/Neutral/Executioner.cs index 99e3b8096..4550b9a9f 100644 --- a/Roles/Neutral/Executioner.cs +++ b/Roles/Neutral/Executioner.cs @@ -100,7 +100,7 @@ public class Executioner : RoleBase switch (Progress) { case "SetTarget": - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetExecutionerTarget, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetExecutionerTarget, HazelExtensions.SendOption); writer.Write(executionerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -108,7 +108,7 @@ public class Executioner : RoleBase case "": if (!AmongUsClient.Instance.AmHost) return; - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveExecutionerTarget, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveExecutionerTarget, HazelExtensions.SendOption); writer.Write(executionerId); AmongUsClient.Instance.FinishRpcImmediately(writer); break; @@ -186,4 +186,4 @@ public class Executioner : RoleBase CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Executioner); CustomWinnerHolder.WinnerIds.Add(playerId); } -} +} \ No newline at end of file diff --git a/Roles/Neutral/Gamer.cs b/Roles/Neutral/Gamer.cs index 47dd6226b..aa5145ab1 100644 --- a/Roles/Neutral/Gamer.cs +++ b/Roles/Neutral/Gamer.cs @@ -94,7 +94,7 @@ public class Gamer : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGamerHealth, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGamerHealth, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(GamerHealth.TryGetValue(playerId, out int value) ? value : PlayerHealth[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Glitch.cs b/Roles/Neutral/Glitch.cs index 151f88618..74c5c298f 100644 --- a/Roles/Neutral/Glitch.cs +++ b/Roles/Neutral/Glitch.cs @@ -115,7 +115,7 @@ public class Glitch : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchTimers, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchTimers, HazelExtensions.SendOption); writer.Write(GlitchId); writer.Write(MimicCDTimer); writer.Write(MimicDurTimer); diff --git a/Roles/Neutral/Hookshot.cs b/Roles/Neutral/Hookshot.cs index de08a73b6..bcbb07988 100644 --- a/Roles/Neutral/Hookshot.cs +++ b/Roles/Neutral/Hookshot.cs @@ -77,7 +77,7 @@ internal class Hookshot : RoleBase { if (!IsEnable || !DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncHookshot, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncHookshot, HazelExtensions.SendOption); writer.Write(HookshotId); writer.Write(ToTargetTP); writer.Write(MarkedPlayerId); diff --git a/Roles/Neutral/Lawyer.cs b/Roles/Neutral/Lawyer.cs index 969e58f4a..6bec0c2e0 100644 --- a/Roles/Neutral/Lawyer.cs +++ b/Roles/Neutral/Lawyer.cs @@ -101,7 +101,7 @@ public class Lawyer : RoleBase switch (Progress) { case "SetTarget": - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLawyerTarget, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLawyerTarget, HazelExtensions.SendOption); writer.Write(lawyerId); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -109,7 +109,7 @@ public class Lawyer : RoleBase case "": if (!AmongUsClient.Instance.AmHost) return; - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveLawyerTarget, SendOption.Reliable); + writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveLawyerTarget, HazelExtensions.SendOption); writer.Write(lawyerId); AmongUsClient.Instance.FinishRpcImmediately(writer); break; @@ -189,4 +189,4 @@ public class Lawyer : RoleBase { if (MeetingStates.FirstMeeting && TargetKnowsLawyer.GetBool() && Target.TryGetValue(LawyerId, out byte target)) LateTask.New(() => Utils.SendMessage("\n", target, string.Format(Translator.GetString("YourLawyerIsNotify"), LawyerId.ColoredPlayerName())), 10f, log: false); } -} +} \ No newline at end of file diff --git a/Roles/Neutral/Mycologist.cs b/Roles/Neutral/Mycologist.cs index 9de24d655..f24dd8caa 100644 --- a/Roles/Neutral/Mycologist.cs +++ b/Roles/Neutral/Mycologist.cs @@ -91,7 +91,7 @@ internal class Mycologist : RoleBase { if (!IsEnable || !DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMycologist, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMycologist, HazelExtensions.SendOption); writer.Write(MycologistId); writer.Write(InfectedPlayers.Count); diff --git a/Roles/Neutral/Pelican.cs b/Roles/Neutral/Pelican.cs index 4b72e73b6..c057c479f 100644 --- a/Roles/Neutral/Pelican.cs +++ b/Roles/Neutral/Pelican.cs @@ -80,7 +80,7 @@ public class Pelican : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPelicanEtenNum, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPelicanEtenNum, HazelExtensions.SendOption); writer.Write(playerId); if (playerId != byte.MaxValue) diff --git a/Roles/Neutral/PlagueBearer.cs b/Roles/Neutral/PlagueBearer.cs index 3148f6f7f..c06a63b3c 100644 --- a/Roles/Neutral/PlagueBearer.cs +++ b/Roles/Neutral/PlagueBearer.cs @@ -80,7 +80,7 @@ public class PlagueBearer : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPlaguedPlayer, SendOption.Reliable); //RPCによる同期 + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPlaguedPlayer, HazelExtensions.SendOption); //RPCによる同期 writer.Write(player.PlayerId); writer.Write(target.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/PlagueDoctor.cs b/Roles/Neutral/PlagueDoctor.cs index 13daef898..9bf0c0681 100644 --- a/Roles/Neutral/PlagueDoctor.cs +++ b/Roles/Neutral/PlagueDoctor.cs @@ -133,7 +133,7 @@ public class PlagueDoctor : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlagueDoctor, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlagueDoctor, HazelExtensions.SendOption); writer.Write(targetId); writer.Write(rate); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index dfed45d9d..a7f7b8f8c 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -122,7 +122,7 @@ public class Romantic : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncRomanticTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncRomanticTarget, HazelExtensions.SendOption); writer.Write(PartnerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -393,7 +393,7 @@ public class VengefulRomantic : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengefulRomanticTarget, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengefulRomanticTarget, HazelExtensions.SendOption); writer.Write(Target); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Neutral/Totocalcio.cs b/Roles/Neutral/Totocalcio.cs index babee2057..3f587497a 100644 --- a/Roles/Neutral/Totocalcio.cs +++ b/Roles/Neutral/Totocalcio.cs @@ -76,7 +76,7 @@ public class Totocalcio : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncTotocalcioTargetAndTimes, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncTotocalcioTargetAndTimes, HazelExtensions.SendOption); writer.Write(playerId); writer.Write(BetTimes); writer.Write(BetPlayer); diff --git a/Roles/Neutral/WeaponMaster.cs b/Roles/Neutral/WeaponMaster.cs index 67dea16c3..cd8cc35bd 100644 --- a/Roles/Neutral/WeaponMaster.cs +++ b/Roles/Neutral/WeaponMaster.cs @@ -81,7 +81,7 @@ public class WeaponMaster : RoleBase { if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWeaponMasterMode, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWeaponMasterMode, HazelExtensions.SendOption); writer.Write(WMId); writer.Write(Mode); writer.Write(shieldUsed); diff --git a/Roles/Neutral/Werewolf.cs b/Roles/Neutral/Werewolf.cs index 5cdb9cbbe..899adbc2b 100644 --- a/Roles/Neutral/Werewolf.cs +++ b/Roles/Neutral/Werewolf.cs @@ -110,7 +110,7 @@ public class Werewolf : RoleBase { if (!IsEnable || !Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWwTimer, SendOption.Reliable); + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWwTimer, HazelExtensions.SendOption); writer.Write(WWId); writer.Write(RampageTime.ToString()); writer.Write(lastTime.ToString()); @@ -150,13 +150,13 @@ public class Werewolf : RoleBase { lastTime = -10; bool unshift = UseUnshiftTrigger.GetBool() && UseUnshiftTriggerForNKs.GetBool(); - + if (!player.IsModClient()) { player.Notify(GetString(unshift ? "WWCanRampageUnshift" : "WWCanRampage")); player.RpcChangeRoleBasis(unshift ? CustomRoles.Werewolf : CustomRoles.EngineerEHR); } - + SendRPC(); CD = 0; }