using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("GuysNight.LethalCompanyMod.EodRoulette")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+1e4d56c2cd19dcd0f45444a611b003bad3eb66ff")]
[assembly: AssemblyProduct("GuysNight.LethalCompanyMod.EodRoulette")]
[assembly: AssemblyTitle("GuysNight.LethalCompanyMod.EodRoulette")]
[assembly: AssemblyVersion("1.1.0.0")]
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;
}
}
}
namespace GuysNight.LethalCompanyMod.EodRoulette
{
internal static class Constants
{
internal const string ConfigSectionHeader = "Settings";
internal const string ConfigChanceToDisableEntryKey = "ChanceToDisable";
internal const byte DefaultChanceToDisable = 69;
}
[BepInPlugin("GuysNight.LethalCompanyMod.EodRoulette", "GuysNight.LethalCompanyMod.EodRoulette", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
SharedComponents.ConfigFile.Bind<byte>("Settings", "ChanceToDisable", (byte)69, new ConfigDescription("The percentage chance that the mine will be disabled when stepping off of it. This value can be set anytime and the updated value will be respected upon stepping off of the mine.", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, (byte)100), Array.Empty<object>()));
}
}
public static class SharedComponents
{
public static ManualLogSource Logger { get; } = Logger.CreateLogSource("GuysNight.LethalCompanyMod.EodRoulette");
public static ConfigFile ConfigFile { get; } = new ConfigFile(Path.Combine(Paths.ConfigPath, "GuysNight.LethalCompanyMod.EodRoulette.cfg"), true)
{
SaveOnConfigSet = true
};
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "GuysNight.LethalCompanyMod.EodRoulette";
public const string PLUGIN_NAME = "GuysNight.LethalCompanyMod.EodRoulette";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace GuysNight.LethalCompanyMod.EodRoulette.Patches
{
[HarmonyPatch(typeof(Landmine))]
public class LandminePatches
{
private static readonly Random RandomGenerator = new Random();
[HarmonyPatch("TriggerMineOnLocalClientByExiting")]
[HarmonyPrefix]
public static bool PotentiallyAvoidExplosion(Landmine __instance)
{
if (!((Behaviour)__instance).isActiveAndEnabled)
{
return true;
}
SharedComponents.ConfigFile.Reload();
if (byte.TryParse(SharedComponents.ConfigFile["Settings", "ChanceToDisable"].GetSerializedValue(), out var result))
{
SharedComponents.Logger.LogDebug((object)$"Successfully retrieved chance to disable. Value is '{result}'");
}
else
{
SharedComponents.Logger.LogWarning((object)$"Could not retrieve chance to disable from config. Assuming it was set to the default value of {(byte)69}.");
result = 69;
}
int num = RandomGenerator.Next(1, 101);
SharedComponents.Logger.LogDebug((object)$"Random number generated {num}");
if (num > result)
{
SharedComponents.Logger.LogDebug((object)"The number generated resulted in a failed defusal. Letting game's code execute.");
return true;
}
SharedComponents.Logger.LogDebug((object)"The number generated resulted in a successful defusal. Doing overrides.");
((Behaviour)__instance.mineAnimator).enabled = false;
__instance.hasExploded = true;
__instance.ToggleMine(false);
return false;
}
}
}