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 LethalEasterEggs v0.1.0
LethalEasterEggs.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalEasterEggs.NetcodePatcher; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [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 = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalEasterEggs")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A lethal company mod")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("LethalEasterEggs")] [assembly: AssemblyTitle("LethalEasterEggs")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalEasterEggs { public class NetcodeHelper : NetworkBehaviour { public static NetcodeHelper Instance; private PlayerControllerB _localPlayer; public NetcodeHelper() { Instance = this; } [ServerRpc(RequireOwnership = false)] public void SpawnObjectServerRpc(ulong clientId, Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(463357336u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clientId); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 463357336u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { HashSet<string> hashSet = (_localPlayer.isInsideFactory ? SpawnableObjects.IndoorSpawns : SpawnableObjects.OutdoorSpawns); string key = hashSet.ElementAt(Random.RandomRangeInt(0, hashSet.Count)); GameObject val3 = Object.Instantiate<GameObject>(SpawnableObjects.AllObjects[key], position, Quaternion.identity); val3.GetComponent<NetworkObject>().Spawn(false); } } } public void Initialize() { _localPlayer = StartOfRound.Instance.localPlayerController; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_NetcodeHelper() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(463357336u, new RpcReceiveHandler(__rpc_handler_463357336)); } private static void __rpc_handler_463357336(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong clientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref clientId); Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); target.__rpc_exec_stage = (__RpcExecStage)1; ((NetcodeHelper)(object)target).SpawnObjectServerRpc(clientId, position); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "NetcodeHelper"; } } [BepInPlugin("LethalEasterEggs", "LethalEasterEggs", "0.1.0")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static GameObject NetcodeHelperPrefab; public static ManualLogSource Console; private Harmony _harmony; private void Awake() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethaleastereggs")); NetcodeHelperPrefab = val.LoadAsset<GameObject>("Assets/LethalEasterEgg/NetcodeHelper.prefab"); NetcodeHelperPrefab.AddComponent<NetcodeHelper>(); Instance = this; Console = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("LethalEasterEggs"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalEasterEggs is loaded!"); } public static void DisplayHUDTip(string header, string body, bool isWarning = false) { if ((Object)(object)HUDManager.Instance == (Object)null) { Console.LogWarning((object)("Failed to display HUD tip: " + header + " - " + body)); } else { HUDManager.Instance.DisplayTip(header, body, isWarning, false, "LC_Tip1"); } } } public static class SpawnableObjects { public static readonly Dictionary<string, GameObject> AllObjects = new Dictionary<string, GameObject> { { "Centipede", null }, { "Bunker Spider", null }, { "Hoarding bug", null }, { "Flowerman", null }, { "Crawler", null }, { "Blob", null }, { "Puffer", null }, { "Nutcracker", null }, { "MouthDog", null }, { "ForestGiant", null }, { "RadMech", null }, { "Baboon hawk", null }, { "Spring", null }, { "Jester", null }, { "Masked", null }, { "Butler", null }, { "Landmine", null }, { "TurretContainer", null }, { "SpikeRoofTrapHazard", null } }; public static HashSet<string> IndoorSpawns = new HashSet<string> { "Centipede", "Bunker Spider", "Hoarding bug", "Flowerman", "Crawler", "Blob", "Puffer", "Nutcracker", "Spring", "Jester", "Masked", "Landmine", "TurretContainer", "SpikeRoofTrapHazard" }; public static HashSet<string> OutdoorSpawns = new HashSet<string> { "MouthDog", "ForestGiant", "RadMech", "Baboon hawk", "Masked", "Landmine", "TurretContainer", "SpikeRoofTrapHazard" }; public static void LoadSpawnableObjects() { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { foreach (SpawnableEnemyWithRarity enemy in val.Enemies) { if (AllObjects.ContainsKey(enemy.enemyType.enemyName)) { AllObjects[enemy.enemyType.enemyName] = enemy.enemyType.enemyPrefab; } } foreach (SpawnableEnemyWithRarity outsideEnemy in val.OutsideEnemies) { if (AllObjects.ContainsKey(outsideEnemy.enemyType.enemyName)) { AllObjects[outsideEnemy.enemyType.enemyName] = outsideEnemy.enemyType.enemyPrefab; } } foreach (SpawnableEnemyWithRarity daytimeEnemy in val.DaytimeEnemies) { if (AllObjects.ContainsKey(daytimeEnemy.enemyType.enemyName)) { AllObjects[daytimeEnemy.enemyType.enemyName] = daytimeEnemy.enemyType.enemyPrefab; } } SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects; foreach (SpawnableMapObject val2 in spawnableMapObjects) { if (AllObjects.ContainsKey(((Object)val2.prefabToSpawn).name)) { AllObjects[((Object)val2.prefabToSpawn).name] = val2.prefabToSpawn; } } } foreach (string key in AllObjects.Keys) { if ((Object)(object)AllObjects[key] == (Object)null) { IndoorSpawns.Remove(key); OutdoorSpawns.Remove(key); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalEasterEggs"; public const string PLUGIN_NAME = "LethalEasterEggs"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace LethalEasterEggs.Patches { public class GameNetworkManagerPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void AddNetcodeHelperPrefab(ref GameNetworkManager __instance) { ((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.NetcodeHelperPrefab); } } [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatch { [HarmonyPostfix] [HarmonyPatch("ConnectClientToPlayerObject")] private static void LoadPrefabs(ref PlayerControllerB __instance) { SpawnableObjects.LoadSpawnableObjects(); NetcodeHelper.Instance.Initialize(); } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void SpawnNetcodeHelper(ref StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsHost) { GameObject val = Object.Instantiate<GameObject>(Plugin.NetcodeHelperPrefab); val.GetComponent<NetworkObject>().Spawn(false); Plugin.Console.LogInfo((object)"Spawned netcode helper!"); } } } [HarmonyPatch(typeof(StunGrenadeItem))] public class StunGrenadeItemPatch : MonoBehaviour { [HarmonyPrefix] [HarmonyPatch("ExplodeStunGrenade")] private static bool PreventExplosion(ref StunGrenadeItem __instance) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; int num = Random.RandomRangeInt(0, 100); if (!__instance.explodeOnCollision) { return true; } if (num > 25) { return true; } Plugin.Console.LogInfo((object)"Doing custom explosion stuff"); PlayEggEffects(__instance, ((Component)__instance).transform.position); ((GrabbableObject)__instance).DestroyObjectInHand(__instance.playerThrownBy); NetcodeHelper.Instance.SpawnObjectServerRpc(localPlayerController.playerClientId, ((Component)__instance).transform.position); return false; } [HarmonyPostfix] [HarmonyPatch("SetExplodeOnThrowClientRpc")] private static void ForceExplosion(ref StunGrenadeItem __instance) { } private static void PlayEggEffects(StunGrenadeItem item, Vector3 position) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) item.itemAudio.PlayOneShot(item.explodeSFX); Object.Instantiate<GameObject>(item.stunGrenadeExplosion, position, Quaternion.identity); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace LethalEasterEggs.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }