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.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+344b3a91f619cbb7716f7d62a90208f393e58b89")]
[assembly: AssemblyProduct("Landmine Placer")]
[assembly: AssemblyTitle("LandminePlacer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
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<bool> InfiniteLandmines { get; private set; }
public static ConfigEntry<int> MaxLandmines { get; private set; }
public static ConfigEntry<int> LandminePlacerSpawnChance { get; private set; }
public static ConfigEntry<bool> LandminePlacerInShop { get; private set; }
public static ConfigEntry<int> LandminePlacerShopPrice { get; private set; }
public static void Load()
{
ConfigFile configFile = Plugin.ConfigFile;
InfiniteLandmines = configFile.Bind<bool>("Landmine Placer Fix", "InfiniteLandmines", false, "Infinite landmines, true = infinite, false = use MaxLandmines");
MaxLandmines = configFile.Bind<int>("Landmine Placer Fix", "MaxLandmines", 1, "Max landmines per LandminePlacer, only used if InfiniteLandmines is false");
LandminePlacerSpawnChance = configFile.Bind<int>("Landmine Placer Fix", "LandminePlacerSpawnChance", 80, "Chance of a LandminePlacer item spawning, higher = more common");
LandminePlacerInShop = configFile.Bind<bool>("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<int>("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<int> _maxLandmines = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private readonly NetworkVariable<bool> _infiniteLandmines = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private readonly NetworkVariable<int> _landminesPlaced = new NetworkVariable<int>(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_00cf: 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))
{
GameObject val3 = Object.Instantiate<GameObject>(Plugin.Landmine, position, Quaternion.identity);
val3.SetActive(true);
NetworkObject component = val3.GetComponent<NetworkObject>();
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)
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) && !_infiniteLandmines.Value)
{
NetworkVariable<int> 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (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 == 2 && (networkManager.IsClient || networkManager.IsHost))
{
((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)
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))
{
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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (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<bool>(ref infiniteLandmines, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 417443870u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
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<string> list = new List<string>();
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)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).grabbable = ((GrabbableObject)prop).grabbable;
((GrabbableObject)this).isHeld = ((GrabbableObject)prop).isHeld;
((GrabbableObject)this).isHeldByEnemy = ((GrabbableObject)prop).isHeldByEnemy;
((GrabbableObject)this).deactivated = ((GrabbableObject)prop).deactivated;
((GrabbableObject)this).parentObject = ((GrabbableObject)prop).parentObject;
((GrabbableObject)this).targetFloorPosition = ((GrabbableObject)prop).targetFloorPosition;
((GrabbableObject)this).startFallingPosition = ((GrabbableObject)prop).startFallingPosition;
((GrabbableObject)this).floorYRot = ((GrabbableObject)prop).floorYRot;
((GrabbableObject)this).fallTime = ((GrabbableObject)prop).fallTime;
((GrabbableObject)this).hasHitGround = ((GrabbableObject)prop).hasHitGround;
((GrabbableObject)this).scrapValue = ((GrabbableObject)prop).scrapValue;
((GrabbableObject)this).itemUsedUp = ((GrabbableObject)prop).itemUsedUp;
((GrabbableObject)this).playerHeldBy = ((GrabbableObject)prop).playerHeldBy;
((GrabbableObject)this).isPocketed = ((GrabbableObject)prop).isPocketed;
((GrabbableObject)this).isBeingUsed = ((GrabbableObject)prop).isBeingUsed;
((GrabbableObject)this).isInElevator = ((GrabbableObject)prop).isInElevator;
((GrabbableObject)this).isInShipRoom = ((GrabbableObject)prop).isInShipRoom;
((GrabbableObject)this).isInFactory = ((GrabbableObject)prop).isInFactory;
((GrabbableObject)this).useCooldown = ((GrabbableObject)prop).useCooldown;
((GrabbableObject)this).currentUseCooldown = ((GrabbableObject)prop).currentUseCooldown;
((GrabbableObject)this).itemProperties = ((GrabbableObject)prop).itemProperties;
((GrabbableObject)this).insertedBattery = ((GrabbableObject)prop).insertedBattery;
((GrabbableObject)this).customGrabTooltip = ((GrabbableObject)prop).customGrabTooltip;
((GrabbableObject)this).propBody = ((GrabbableObject)prop).propBody;
((GrabbableObject)this).propColliders = ((GrabbableObject)prop).propColliders;
((GrabbableObject)this).originalScale = ((GrabbableObject)prop).originalScale;
((GrabbableObject)this).wasOwnerLastFrame = ((GrabbableObject)prop).wasOwnerLastFrame;
((GrabbableObject)this).mainObjectRenderer = ((GrabbableObject)prop).mainObjectRenderer;
((GrabbableObject)this).isSendingItemRPC = ((GrabbableObject)prop).isSendingItemRPC;
((GrabbableObject)this).scrapPersistedThroughRounds = ((GrabbableObject)prop).scrapPersistedThroughRounds;
((GrabbableObject)this).heldByPlayerOnServer = ((GrabbableObject)prop).heldByPlayerOnServer;
((GrabbableObject)this).radarIcon = ((GrabbableObject)prop).radarIcon;
((GrabbableObject)this).reachedFloorTarget = ((GrabbableObject)prop).reachedFloorTarget;
((GrabbableObject)this).grabbableToEnemies = ((GrabbableObject)prop).grabbableToEnemies;
((GrabbableObject)this).hasBeenHeld = ((GrabbableObject)prop).hasBeenHeld;
}
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();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_LandminePlacer()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3176384049u, new RpcReceiveHandler(__rpc_handler_3176384049));
NetworkManager.__rpc_func_table.Add(2175429515u, new RpcReceiveHandler(__rpc_handler_2175429515));
NetworkManager.__rpc_func_table.Add(2794258110u, new RpcReceiveHandler(__rpc_handler_2794258110));
NetworkManager.__rpc_func_table.Add(1836362747u, new RpcReceiveHandler(__rpc_handler_1836362747));
NetworkManager.__rpc_func_table.Add(417443870u, new RpcReceiveHandler(__rpc_handler_417443870));
}
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)2;
((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<bool>(ref infiniteLandmines, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((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.2")]
[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<Item>("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<PhysicsProp>();
if ((Object)(object)component == (Object)null)
{
Log.LogError((object)"PhysicsProp is missing on the landmine prefab.");
return;
}
LandminePlacer landminePlacer = spawnPrefab.AddComponent<LandminePlacer>();
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<Landmine>() != (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.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace LandminePlacer.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}