using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using Player_Landmine_Summon;
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: AssemblyCompany("Player_Landmine_Summon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Player_Landmine_Summon")]
[assembly: AssemblyTitle("Player_Landmine_Summon")]
[assembly: AssemblyVersion("1.0.0.0")]
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.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;
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class Initiate
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void updateObject()
{
if (!Object.op_Implicit((Object)(object)GameObject.Find("CET.Controller")))
{
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)val).name = "CET.Controller";
val.layer = LayerMask.NameToLayer("Player");
val.AddComponent<MonobehaviorScript>();
}
}
}
namespace Player_Landmine_Summon
{
[BepInPlugin("cobster.explosivetouch", "Explosive touch", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "cobster.explosivetouch";
private const string modName = "Explosive touch";
private const string modVersion = "1.0.0.0";
private static GameObject _landmine;
private readonly Harmony harmony = new Harmony("cobster.explosivetouch");
internal static InputClass PluginInputs = new InputClass();
public static GameObject Landmine => TryToGetLandMine();
private void Awake()
{
harmony.PatchAll(typeof(Initiate));
}
public static GameObject TryToGetLandMine()
{
if ((Object)(object)_landmine != (Object)null)
{
return _landmine;
}
SpawnableMapObject[] spawnableMapObjects = RoundManager.Instance.spawnableMapObjects;
if (spawnableMapObjects.Length == 0)
{
return null;
}
RoundManager.Instance.spawnableMapObjects = spawnableMapObjects;
SpawnableMapObject[] array = spawnableMapObjects;
int num = 0;
if (num < array.Length)
{
SpawnableMapObject val = array[num];
if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
{
_landmine = val.prefabToSpawn;
return _landmine;
}
return null;
}
return null;
}
}
public class InputClass : LcInputActions
{
[InputAction("<Keyboard>/x", Name = "Explode")]
public InputAction ExplodeKey { get; set; }
}
internal class MonobehaviorScript : MonoBehaviour
{
public PlayerControllerB currentPlayer;
public void Start()
{
Object.Destroy((Object)(object)((Component)this).GetComponent<Collider>());
Plugin.PluginInputs.ExplodeKey.performed -= ExplosionKeyed;
Plugin.PluginInputs.ExplodeKey.performed += ExplosionKeyed;
DefinePlayerController();
}
public void DefinePlayerController()
{
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
for (int i = 0; i < array.Length; i++)
{
if (((NetworkBehaviour)array[i]).IsOwner)
{
currentPlayer = array[i];
}
}
}
public void ExplosionKeyed(CallbackContext context)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_006a: 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)
GameObject gameObject = ((Component)currentPlayer.gameplayCamera).gameObject;
LayerMask val = LayerMask.op_Implicit(1 << LayerMask.NameToLayer("Player"));
Debug.Log((object)val);
RaycastHit val2 = default(RaycastHit);
bool flag = Physics.Raycast(gameObject.transform.position + gameObject.transform.forward * 0.5f, gameObject.transform.forward, ref val2, float.PositiveInfinity, LayerMask.op_Implicit(val));
Debug.Log((object)flag);
if (flag)
{
Debug.Log((object)((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name);
if ((Object)(object)((Component)((RaycastHit)(ref val2)).transform).gameObject.GetComponent<PlayerControllerB>() != (Object)null)
{
PlaceLandmineAtServerRpc(((RaycastHit)(ref val2)).transform.position);
}
}
}
[ServerRpc]
private void PlaceLandmineAtServerRpc(Vector3 position)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Plugin.TryToGetLandMine();
GameObject val = Object.Instantiate<GameObject>(Plugin.Landmine, position, Quaternion.identity);
val.SetActive(true);
NetworkObject component = val.GetComponent<NetworkObject>();
if (!((Object)(object)component == (Object)null))
{
component.Spawn(false);
}
}
}
}