using System;
using System.Collections;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SuperLandmine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("SuperLandmine mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("SuperLandmine")]
[assembly: AssemblyTitle("SuperLandmine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 SuperLandmine
{
[BepInPlugin("Superlandmine", "SuperLandmine", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource log;
public Harmony harmony = new Harmony("Superlandmine");
public static ConfigEntry<int> config_LandmineMinAmount;
public static ConfigEntry<int> config_LandmineMaxAmount;
public static ConfigEntry<bool> config_EnableLandmineSound;
public static ConfigEntry<bool> config_EnemyCanTriggerLandmine;
public static ConfigEntry<bool> config_LandmineCanSpawnOutside;
public static ConfigEntry<bool> config_UseDefaultLandmineSpawnRate;
private void Awake()
{
log = ((BaseUnityPlugin)this).Logger;
log.LogInfo((object)"Loading plugin SuperLandmine ...");
ConfigSetup();
harmony.PatchAll();
log.LogInfo((object)"Plugin SuperLandmine loaded!");
}
private void ConfigSetup()
{
config_LandmineMinAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine min amount", "Value", 10, "Min landmine to be spawned in the map");
config_LandmineMaxAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine max amount", "Value", 15, "Max landmine to be spawned in the map");
config_EnableLandmineSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Disable landmine sound", "Value", true, "Enable or disable landmine sound");
config_EnemyCanTriggerLandmine = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemy trigger landmine", "Value", true, "Enable or disable enemy can trigger landmine");
config_LandmineCanSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("Landmine can spawn outside", "Value", true, "Enable or disable landmine can spawn outside");
config_UseDefaultLandmineSpawnRate = ((BaseUnityPlugin)this).Config.Bind<bool>("Use default landmine spawn rate", "Value", false, "Enable or disable default landmine spawn rate");
}
}
internal class PluginInfo
{
public const string PLUGIN_GUID = "Superlandmine";
public const string PLUGIN_NAME = "SuperLandmine";
public const string PLUGIN_VERSION = "1.1.2";
}
public static class Utils
{
public class OutsideLandmineMarker : MonoBehaviour
{
}
public const float MAX_RAYCAST_DIST = 30000f;
public static (Vector3, Quaternion) projectToGround(Vector3 position)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
Ray val = new Ray(position, Vector3.down);
Quaternion item = Quaternion.identity;
Vector3 item2 = position;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, 30000f))
{
item2 = ((RaycastHit)(ref val2)).point;
item = Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val2)).normal);
}
return (item2, item);
}
}
}
namespace SuperLandmine.Patchs
{
[HarmonyPatch(typeof(Landmine))]
public class SuperLandminePatch
{
[HarmonyPatch("PressMineClientRpc")]
[HarmonyPostfix]
public static void playTriggerSound(Landmine __instance)
{
Plugin.log.LogInfo((object)"Play trigger sound");
__instance.mineAudio.volume = 1.3f;
__instance.mineFarAudio.volume = 1.3f;
Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
__instance.mineAudio.PlayOneShot(__instance.minePress, 1.3f);
WalkieTalkie.TransmitOneShotAudio(__instance.mineAudio, __instance.minePress, 1f);
}
[HarmonyPatch("Detonate")]
[HarmonyPrefix]
public static void IncreaseAudioVolume(Landmine __instance)
{
Plugin.log.LogInfo((object)"Increase landmine volume and kill range");
((MonoBehaviour)__instance).StartCoroutine(DelayedActions(__instance));
}
private static IEnumerator DelayedActions(Landmine __instance)
{
yield return (object)new WaitForSeconds(0.5f);
__instance.mineAudio.volume = 1.2f;
__instance.mineFarAudio.volume = 1.3f;
__instance.mineAudio.pitch = Random.Range(0.93f, 1.07f);
__instance.mineAudio.PlayOneShot(__instance.mineDetonate, 1.2f);
Landmine.SpawnExplosion(((Component)__instance).transform.position + Vector3.up, true, 10f, 12f);
yield return (object)new WaitForSeconds(0.5f);
}
[HarmonyPatch("Detonate")]
[HarmonyPostfix]
public static void disableSoundAfterExplode(Landmine __instance)
{
if (Plugin.config_EnableLandmineSound.Value)
{
__instance.mineAudio.volume = 0f;
__instance.mineFarAudio.volume = 0f;
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void enabledLandMineSound(Landmine __instance)
{
if (Plugin.config_EnableLandmineSound.Value)
{
__instance.mineAudio.volume = 0f;
__instance.mineFarAudio.volume = 0f;
}
}
[HarmonyPatch("OnTriggerEnter")]
[HarmonyPrefix]
public static void anyObjectTriggerLandmineEnter(ref Collider other, Landmine __instance)
{
if (!Plugin.config_EnemyCanTriggerLandmine.Value)
{
return;
}
float value = Traverse.Create((object)__instance).Field("pressMineDebounceTimer").GetValue<float>();
if (__instance.hasExploded || value > 0f)
{
return;
}
if (((Component)other).CompareTag("Player"))
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && (Object)(object)component != (Object)null && !component.isPlayerDead)
{
Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)true);
Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
__instance.PressMineServerRpc();
}
}
else
{
if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
{
return;
}
if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
{
if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
return;
}
}
else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
{
return;
}
Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
__instance.PressMineServerRpc();
}
}
[HarmonyPatch("OnTriggerExit")]
[HarmonyPrefix]
public static void anyObjectTriggerLandmineExit(ref Collider other, Landmine __instance)
{
if (!Plugin.config_EnemyCanTriggerLandmine.Value)
{
return;
}
bool value = Traverse.Create((object)__instance).Field("mineActivated").GetValue<bool>();
if (__instance.hasExploded || !value)
{
return;
}
if (((Component)other).CompareTag("Player"))
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)false);
Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
}
}
else
{
if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
{
return;
}
if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
{
if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
return;
}
}
else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
{
return;
}
Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
}
}
}
[HarmonyPatch(typeof(RoundManager))]
public class RoundManagerPatch
{
[HarmonyPatch("LoadNewLevel")]
[HarmonyPrefix]
public static void spawnLanmineInside(ref SelectableLevel newLevel)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
if (Plugin.config_UseDefaultLandmineSpawnRate.Value)
{
return;
}
Plugin.log.LogInfo((object)"Load landmine");
SelectableLevel obj = newLevel;
SpawnableMapObject[] spawnableMapObjects = obj.spawnableMapObjects;
if (obj.spawnableMapObjects.Length == 0)
{
return;
}
Plugin.log.LogInfo((object)"Spawn landmine inside");
SpawnableMapObject[] array = spawnableMapObjects;
foreach (SpawnableMapObject val in array)
{
if ((Object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
{
val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
});
}
}
}
[HarmonyPatch("SpawnOutsideHazards")]
[HarmonyPrefix]
public static void spawnLandmineOutside(RoundManager __instance)
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.config_LandmineCanSpawnOutside.Value || !((NetworkBehaviour)__instance).IsServer || !((NetworkBehaviour)__instance).IsHost)
{
return;
}
Utils.OutsideLandmineMarker[] array = Object.FindObjectsOfType<Utils.OutsideLandmineMarker>();
for (int i = 0; i < array.Length; i++)
{
Object.Destroy((Object)(object)((Component)array[i]).gameObject);
}
Plugin.log.LogInfo((object)"Load landmine");
SelectableLevel currentLevel = __instance.currentLevel;
SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
if (currentLevel.spawnableMapObjects.Length == 0)
{
return;
}
Plugin.log.LogInfo((object)"Spawn landmine outside");
SpawnableMapObject[] array2 = spawnableMapObjects;
foreach (SpawnableMapObject val in array2)
{
if (!((Object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null))
{
continue;
}
AnimationCurve val2 = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
});
Transform[] shipSpawnPathPoints = __instance.shipSpawnPathPoints;
for (int j = 0; j < shipSpawnPathPoints.Length; j++)
{
for (int k = 0; (float)k < val2.Evaluate(Random.Range(0f, 1f)); k++)
{
Random random = new Random();
Vector3 val3 = __instance.GetRandomNavMeshPositionInBoxPredictable(shipSpawnPathPoints[j].position, 300f, __instance.navHit, random, -5);
Quaternion val4;
(val3, val4) = Utils.projectToGround(val3);
Plugin.log.LogInfo((object)("Spawn landmine outside at" + ((object)(Vector3)(ref val3)).ToString()));
GameObject obj = Object.Instantiate<GameObject>(val.prefabToSpawn, val3, val4);
obj.SetActive(true);
obj.GetComponent<NetworkObject>().Spawn(false);
obj.AddComponent<Utils.OutsideLandmineMarker>();
}
}
}
}
}
}