using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; 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 LandminePlacer.NetcodePatcher; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("alexandre v1")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A Lethal Company mod that add a new item for placing mine")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+ea3d3e6ed2a76f343ae5256cfed33ccc00b68149")] [assembly: AssemblyProduct("Landmine Placer")] [assembly: AssemblyTitle("LandminePlacer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 LandminePlacer { public static class Config { public static ConfigEntry InfiniteLandmines { get; private set; } public static ConfigEntry MaxLandmines { get; private set; } public static ConfigEntry LandminePlacerSpawnChance { get; private set; } public static ConfigEntry LandminePlacerInShop { get; private set; } public static ConfigEntry LandminePlacerShopPrice { get; private set; } public static void Load() { ConfigFile configFile = Plugin.ConfigFile; InfiniteLandmines = configFile.Bind("Landmine Placer Fix", "InfiniteLandmines", false, "Infinite landmines, true = infinite, false = use MaxLandmines"); MaxLandmines = configFile.Bind("Landmine Placer Fix", "MaxLandmines", 1, "Max landmines per LandminePlacer, only used if InfiniteLandmines is false"); LandminePlacerSpawnChance = configFile.Bind("Landmine Placer Fix", "LandminePlacerSpawnChance", 80, "Chance of a LandminePlacer item spawning, higher = more common"); LandminePlacerInShop = configFile.Bind("Landmine Placer Fix", "LandminePlacerInShop", false, "Whether or not the LandminePlacer should be in the shop, true = in shop, false = not in shop"); LandminePlacerShopPrice = configFile.Bind("Landmine Placer Fix", "LandminePlacerShopPrice", 70, "Price of the LandminePlacer in the shop, only used if LandminePlacerInShop is true"); } } public class LandminePlacer : PhysicsProp { private readonly NetworkVariable _maxLandmines = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _infiniteLandmines = new NetworkVariable(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _landminesPlaced = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public override void OnNetworkSpawn() { ((GrabbableObject)this).Start(); if (((NetworkBehaviour)this).IsHost) { _maxLandmines.Value = Config.MaxLandmines?.Value ?? 3; _infiniteLandmines.Value = Config.InfiniteLandmines?.Value ?? false; UpdateGrabTooltipClientRpc(_landminesPlaced.Value, _maxLandmines.Value, _infiniteLandmines.Value); } } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (((NetworkBehaviour)this).IsOwner) { TryPlaceLandmine(buttonDown); } } public override void EquipItem() { UpdateItemTooltip(_landminesPlaced.Value, _maxLandmines.Value, _infiniteLandmines.Value); ((PhysicsProp)this).EquipItem(); } public override void DiscardItem() { UpdateGrabTooltipServerRpc(); ((GrabbableObject)this).DiscardItem(); } public void TryPlaceLandmine(bool buttonDown) { if (!buttonDown) { return; } if (IsPlayer()) { if (CanPlaceLandmine()) { PlaceLandMine(((Component)((GrabbableObject)this).playerHeldBy).transform); LandminePlacedServerRpc(); } else { DestroyObjectInHandClientRpc(); } } else { PlaceLandMine(((Component)((GrabbableObject)this).parentObject).transform); LandminePlacedServerRpc(); } } private void PlaceLandMine(Transform userTransform) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 position = userTransform.position; Vector3 position2 = position + userTransform.forward * 1.5f; PlaceLandmineAtServerRpc(position2); } [ServerRpc(RequireOwnership = false)] private void PlaceLandmineAtServerRpc(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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3176384049u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3176384049u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; GameObject val3 = Object.Instantiate(Plugin.Landmine, position, Quaternion.identity); val3.SetActive(true); NetworkObject component = val3.GetComponent(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogError((object)"NetworkObject is missing on the instantiated landmine."); } else { component.Spawn(false); } } } [ServerRpc(RequireOwnership = false)] private void LandminePlacedServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2175429515u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2175429515u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!_infiniteLandmines.Value) { NetworkVariable landminesPlaced = _landminesPlaced; int value = landminesPlaced.Value; landminesPlaced.Value = value + 1; if (_landminesPlaced.Value >= _maxLandmines.Value) { DestroyObjectInHandClientRpc(); } else { Plugin.Log.LogInfo((object)$"Landmines placed count {_landminesPlaced} !"); } UpdateItemTooltip(_landminesPlaced.Value, _maxLandmines.Value, _infiniteLandmines.Value); } } [ClientRpc] private void DestroyObjectInHandClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2794258110u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2794258110u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy); } } } [ServerRpc(RequireOwnership = false)] public void UpdateGrabTooltipServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1836362747u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1836362747u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; UpdateGrabTooltipClientRpc(_landminesPlaced.Value, _maxLandmines.Value, _infiniteLandmines.Value); } } } [ClientRpc] public void UpdateGrabTooltipClientRpc(int landminesPlaced, int maxLandmines, bool infiniteLandmines) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_007e: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(417443870u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, landminesPlaced); BytePacker.WriteValueBitPacked(val2, maxLandmines); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref infiniteLandmines, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 417443870u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!infiniteLandmines) { ((GrabbableObject)this).customGrabTooltip = $"{maxLandmines - landminesPlaced} Landmines remaining"; } else { ((GrabbableObject)this).customGrabTooltip = "Infinite Landmines"; } } } public void UpdateItemTooltip(int landminesPlaced, int maxLandmines, bool infiniteLandmines = false) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return; } if (localPlayerController.playerActions?.m_Movement_Use == null || (Object)(object)((GrabbableObject)this).itemProperties == (Object)null) { Plugin.Log.LogError((object)"Cannot update ItemTooltip, One of the required objects is null."); return; } string text = ((!_infiniteLandmines.Value) ? $"{_maxLandmines.Value - _landminesPlaced.Value} Landmines remaining" : null); List list = new List(); if (text != null) { list.Add(text); } string bindingDisplayString = InputActionRebindingExtensions.GetBindingDisplayString(localPlayerController.playerActions.m_Movement_Use, 0, (DisplayStringOptions)0); list.Add(string.Format("Press {0} to place a landmine", "[" + bindingDisplayString + "]")); ((GrabbableObject)this).itemProperties.toolTips = list.ToArray(); } private bool IsPlayer() { return (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !((GrabbableObject)this).isHeldByEnemy; } private bool CanPlaceLandmine() { return _landminesPlaced.Value < _maxLandmines.Value || _infiniteLandmines.Value; } public void InitProperties(PhysicsProp prop) { FieldInfo[] fields = typeof(GrabbableObject).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(this, fieldInfo.GetValue(prop)); } } public override string __getTypeName() { return "LandminePlacer"; } protected override void __initializeVariables() { if (_maxLandmines == null) { throw new Exception("LandminePlacer._maxLandmines cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_maxLandmines).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_maxLandmines, "_maxLandmines"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_maxLandmines); if (_infiniteLandmines == null) { throw new Exception("LandminePlacer._infiniteLandmines cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_infiniteLandmines).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_infiniteLandmines, "_infiniteLandmines"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_infiniteLandmines); if (_landminesPlaced == null) { throw new Exception("LandminePlacer._landminesPlaced cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_landminesPlaced).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_landminesPlaced, "_landminesPlaced"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_landminesPlaced); ((PhysicsProp)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3176384049u, new RpcReceiveHandler(__rpc_handler_3176384049), "PlaceLandmineAtServerRpc"); ((NetworkBehaviour)this).__registerRpc(2175429515u, new RpcReceiveHandler(__rpc_handler_2175429515), "LandminePlacedServerRpc"); ((NetworkBehaviour)this).__registerRpc(2794258110u, new RpcReceiveHandler(__rpc_handler_2794258110), "DestroyObjectInHandClientRpc"); ((NetworkBehaviour)this).__registerRpc(1836362747u, new RpcReceiveHandler(__rpc_handler_1836362747), "UpdateGrabTooltipServerRpc"); ((NetworkBehaviour)this).__registerRpc(417443870u, new RpcReceiveHandler(__rpc_handler_417443870), "UpdateGrabTooltipClientRpc"); ((PhysicsProp)this).__initializeRpcs(); } private static void __rpc_handler_3176384049(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); target.__rpc_exec_stage = (__RpcExecStage)1; ((LandminePlacer)(object)target).PlaceLandmineAtServerRpc(position); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2175429515(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((LandminePlacer)(object)target).LandminePlacedServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2794258110(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((LandminePlacer)(object)target).DestroyObjectInHandClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1836362747(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((LandminePlacer)(object)target).UpdateGrabTooltipServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_417443870(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int landminesPlaced = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref landminesPlaced); int maxLandmines = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref maxLandmines); bool infiniteLandmines = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref infiniteLandmines, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((LandminePlacer)(object)target).UpdateGrabTooltipClientRpc(landminesPlaced, maxLandmines, infiniteLandmines); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "LandminePlacer"; } } [BepInPlugin("Axyss.LandminePlacerFix", "Landmine Placer Fix", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { private static GameObject _landmine; public Item placeableLandmineItem; internal static ManualLogSource Log; public static ConfigFile ConfigFile; public static GameObject Landmine => TryToGetLandMine(); private void Awake() { Log = Logger.CreateLogSource("Axyss.LandminePlacerFix"); ConfigFile = ((BaseUnityPlugin)this).Config; Config.Load(); PatchMod(); InitLandminePlacer(); Log.LogInfo((object)"Plugin Axyss.LandminePlacerFix is loaded!"); } private static void PatchMod() { 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); } } } } private void InitLandminePlacer() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException(), "landmine_placer"); AssetBundle val = AssetBundle.LoadFromFile(text); placeableLandmineItem = val.LoadAsset("Assets/Mods/LandminePlacer/LandminePlacer.asset"); if ((Object)(object)placeableLandmineItem == (Object)null) { Log.LogError((object)"Could not load LandminePlacer item"); return; } GameObject spawnPrefab = placeableLandmineItem.spawnPrefab; if ((Object)(object)spawnPrefab == (Object)null) { Log.LogError((object)"Could not load LandminePlacer prefab"); return; } PhysicsProp component = spawnPrefab.GetComponent(); if ((Object)(object)component == (Object)null) { Log.LogError((object)"PhysicsProp is missing on the landmine prefab."); return; } LandminePlacer landminePlacer = spawnPrefab.AddComponent(); if ((Object)(object)landminePlacer == (Object)null) { Log.LogError((object)"Could not add LandminePlacer script to prefab"); return; } if ((Object)(object)component != (Object)null) { landminePlacer.InitProperties(component); Object.Destroy((Object)(object)component); } else { Log.LogError((object)"PhysicsProp is missing on the landmine prefab."); } NetworkPrefabs.RegisterNetworkPrefab(placeableLandmineItem.spawnPrefab); int value = Config.LandminePlacerSpawnChance.Value; Items.RegisterItem(placeableLandmineItem); Items.RegisterScrap(placeableLandmineItem, value, (LevelTypes)(-1)); if (Config.LandminePlacerInShop.Value) { Items.RegisterShopItem(placeableLandmineItem, Config.LandminePlacerShopPrice.Value); } } private static GameObject TryToGetLandMine() { if ((Object)(object)_landmine != (Object)null) { return _landmine; } SpawnableMapObject[] spawnableMapObjects = RoundManager.Instance.currentLevel.spawnableMapObjects; if (spawnableMapObjects.Length == 0) { return null; } SpawnableMapObject[] array = spawnableMapObjects; foreach (SpawnableMapObject val in array) { if ((Object)(object)val.prefabToSpawn.GetComponentInChildren() != (Object)null) { _landmine = val.prefabToSpawn; return _landmine; } } Log.LogError((object)"Could not find default landmine prefab"); return null; } } public static class PluginInfo { public const string PluginGuid = "Axyss.LandminePlacerFix"; public const string PluginName = "Landmine Placer Fix"; public const string PluginVersion = "1.0.4"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace LandminePlacer.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }