Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RandomZombies v0.2.1
synaxin.zombiesrandom.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalNetworkAPI; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using Zombies.Scripts; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("synaxin.zombiesrandom")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1")] [assembly: AssemblyProduct("synaxin.zombiesrandom")] [assembly: AssemblyTitle("synaxin.zombiesrandom")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Zombies { internal class ConfigHandler { public readonly ConfigEntry<int> tryForTicks; public readonly ConfigEntry<float> infectionChance; public readonly ConfigEntry<int> proximityChance; public readonly ConfigEntry<int> infectionTimeMin; public readonly ConfigEntry<int> infectionTimeMax; public readonly ConfigEntry<bool> zombiesDropBodies; public readonly ConfigEntry<bool> droppedBodiesInfection; public ConfigHandler(ConfigFile cfg) { tryForTicks = cfg.Bind<int>("General", "InfectionTickAmount", 60, "Amount of ticks to try for infection\nA tick is ~= 2s"); infectionChance = cfg.Bind<float>("General", "InfectionChance", 0.8f, "% Chance per tick of infecting a body"); proximityChance = cfg.Bind<int>("General", "ProximityChance", 25, "% Chance for zombie to be proximity trigger"); infectionTimeMin = cfg.Bind<int>("General", "InfectionTimeMin", 30, "Minimum ticks before infection is complete\nA tick is ~= 2s"); infectionTimeMax = cfg.Bind<int>("General", "InfectionTimeMax", 90, "Maximum ticks before infection is complete\nA tick is ~= 2s"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } [BepInPlugin("synaxin.zombiesrandom", "synaxin.zombiesrandom", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Zombies : BaseUnityPlugin { public static List<EnemyType> indoorEnemies = new List<EnemyType>(); public static List<EnemyType> outdoorEnemies = new List<EnemyType>(); public static Zombies Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } internal static ConfigHandler BoundConfig { get; private set; } = null; internal static PlayerControllerB Player { get; set; } internal static ZombieNetworkManager Networking { get; set; } internal static InfectionHandler Infection { get; set; } public static BodySpawnHandler BodySpawn { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; BoundConfig = new ConfigHandler(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)"Random Zombies v0.2.1 has loaded!"); } public static bool GetConverted(PlayerControllerB player) { bool flag = BodySpawn.ContainsPlayer(player); Logger.LogDebug((object)$"Got Converted, {flag}, {BodySpawn.convertedList.Count}"); return BodySpawn.ContainsPlayer(player); } public static void TryRemoveConverted(PlayerControllerB player) { BodySpawn.RemovePlayer(player); } public static void ClearConverted() { BodySpawn.ResetList(); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("synaxin.zombiesrandom"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "synaxin.zombiesrandom"; public const string PLUGIN_NAME = "synaxin.zombiesrandom"; public const string PLUGIN_VERSION = "0.2.1"; } } namespace Zombies.Scripts { public class BodySpawnHandler { public List<PlayerControllerB> convertedList = new List<PlayerControllerB>(); public void AddBody(PlayerControllerB player) { Zombies.Logger.LogMessage((object)"Addbody fired!"); if (!convertedList.Contains(player)) { Zombies.Logger.LogMessage((object)"Body added to list!"); convertedList.Add(player); } } public bool ContainsPlayer(PlayerControllerB player) { return convertedList.Contains(player); } public void RemovePlayer(PlayerControllerB player) { if (convertedList.Contains(player)) { convertedList.Remove(player); } } public void ResetList() { convertedList.Clear(); } } internal class InfectionHandler { private static int deadTicks = Mathf.Abs(Zombies.BoundConfig.tryForTicks.Value); private static float infectionChance = Mathf.Abs(Zombies.BoundConfig.infectionChance.Value); private static int infectionMinTicks = Mathf.Abs(Zombies.BoundConfig.infectionTimeMin.Value); private static int infectionMaxTicks = Mathf.Abs(Zombies.BoundConfig.infectionTimeMax.Value); private static int proxChance = Mathf.Abs(Zombies.BoundConfig.proximityChance.Value); private static float timeForTick = 2f; private static float currentTickTime = 0f; private static float timeForProxTick = 0.1f; private static float currentProxTickTime = 0f; private static bool tickProximity = false; private static float proxDistance = 5f; private static int wakeTicks = 10; private static float timeForWakeTick = 0.2f; private static float currentWakeTickTime = 0f; private static bool tickWake = false; private static Dictionary<PlayerControllerB, InfectionInfo> deadList = new Dictionary<PlayerControllerB, InfectionInfo>(); private static Dictionary<NetworkObjectReference, PlayerControllerB> bodyList = new Dictionary<NetworkObjectReference, PlayerControllerB>(); public void ClearInfected() { deadList.Clear(); bodyList.Clear(); } public void AddDeadBody(ulong playerID) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.playerClientId != playerID) { continue; } Zombies.Logger.LogMessage((object)$"Adding Player {val.playerClientId} to deadlist"); bool flag = true; foreach (var (val4, val5) in bodyList) { if ((Object)(object)val == (Object)(object)val5) { flag = false; Zombies.Logger.LogMessage((object)"Cancelling Add"); } } if (flag && !deadList.ContainsKey(val)) { deadList.Add(val, new InfectionInfo(val, deadTicks, infectionChance, infectionMinTicks, infectionMaxTicks, proxChance, wakeTicks)); } } } public void AddZombie(NetworkObjectReference enemy, PlayerControllerB player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !bodyList.ContainsKey(enemy)) { Zombies.Logger.LogDebug((object)"Added Player to Zombie List"); if (deadList.ContainsKey(player)) { deadList.Remove(player); } bodyList.Add(enemy, player); } } public void ReplaceDeadBody(NetworkObject target) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) List<NetworkObjectReference> list = new List<NetworkObjectReference>(); NetworkObject val5 = default(NetworkObject); foreach (KeyValuePair<NetworkObjectReference, PlayerControllerB> body in bodyList) { var (val3, val4) = (KeyValuePair<NetworkObjectReference, PlayerControllerB>)(ref body); if (((NetworkObjectReference)(ref val3)).TryGet(ref val5, (NetworkManager)null) && (Object)(object)val5 == (Object)(object)target) { Vector3[] position = (Vector3[])(object)new Vector3[1] { ((Component)target).transform.position }; Zombies.Networking.SendZombieDeadMessage(new ZombieDeadInfo(val4.playerClientId, position, val3)); list.Add(val3); } } foreach (NetworkObjectReference item in list) { if (bodyList.ContainsKey(item)) { Zombies.Logger.LogDebug((object)"Removing Reference"); PlayerControllerB val6 = bodyList[item]; bodyList.Remove(item); AddDeadBody(val6.playerClientId); } } } public void TickThroughBodies() { if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer) { return; } if (deadList.Count > 0) { TickInfection(); if (tickProximity) { ProximityCheck(); } if (tickWake) { WakeTick(); } } else { currentTickTime = 0f; } } private void TickInfection() { bool flag = false; bool flag2 = false; currentTickTime += Time.deltaTime; if (!(currentTickTime >= timeForTick)) { return; } List<PlayerControllerB> list = new List<PlayerControllerB>(); currentTickTime = 0f; foreach (var (val2, infectionInfo2) in deadList) { if (infectionInfo2.GetState() < 0 || (Object)(object)val2.deadBody == (Object)null || val2.deadBody.deactivated) { list.Add(val2); continue; } Zombies.Networking.SendSyncMessageServer(val2.playerClientId, val2); int num = infectionInfo2.Tick(); Zombies.Logger.LogDebug((object)$"Body {val2} Ticked! State: {num}"); switch (num) { case 2: Zombies.Networking.SendBloodMessage(val2.playerClientId); Zombies.Logger.LogDebug((object)$"Ticking Infection! ID{val2.playerClientId}"); break; case 3: Zombies.Logger.LogDebug((object)$"Infection Complete! ID{val2.playerClientId}"); infectionInfo2.SetTarget(val2); infectionInfo2.WakeUp(); break; case 4: Zombies.Logger.LogDebug((object)"Infection Complete! Proximity ID{body.playerClientId}"); flag = true; break; case 5: flag2 = true; break; } } foreach (PlayerControllerB item in list) { deadList[item].Finish(); deadList.Remove(item); } tickProximity = flag; tickWake = flag2; } private void ProximityCheck() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) currentProxTickTime += Time.deltaTime; if (!(currentProxTickTime >= timeForProxTick)) { return; } Zombies.Logger.LogDebug((object)"Ticking Proximity!"); currentProxTickTime = 0f; foreach (var (val2, infectionInfo2) in deadList) { if (infectionInfo2.GetState() != 4) { continue; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (val3.isPlayerControlled && !val3.isPlayerDead && (Object)(object)((Component)val3).gameObject != (Object)(object)((Component)val2).gameObject && (Object)(object)val2.deadBody != (Object)null) { float num = Vector3.Distance(((Component)val2.deadBody).gameObject.transform.position, ((Component)val3).gameObject.transform.position); if (num <= proxDistance) { Zombies.Logger.LogDebug((object)"Found Target!"); infectionInfo2.SetTarget(val3); infectionInfo2.WakeUp(); tickWake = true; } } } } } private void WakeTick() { currentWakeTickTime += Time.deltaTime; if (!(currentWakeTickTime >= timeForWakeTick)) { return; } Zombies.Logger.LogDebug((object)"Ticking Wake!"); currentWakeTickTime = 0f; List<PlayerControllerB> list = new List<PlayerControllerB>(); foreach (var (val2, infectionInfo2) in deadList) { if (infectionInfo2.GetState() == 5) { infectionInfo2.WakeTick(); Zombies.Networking.SendWakeMessage(val2.playerClientId); } if (infectionInfo2.GetState() == 6) { list.Add(val2); } } foreach (PlayerControllerB item in list) { deadList[item].Finish(); Zombies.Networking.SendMaskSpawnMessage(item, deadList[item].GetTarget().playerClientId); deadList.Remove(item); } } public Dictionary<ulong, Vector3> GetPositions() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) Dictionary<ulong, Vector3> dictionary = new Dictionary<ulong, Vector3>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled) { dictionary.Add(val.playerClientId, ((Component)val).transform.position); } } return dictionary; } } internal class BodySyncInfo { public readonly ulong bodyID; public readonly Vector3 position; public BodySyncInfo(ulong id, Vector3 position) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) bodyID = id; this.position = position; } public bool GetDifference(Vector3 newPos, float posDif) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) bool result = false; if (Vector3.Distance(position, newPos) >= posDif) { result = true; } return result; } } internal class ZombieSpawnInfo { public readonly ulong playerID; public readonly ulong targetID; public ZombieSpawnInfo(ulong playerID, ulong targetID) { this.playerID = playerID; this.targetID = targetID; } } internal class ZombieDeadInfo { public readonly ulong playerID; public readonly Vector3[] position; public readonly NetworkObjectReference enemy; private Vector3[] bodyPartPositions; public ZombieDeadInfo(ulong playerID, Vector3[] position, NetworkObjectReference enemy) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) this.playerID = playerID; this.position = position; this.enemy = enemy; } } internal class RPCStuff { } internal class InfectionInfo { private Random rand = new Random((int)Time.time); private int deadTime = 0; private readonly int deadTicks; private readonly float infectionChance; private int infectionTime = 0; private readonly int infectionTicks = 10; private bool infected = false; private PlayerControllerB targetPlayer; private readonly bool proximity = false; private bool done = false; private int state = 0; private readonly int wakeTicks = 10; private int wakeTime = 0; public InfectionInfo(PlayerControllerB player, int deadTicks, float infectionChance, int inMinTicks, int inMaxTicks, int proxChance, int wakeTicks) { targetPlayer = player; this.deadTicks = deadTicks; this.infectionChance = infectionChance; infectionTicks = inMinTicks + rand.Next(inMaxTicks - inMinTicks); proximity = rand.Next(100) < proxChance; this.wakeTicks = wakeTicks; } public int Tick() { if (state < 0 || state == 5) { return state; } if (!infected) { bool flag = RollInfection(infectionChance); deadTime++; if (flag) { state = 1; return 1; } if (deadTime >= deadTicks) { state = -1; return -1; } state = 0; return 0; } infectionTime++; if (infectionTime >= infectionTicks && state <= 4) { if (proximity) { state = 4; return 4; } state = 3; return 3; } state = 2; return 2; } public int WakeTick() { wakeTime++; if (wakeTime >= wakeTicks) { state = 6; return 6; } return 5; } public void Finish() { done = true; state = -2; } public bool GetProximity() { return proximity; } public int GetState() { return state; } public void SetTarget(PlayerControllerB target) { targetPlayer = target; } public PlayerControllerB GetTarget() { return targetPlayer; } public void WakeUp() { state = 5; } private bool RollInfection(float chance) { float num = rand.Next(1000) / 10; if (num <= chance) { infected = true; return true; } return false; } } public class ZombieNetworkManager : MonoBehaviour { private Random rand = new Random(); private readonly LNetworkMessage<ulong> deadBodyMessage; private readonly LNetworkMessage<ulong> bloodDropMessage; private readonly LNetworkMessage<BodySyncInfo> bodySyncMessage; private readonly LNetworkMessage<ulong> zombieWakeMessage; private readonly LNetworkMessage<(NetworkObjectReference, ZombieSpawnInfo)> maskSpawnMessage; private readonly LNetworkMessage<ZombieDeadInfo> zombieDeadMessage; private readonly LNetworkMessage<ZombieDeadInfo> bodySpawnOwnerMessage; private readonly LNetworkMessage<ZombieDeadInfo> bodySpawnMessage; private readonly LNetworkMessage<NetworkObjectReference> maskDespawnMessage; private Dictionary<NetworkObjectReference, List<ulong>> maskDespawnList = new Dictionary<NetworkObjectReference, List<ulong>>(); public ZombieNetworkManager() { deadBodyMessage = LNetworkMessage<ulong>.Connect("AddDeadBody", (Action<ulong, ulong>)null, (Action<ulong>)null, (Action<ulong, ulong>)null); bloodDropMessage = LNetworkMessage<ulong>.Connect("BloodDrop", (Action<ulong, ulong>)null, (Action<ulong>)null, (Action<ulong, ulong>)null); bodySyncMessage = LNetworkMessage<BodySyncInfo>.Connect("DeadBodySync", (Action<BodySyncInfo, ulong>)null, (Action<BodySyncInfo>)null, (Action<BodySyncInfo, ulong>)null); zombieWakeMessage = LNetworkMessage<ulong>.Connect("ZombieWake", (Action<ulong, ulong>)null, (Action<ulong>)null, (Action<ulong, ulong>)null); maskSpawnMessage = LNetworkMessage<(NetworkObjectReference, ZombieSpawnInfo)>.Connect("MaskSpawn", (Action<(NetworkObjectReference, ZombieSpawnInfo), ulong>)null, (Action<(NetworkObjectReference, ZombieSpawnInfo)>)null, (Action<(NetworkObjectReference, ZombieSpawnInfo), ulong>)null); zombieDeadMessage = LNetworkMessage<ZombieDeadInfo>.Connect("ZombieDead", (Action<ZombieDeadInfo, ulong>)null, (Action<ZombieDeadInfo>)null, (Action<ZombieDeadInfo, ulong>)null); bodySpawnOwnerMessage = LNetworkMessage<ZombieDeadInfo>.Connect("SpawnBodyOwner", (Action<ZombieDeadInfo, ulong>)null, (Action<ZombieDeadInfo>)null, (Action<ZombieDeadInfo, ulong>)null); bodySpawnMessage = LNetworkMessage<ZombieDeadInfo>.Connect("SpawnBody", (Action<ZombieDeadInfo, ulong>)null, (Action<ZombieDeadInfo>)null, (Action<ZombieDeadInfo, ulong>)null); maskDespawnMessage = LNetworkMessage<NetworkObjectReference>.Connect("DespawnMask", (Action<NetworkObjectReference, ulong>)null, (Action<NetworkObjectReference>)null, (Action<NetworkObjectReference, ulong>)null); deadBodyMessage.OnServerReceived += OnDeadMessageServer; bodySyncMessage.OnServerReceived += OnSyncMessageServer; bodySyncMessage.OnClientReceived += OnSyncMessageClient; bloodDropMessage.OnServerReceived += OnBloodDropServer; bloodDropMessage.OnClientReceived += OnBloodDropClient; zombieWakeMessage.OnServerReceived += OnZombieWakeServer; zombieWakeMessage.OnClientReceived += OnZombieWakeClient; maskSpawnMessage.OnServerReceived += OnMaskSpawnServer; maskSpawnMessage.OnClientReceived += OnMaskSpawnClient; zombieDeadMessage.OnServerReceived += OnZombieDeadServer; zombieDeadMessage.OnClientReceived += OnZombieDeadClient; maskDespawnMessage.OnServerReceived += OnDespawnServer; } internal void SendDeadMessage(ulong id) { Zombies.Logger.LogMessage((object)$"Sent Dead Message from {id}"); deadBodyMessage.SendServer(id); } private void OnDeadMessageServer(ulong id, ulong id2) { Zombies.Logger.LogMessage((object)$"Received Dead Message from {id}, {id2}"); if (id == id2) { Zombies.Infection.AddDeadBody(id); } } internal void SendSyncMessageServer(ulong id, PlayerControllerB body) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)body.deadBody).gameObject; if (!((Object)(object)gameObject == (Object)null)) { BodySyncInfo bodySyncInfo = new BodySyncInfo(id, gameObject.transform.position); bodySyncMessage.SendServer(bodySyncInfo); } } internal void OnSyncMessageServer(BodySyncInfo info, ulong id) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(info.bodyID); if (!((Object)(object)playerController == (Object)null)) { GameObject gameObject = ((Component)playerController.deadBody).gameObject; if (!((Object)(object)gameObject == (Object)null)) { BodySyncInfo bodySyncInfo = new BodySyncInfo(info.bodyID, gameObject.transform.position); bodySyncMessage.SendClients(bodySyncInfo); } } } internal void OnSyncMessageClient(BodySyncInfo info) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(info.bodyID); if ((Object)(object)playerController == (Object)null) { return; } DeadBodyInfo deadBody = playerController.deadBody; if (!((Object)(object)deadBody == (Object)null)) { GameObject gameObject = ((Component)playerController.deadBody).gameObject; if (info.GetDifference(gameObject.transform.position, 2f)) { Zombies.Logger.LogDebug((object)$"Perfoming Body Sync On {info.bodyID}"); gameObject.transform.position = info.position; } } } internal void SendBloodMessage(ulong playerID) { Zombies.Logger.LogDebug((object)"SendBloodMessage"); bloodDropMessage.SendServer(playerID); } private void OnBloodDropServer(ulong playerID, ulong id) { Zombies.Logger.LogDebug((object)"OnBloodMessageServer"); bloodDropMessage.SendClients(playerID); } private void OnBloodDropClient(ulong playerID) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogDebug((object)"OnBloodMessageClient"); PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(playerID); if (!((Object)(object)playerController == (Object)null)) { playerController.bloodDropTimer = -1f; playerController.DropBlood(Vector3.down, true, false); } } internal void SendWakeMessage(ulong playerID) { Zombies.Logger.LogDebug((object)"SendWakeMessage"); zombieWakeMessage.SendServer(playerID); } private void OnZombieWakeServer(ulong playerID, ulong id) { Zombies.Logger.LogDebug((object)"OnZombieWakeServer"); zombieWakeMessage.SendClients(playerID); } private void OnZombieWakeClient(ulong playerID) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogDebug((object)"OnZombieWakeClient"); PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(playerID); if ((Object)(object)playerController == (Object)null) { return; } playerController.bloodDropTimer = -1f; playerController.AddBloodToBody(); playerController.DropBlood(Vector3.down, true, false); playerController.DropBlood(new Vector3(0.7f, -0f, 0.7f), true, false); playerController.DropBlood(new Vector3(-0.7f, -0f, 0.7f), true, false); playerController.DropBlood(new Vector3(0.7f, -0f, -0.7f), true, false); playerController.DropBlood(new Vector3(-0.7f, -0f, -0.7f), true, false); if ((Object)(object)playerController.deadBody != (Object)null) { for (int i = 0; i < playerController.deadBody.bodyParts.Length; i++) { playerController.deadBody.bodyParts[i].drag = 0f; playerController.deadBody.bodyParts[i].AddForce(new Vector3(0f, 5000f, 0f), (ForceMode)0); } } } internal void SendMaskSpawnMessage(PlayerControllerB player, ulong target) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { Zombies.Logger.LogMessage((object)$"Sent Mask {player}"); maskSpawnMessage.SendServer((default(NetworkObjectReference), new ZombieSpawnInfo(player.playerClientId, target))); } } private void OnMaskSpawnServer((NetworkObjectReference, ZombieSpawnInfo) info, ulong playerID) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(info.Item2.playerID); if ((Object)(object)playerController == (Object)null || (Object)(object)playerController.deadBody == (Object)null) { return; } Vector3 position = ((Component)playerController.deadBody).transform.position; EnemyType val = ((!playerController.isInsideFactory) ? Zombies.outdoorEnemies[rand.Next(0, Zombies.outdoorEnemies.Count)] : Zombies.indoorEnemies[rand.Next(0, Zombies.indoorEnemies.Count)]); NetworkObjectReference val2 = RoundManager.Instance.SpawnEnemyGameObject(position, 0f, -1, val); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null)) { Zombies.Infection.AddZombie(val2, playerController); Debug.Log((object)"Got network object for mask enemy"); MaskedPlayerEnemy val4 = default(MaskedPlayerEnemy); if (((Component)val3).TryGetComponent<MaskedPlayerEnemy>(ref val4)) { val4.SetSuit(playerController.currentSuitID); val4.mimickingPlayer = playerController; ((EnemyAI)val4).SetEnemyOutside(!playerController.isInsideFactory); val4.SetVisibilityOfMaskedEnemy(); val4.SetMaskType(5); playerController.redirectToEnemy = (EnemyAI)(object)val4; } if ((Object)(object)playerController.deadBody != (Object)null) { playerController.deadBody.DeactivateBody(false); } } Zombies.Logger.LogMessage((object)$"Received Mask Server {info.Item2}"); maskSpawnMessage.SendClients((val2, new ZombieSpawnInfo(info.Item2.playerID, 0uL))); } private void OnMaskSpawnClient((NetworkObjectReference, ZombieSpawnInfo) info) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogMessage((object)$"Received Client, {info.Item1}"); ((MonoBehaviour)this).StartCoroutine(waitForMimicEnemySpawn(info.Item1, info.Item2.playerID)); } private IEnumerator waitForMimicEnemySpawn(NetworkObjectReference netObjectRef, ulong id) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) NetworkObject netObject = null; PlayerControllerB player = LethalNetworkExtensions.GetPlayerController(id); if ((Object)(object)player == (Object)null) { yield break; } Zombies.Logger.LogMessage((object)LethalNetworkExtensions.GetPlayerController(id)); float startTime = Time.realtimeSinceStartup; yield return (object)new WaitUntil((Func<bool>)(() => (double)Time.realtimeSinceStartup - (double)startTime > 20.0 || ((NetworkObjectReference)(ref netObjectRef)).TryGet(ref netObject, (NetworkManager)null))); if ((Object)(object)LethalNetworkExtensions.GetPlayerController(id).deadBody == (Object)null) { startTime = Time.realtimeSinceStartup; yield return (object)new WaitUntil((Func<bool>)(() => (double)Time.realtimeSinceStartup - (double)startTime > 20.0 || (Object)(object)LethalNetworkExtensions.GetPlayerController(id).deadBody != (Object)null)); } if (!((Object)(object)LethalNetworkExtensions.GetPlayerController(id).deadBody == (Object)null) && (Object)(object)netObject != (Object)null) { LethalNetworkExtensions.GetPlayerController(id).deadBody.DeactivateBody(false); MaskedPlayerEnemy component = default(MaskedPlayerEnemy); if (((Component)netObject).TryGetComponent<MaskedPlayerEnemy>(ref component)) { component.mimickingPlayer = LethalNetworkExtensions.GetPlayerController(id); component.SetSuit(LethalNetworkExtensions.GetPlayerController(id).currentSuitID); ((EnemyAI)component).SetEnemyOutside(!LethalNetworkExtensions.GetPlayerController(id).isInsideFactory); component.SetVisibilityOfMaskedEnemy(); component.SetMaskType(5); LethalNetworkExtensions.GetPlayerController(id).redirectToEnemy = (EnemyAI)(object)component; } } } internal void SendZombieDeadMessage(ZombieDeadInfo info) { Zombies.Logger.LogDebug((object)"SendZombieDeadMessage"); zombieDeadMessage.SendServer(info); } private void OnZombieDeadServer(ZombieDeadInfo info, ulong id) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogDebug((object)"OnZombieDeadServer"); PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(info.playerID); if (!((Object)(object)playerController != (Object)null)) { return; } Zombies.Logger.LogDebug((object)"OnZombieDeadServer2"); bodySpawnOwnerMessage.SendClient(info, info.playerID); NetworkObjectReference enemy = info.enemy; NetworkObject val = default(NetworkObject); if (((NetworkObjectReference)(ref enemy)).TryGet(ref val, (NetworkManager)null)) { Transform[] array = (Transform[])(object)new Transform[1] { ((Component)val).transform }; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = array[i].position; } ZombieDeadInfo zombieDeadInfo = new ZombieDeadInfo(info.playerID, array2, info.enemy); zombieDeadMessage.SendClients(zombieDeadInfo); } enemy = info.enemy; if (!((NetworkObjectReference)(ref enemy)).TryGet(ref val, (NetworkManager)null)) { } } private void OnZombieDeadClient(ZombieDeadInfo info) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogDebug((object)"OnZombieDeadClient"); PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(info.playerID); if ((Object)(object)playerController == (Object)null) { return; } NetworkObjectReference enemy = info.enemy; NetworkObject val = default(NetworkObject); if (((NetworkObjectReference)(ref enemy)).TryGet(ref val, (NetworkManager)null)) { Zombies.Logger.LogDebug((object)"OnZombieDeadClient2"); Zombies.Logger.LogDebug((object)"OnZombieDeadClient3"); Zombies.Logger.LogDebug((object)$"{info.position},"); Zombies.Logger.LogDebug((object)"OnZombieDeadClient4"); playerController.deadBody.overrideSpawnPosition = true; ((Component)playerController.deadBody).gameObject.SetActive(true); playerController.deadBody.SetBodyPartsKinematic(false); playerController.deadBody.bodyParts[6].position = info.position[0]; playerController.deadBody.bodyParts[6].velocity = Vector3.zero; playerController.deadBody.seenByLocalPlayer = false; Zombies.Logger.LogDebug((object)"OnZombieDeadClient6"); Zombies.Logger.LogDebug((object)"OnZombieDeadClient7"); playerController.deadBody.deactivated = false; Zombies.Logger.LogDebug((object)"OnZombieDeadClient8"); playerController.redirectToEnemy = null; Zombies.Logger.LogDebug((object)"OnZombieDeadClient9"); if ((Object)(object)val != (Object)null) { Zombies.Logger.LogDebug((object)"OnZombieDeadClient10"); ((Component)val).gameObject.SetActive(false); maskDespawnMessage.SendServer(info.enemy); } Zombies.Logger.LogDebug((object)"OnZombieDeadClient11"); if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { Zombies.Infection.AddDeadBody(playerController.playerClientId); } } } private void OnDespawnServer(NetworkObjectReference enemy, ulong id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (maskDespawnList.ContainsKey(enemy)) { maskDespawnList[enemy].Add(id); } else { maskDespawnList.Add(enemy, new List<ulong>()); maskDespawnList[enemy].Add(id); } if (maskDespawnList[enemy].Count >= StartOfRound.Instance.ClientPlayerList.Count) { NetworkObject val = default(NetworkObject); if (((NetworkObjectReference)(ref enemy)).TryGet(ref val, (NetworkManager)null)) { val.Despawn(true); } maskDespawnList.Remove(enemy); } } } } namespace Zombies.Patches { [HarmonyPatch(typeof(DeadBodyInfo))] internal class DeadBodyInfoPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPatch(DeadBodyInfo __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Zombies.Logger.LogDebug((object)$"DeadBodyStartPost {((Component)__instance).gameObject.transform.position}"); for (int i = 0; i < __instance.playerScript.bodyParts.Length; i++) { Zombies.Logger.LogDebug((object)$"Bodypart {((Object)__instance.bodyParts[i]).name} Position {__instance.bodyParts[i].position}"); } } } [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { [HarmonyPatch("KillEnemy")] [HarmonyPrefix] public static void KillEnemyPatch(EnemyAI __instance) { if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsHost) { Zombies.Infection.ReplaceDeadBody(((NetworkBehaviour)__instance).NetworkObject); } } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { [HarmonyPatch("StartHost")] [HarmonyPostfix] public static void StartHostPost() { Zombies.Logger.LogDebug((object)"New Infection Handler Made!"); Zombies.Infection = new InfectionHandler(); } [HarmonyPatch("StartDisconnect")] [HarmonyPostfix] public static void StartDisconnectPost() { if (Zombies.Infection != null) { Zombies.Infection = null; } } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] internal class MaskedPlayerEnemyPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(MaskedPlayerEnemy __instance) { ((EnemyAI)__instance).timeSinceSpawn = 4f; ((EnemyAI)__instance).creatureAnimator.SetTrigger("HitEnemy"); ((EnemyAI)__instance).SwitchToBehaviourState(0); } [HarmonyPatch("KillPlayerAnimationClientRpc")] [HarmonyPostfix] private static void KillPlayerClientPatch(MaskedPlayerEnemy __instance) { Zombies.Logger.LogMessage((object)"Added Body to list!"); Zombies.BodySpawn.AddBody(((EnemyAI)__instance).inSpecialAnimationWithPlayer); } [HarmonyPatch("CreateMimicClientRpc")] [HarmonyPrefix] private static void CreateMimicPatch(NetworkObjectReference netObjectRef, bool inFactory, int playerKilled) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { Zombies.Logger.LogDebug((object)$"Dead From Masked {netObjectRef}, {inFactory}, {playerKilled}"); Zombies.Infection.AddZombie(netObjectRef, StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[(ulong)playerKilled]]); } } } [HarmonyPatch(typeof(HauntedMaskItem))] internal class HauntedMaskItemPatch { [HarmonyPatch("CreateMimicClientRpc")] [HarmonyPrefix] private static void CreateMimicPatch(NetworkObjectReference netObjectRef, bool inFactory, HauntedMaskItem __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { Zombies.Logger.LogDebug((object)$"Dead From HauntedMask {netObjectRef}, {inFactory}, {__instance.previousPlayerHeldBy.playerClientId}"); Zombies.Infection.AddZombie(netObjectRef, StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[__instance.previousPlayerHeldBy.playerClientId]]); } } [HarmonyPatch("FinishAttaching")] [HarmonyPrefix] private static void AttachPatch(HauntedMaskItem __instance) { if (((NetworkBehaviour)__instance).IsOwner && !__instance.finishedAttaching && __instance.previousPlayerHeldBy.AllowPlayerDeath()) { Zombies.Logger.LogMessage((object)"Added Body to list!"); Zombies.BodySpawn.AddBody(StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[__instance.previousPlayerHeldBy.playerClientId]]); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerBPatch { [HarmonyPatch(typeof(PlayerControllerB))] internal static class PreloadPatches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] private static void ConnectClientToPlayerObjectPatch(PlayerControllerB __instance) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance)) { Zombies.Player = GameNetworkManager.Instance.localPlayerController; Zombies.Logger.LogDebug((object)"NetworkHandlerAdded!"); Zombies.Networking = ((Component)__instance).gameObject.AddComponent<ZombieNetworkManager>(); } } } [HarmonyPatch("KillPlayer")] [HarmonyPostfix] public static void KillPlayerPostfix(PlayerControllerB __instance, bool spawnBody) { Zombies.Logger.LogDebug((object)$"SpawnBody {spawnBody}"); if (spawnBody) { Zombies.Networking.SendDeadMessage(__instance.playerClientId); } } [HarmonyPatch("SpawnDeadBody")] [HarmonyPostfix] public static void SpawnDeadBodyPatch(PlayerControllerB __instance) { if (Zombies.GetConverted(__instance)) { __instance.deadBody.DeactivateBody(false); } Zombies.Logger.LogDebug((object)"Dead Body Spawned"); } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPatch("KillPlayer")] public static class PlayerControllerB_KillPlayer_Patch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase method) { Zombies.Logger.LogDebug((object)"Transpiler fired"); List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> collection = BuildInstructionsToInsert(method, generator); Zombies.Logger.LogDebug((object)list.Count); list.InsertRange(0, collection); return list.AsEnumerable(); } private static List<CodeInstruction>? BuildInstructionsToInsert(MethodBase method, ILGenerator ilGen) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown Zombies.Logger.LogDebug((object)"CodeInstructions constructing"); List<CodeInstruction> list = new List<CodeInstruction>(); int num = 0; int num2 = 2; int num3 = 4; Label label = ilGen.DefineLabel(); list.Add(new CodeInstruction(OpCodes.Ldarg, (object)num)); list.Add(new CodeInstruction(OpCodes.Call, (object)typeof(Zombies).GetMethod("GetConverted"))); list.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label)); list.Add(new CodeInstruction(OpCodes.Ldarg, (object)num)); list.Add(new CodeInstruction(OpCodes.Call, (object)typeof(Zombies).GetMethod("GetConverted"))); list.Add(new CodeInstruction(OpCodes.Starg_S, (object)num2)); list.Add(new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Starg_S, (object)num3)); list.Add(new CodeInstruction(OpCodes.Nop, (object)null)); list[8].labels.Add(label); Zombies.Logger.LogDebug((object)"CodeInstructions Constructed"); return list; } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Update")] [HarmonyPostfix] public static void UpdatePost() { if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && Zombies.Infection != null) { Zombies.Infection.TickThroughBodies(); } } [HarmonyPatch("ShipHasLeft")] [HarmonyPrefix] public static void ShipHasLeftPatch() { if (Zombies.Infection != null) { Zombies.Infection.ClearInfected(); } Zombies.ClearConverted(); } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void GetMaskPrefab(ref SelectableLevel[] ___moonsCatalogueList) { Zombies.BodySpawn = new BodySpawnHandler(); foreach (EnemyType item in Resources.FindObjectsOfTypeAll<EnemyType>().Distinct()) { if (!(((Object)item).name == "BushWolf") && !(((Object)item).name == "LassoMan")) { Zombies.Logger.LogMessage((object)$"{((Object)item).name}, Is outside {item.isOutsideEnemy}"); if (item.isOutsideEnemy) { Zombies.outdoorEnemies.Add(item); } else { Zombies.indoorEnemies.Add(item); } } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }