Decompiled source of LegalizeNuclearBombs v2.0.0

LegalizeNuclearBombs.dll

Decompiled a month ago
using System;
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 Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[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: AssemblyCompany("BLOKBUSTR")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+2713492e56c173425b62ce0b10cd8cd44d569a83")]
[assembly: AssemblyProduct("LegalizeNuclearBombs")]
[assembly: AssemblyTitle("LegalizeNuclearBombs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
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 LegalizeNuclearBombs
{
	[BepInPlugin("BLOKBUSTR.LegalizeNuclearBombs", "LegalizeNuclearBombs", "2.0.0")]
	public class LegalizeNuclearBombs : BaseUnityPlugin
	{
		public enum HitSensitivity
		{
			Light,
			Medium,
			Heavy
		}

		public static ConfigEntry<HitSensitivity> configHitSensitivity;

		public static ConfigEntry<int> configMaxHitCount;

		public static ConfigEntry<float> configExplosionStrength;

		public static ConfigEntry<int> configPlayerDamage;

		public static ConfigEntry<int> configEnemyDamage;

		public static ConfigEntry<float> configCameraShakeStrength;

		public static ConfigEntry<bool> configPlayWarningSound;

		public static ConfigEntry<float> configWarningVolume;

		public static ConfigEntry<bool> configShowWarningVisual;

		public static ConfigEntry<float> configWarningCameraShakeStrength;

		private static ConfigEntry<bool> configEnableDebug;

		internal static LegalizeNuclearBombs Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			RegisterConfig();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
			Debug("Debug logs are enabled.");
		}

		private void RegisterConfig()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			configHitSensitivity = ((BaseUnityPlugin)this).Config.Bind<HitSensitivity>("1 - Nuke", "HitSensitivity", HitSensitivity.Medium, new ConfigDescription("The minimum impact strength that the nuke is sensitive to.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMaxHitCount = ((BaseUnityPlugin)this).Config.Bind<int>("1 - Nuke", "MaxHitCount", 3, new ConfigDescription("The number of hits the nuke can take until it explodes. Set to 0 to disable and make it explode only when it loses all value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			configExplosionStrength = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Nuke", "ExplosionStrength", 15f, new ConfigDescription("The strength of the explosion.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 25f), Array.Empty<object>()));
			configPlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("1 - Nuke", "PlayerDamage", 200, new ConfigDescription("The amount of damage dealt to players.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			configEnemyDamage = ((BaseUnityPlugin)this).Config.Bind<int>("1 - Nuke", "EnemyDamage", 400, new ConfigDescription("The amount of damage dealt to enemies.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			configCameraShakeStrength = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Nuke", "CameraShakeStrength", 5f, new ConfigDescription("The intensity of the explosion camera shake.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			configPlayWarningSound = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Break Warning", "PlayWarningSound", true, new ConfigDescription("Whether to play a fizzing sound as a warning when the nuke has only one hit remaining.", (AcceptableValueBase)null, Array.Empty<object>()));
			configWarningVolume = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Break Warning", "WarningVolume", 0.35f, new ConfigDescription("The volume of the warning sound.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			configShowWarningVisual = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Break Warning", "ShowWarningVisual", true, new ConfigDescription("Whether to momentarily show a red glow on the nuke when it has only one hit remaining.", (AcceptableValueBase)null, Array.Empty<object>()));
			configWarningCameraShakeStrength = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Break Warning", "WarningCameraShakeStrength", 1.5f, new ConfigDescription("The intensity of the warning camera shake.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			configEnableDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLogging", false, new ConfigDescription("Whether to enable debug logging.", (AcceptableValueBase)null, Array.Empty<object>()));
		}

		public static void Debug(string message, MonoBehaviour? monoBehaviour = null)
		{
			if (configEnableDebug.Value)
			{
				string text = (((Object)(object)monoBehaviour == (Object)null) ? string.Empty : $"{monoBehaviour}: ");
				Logger.LogDebug((object)(text + message));
			}
		}
	}
	public class NukeValuable : Trap
	{
		public Transform center;

		public GameObject mesh;

		private Material material;

		private static readonly int emissionColor = Shader.PropertyToID("_EmissionColor");

		private bool detonated;

		private bool emissionActive;

		private bool emissionImpulse;

		private float emissionTime;

		private ParticleScriptExplosion particleScriptExplosion;

		private int hitCount;

		public Sound warningSound;

		public override void Start()
		{
			((Trap)this).Start();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			material = mesh.GetComponent<Renderer>().material;
			LegalizeNuclearBombs.Debug($"New nuke valuable spawned | {((Component)this).gameObject}", (MonoBehaviour?)(object)this);
		}

		public override void Update()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (emissionActive)
			{
				if (emissionImpulse)
				{
					GameDirector.instance.CameraImpact.ShakeDistance(LegalizeNuclearBombs.configWarningCameraShakeStrength.Value, 1f, 6f, ((Component)this).transform.position, 0.25f);
					emissionImpulse = false;
				}
				LegalizeNuclearBombs.Debug($"emissionColor: {material.GetColor(emissionColor).r}");
				material.SetColor(emissionColor, Color.white * Mathf.Lerp(material.GetColor(emissionColor).r, Mathf.Clamp(emissionTime, 0f, 1f), 0.35f));
				if (emissionTime > 0f)
				{
					emissionTime -= Time.deltaTime;
				}
				else if (!(material.GetColor(emissionColor).r > 0.01f))
				{
					material.SetColor(emissionColor, Color.black);
					emissionActive = false;
				}
			}
		}

		public void Explode()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!detonated)
			{
				particleScriptExplosion.Spawn(center.position, LegalizeNuclearBombs.configExplosionStrength.Value, LegalizeNuclearBombs.configPlayerDamage.Value, LegalizeNuclearBombs.configEnemyDamage.Value, LegalizeNuclearBombs.configExplosionStrength.Value, false, false, LegalizeNuclearBombs.configCameraShakeStrength.Value);
				LegalizeNuclearBombs.Debug("KABOOM", (MonoBehaviour?)(object)this);
				detonated = true;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void PotentialExplodeLight()
		{
			if (base.isLocal && LegalizeNuclearBombs.configHitSensitivity.Value == LegalizeNuclearBombs.HitSensitivity.Light)
			{
				PotentialExplodeHeavy();
			}
		}

		public void PotentialExplodeMedium()
		{
			if (base.isLocal && LegalizeNuclearBombs.configHitSensitivity.Value != LegalizeNuclearBombs.HitSensitivity.Heavy)
			{
				PotentialExplodeHeavy();
			}
		}

		public void PotentialExplodeHeavy()
		{
			//IL_00ab: 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)
			if (!base.isLocal || LegalizeNuclearBombs.configMaxHitCount.Value <= 0)
			{
				return;
			}
			if (hitCount >= LegalizeNuclearBombs.configMaxHitCount.Value - 1)
			{
				Explode();
				return;
			}
			LegalizeNuclearBombs.Debug($"_hitCount: {hitCount + 1}", (MonoBehaviour?)(object)this);
			if (hitCount >= LegalizeNuclearBombs.configMaxHitCount.Value - 2)
			{
				if (SemiFunc.IsMultiplayer())
				{
					base.photonView.RPC("PlayWarningRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					PlayWarningRPC();
				}
			}
			hitCount++;
		}

		[PunRPC]
		public void PlayWarningRPC(PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (LegalizeNuclearBombs.configPlayWarningSound.Value)
			{
				warningSound.Volume = LegalizeNuclearBombs.configWarningVolume.Value;
				warningSound.Play(center.position, 1f, 1f, 1f, 1f);
			}
			if (LegalizeNuclearBombs.configShowWarningVisual.Value)
			{
				emissionTime = 1.5f;
				emissionImpulse = true;
				emissionActive = true;
			}
			LegalizeNuclearBombs.Debug("Played warning, one hit left", (MonoBehaviour?)(object)this);
		}
	}
}