public static void Postfix(Il2CppReferenceArray <PlayerInfo> BHNEINNHPIJ) { Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix start"); InitMetamorphs(); List <byte> infectedIds = new List <byte>(); List <PlayerControl> infected = GetInfected(BHNEINNHPIJ, ref infectedIds); foreach (PlayerControl playerControl in infected) { Metamorph metamorph = new Metamorph(playerControl); Metamorphs.Add(metamorph); Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix: {metamorph.PlayerId} added"); if (playerControl.PlayerId == PlayerControl.LocalPlayer.PlayerId) { Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix: Metamorph is a local player {metamorph.PlayerId}"); Metamorph.LocalMetamorph = metamorph; if (HudManagerPatch.MorphButton != null) { HudManagerPatch.MorphButton.StartCooldown(CustomGameOptions.MorphCooldown + 9.0f); HudManagerPatch.MorphButton.EffectDuration = CustomGameOptions.MorphDuration; HudManagerPatch.MorphButton.CooldownDuration = CustomGameOptions.MorphCooldown; } } } MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMetamorphs, Hazel.SendOption.Reliable); writer.WriteBytesAndSize(infectedIds.ToArray()); writer.EndMessage(); Metamorphosis.Logger.LogDebug("RcpSetInfected postfix"); }
public static void Postfix(MeetingHud __instance) { if (PlayerControlPatch.Metamorphs != null) { PlayerControl localPlayer = PlayerControl.LocalPlayer; Metamorph outMetamorph = null; if (PlayerControlPatch.IsMetamorph(localPlayer.PlayerId, out outMetamorph)) { HudManagerPatch.MorphButton.StartCooldown(HudManagerPatch.MorphButton.CooldownDuration + 8.0f); } } }
public static bool IsMetamorph(byte playerId, out Metamorph outMetamorph) { outMetamorph = null; if (Metamorphs != null) { foreach (Metamorph metamorph in Metamorphs) { if (metamorph.PlayerId == playerId) { outMetamorph = metamorph; return(true); } } } return(false); }
public void FixedUpdate() { if (PlayerControl.AllPlayerControls.Count > 1) { if (isAlive()) { if (playerControl.POECPOEKKNO) { PlayerControl closestPlayer = FindClosestTarget(PlayerControl.LocalPlayer); Metamorph outMetamorph = null; if (closestPlayer != null && !PlayerControlPatch.IsMetamorph(closestPlayer.PlayerId, out outMetamorph)) { lastPlayerContact = closestPlayer; } } } } }
public static void Postfix(byte ACCJCEHMKLN, MessageReader HFPCBBHJIPJ) { switch (ACCJCEHMKLN) { case (byte)CustomRPC.SetMetamorphs: { InitMetamorphs(); byte[] infections = HFPCBBHJIPJ.ReadBytesAndSize(); Metamorphosis.Logger.LogMessage(String.Format($"HandleRpc SetMetamorphs Length: {infections.Length}")); foreach (byte infectedId in infections) { PlayerControl infectedControl = GetPlayerControlById(infectedId); if (infectedControl != null) { Metamorph metamorph = new Metamorph(infectedControl); Metamorphs.Add(metamorph); Metamorphosis.Logger.LogDebug(String.Format($"HandleRpc SetMetamorphs Add Metamorph: {metamorph.PlayerId}")); if (metamorph.PlayerId == PlayerControl.LocalPlayer.PlayerId) { Metamorphosis.Logger.LogDebug(String.Format($"HandleRpc SetMetamorphs is local player {metamorph.PlayerId}")); Metamorph.LocalMetamorph = metamorph; if (HudManagerPatch.MorphButton != null) { HudManagerPatch.MorphButton.StartCooldown(CustomGameOptions.MorphCooldown + 9.0f); HudManagerPatch.MorphButton.EffectDuration = CustomGameOptions.MorphDuration; HudManagerPatch.MorphButton.CooldownDuration = CustomGameOptions.MorphCooldown; } } } } break; } case (byte)CustomRPC.SetMorph: { Metamorphosis.Logger.LogDebug("HandleRpc SetMorph"); byte playerId = HFPCBBHJIPJ.ReadByte(); string name = HFPCBBHJIPJ.ReadString(); byte colorId = HFPCBBHJIPJ.ReadByte(); uint skinId = HFPCBBHJIPJ.ReadUInt32(); uint hatId = HFPCBBHJIPJ.ReadUInt32(); uint petId = HFPCBBHJIPJ.ReadUInt32(); MorphInfo target = new MorphInfo(playerId, name, colorId, skinId, hatId, petId); Metamorph metamorph; if (IsMetamorph(playerId, out metamorph)) { bool updateName = !IsMetamorph(PlayerControl.LocalPlayer.PlayerId); metamorph.MorphTo(target, updateName); } else { Metamorphosis.Logger.LogError("HandleRpc SetMorph: Player is not a Metamorph"); } break; } case (byte)RPC.StartMeeting: { Metamorphosis.Logger.LogDebug("HandleRpc StartMeeting"); if (PlayerControlPatch.Metamorphs != null) { foreach (Metamorph metamorph in PlayerControlPatch.Metamorphs) { metamorph.MorphBack(); } } break; } case (byte)CustomRPC.SyncCustomSettings: { CustomGameOptions.MorphDuration = System.BitConverter.ToSingle(HFPCBBHJIPJ.ReadBytes(4), 0); CustomGameOptions.MorphCooldown = System.BitConverter.ToSingle(HFPCBBHJIPJ.ReadBytes(4), 0); break; } } }