Decompiled source of BigNuke v1.0.1

BigNuke.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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("BigNuke")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigNuke")]
[assembly: AssemblyTitle("BigNuke")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.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;
		}
	}
	[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 Vortex.BigNuke
{
	[BepInPlugin("Vortex.BigNuke", "BigNuke", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BigNuke : BaseUnityPlugin
	{
		private const string modUID = "Vortex.BigNuke";

		private const string modName = "BigNuke";

		private const string modVersion = "1.0.1";

		public int explosionPlayerDamage = 100;

		public int explosionEnemyDamage = 500;

		public ConfigEntry<float> explosionRange;

		public ConfigEntry<int> maxHitCount;

		public ConfigEntry<int> minValue;

		public ConfigEntry<int> maxValue;

		internal static BigNuke instance;

		internal ManualLogSource logger = Logger.CreateLogSource("BigNuke");

		internal static GameObject NukeModel;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			if ((Object)instance == (Object)null)
			{
				instance = this;
			}
			else
			{
				Object.Destroy((Object)this);
			}
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Instance set.");
			explosionRange = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "Range", 5f, "The range of the explosion. (For comparison: explosive grenade range is 1)");
			maxHitCount = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Max Hit Count", 3, "The amount of heavy hits required to trigger the explosion. (0 means only explode on destroy)");
			minValue = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Min Nuke Sell Value", 8000, "The minimum value of the nuke when sold.");
			maxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Max Nuke Sell Value", 12000, "The maximum value of the nuke when sold.");
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Config loaded.");
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("BigNuke.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "nuke");
			if ((Object)val == (Object)null)
			{
				logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			NukeModel = val.LoadAsset<GameObject>("Valuable Nuke");
			if ((Object)NukeModel == (Object)null)
			{
				logger.LogError((object)"Failed to load model!");
				return;
			}
			NukeValuable nukeValuable = NukeModel.AddComponent<NukeValuable>();
			if ((Object)nukeValuable == (Object)null)
			{
				logger.LogError((object)"Failed to add NukeValuable component!");
				return;
			}
			Valuables.RegisterValuable(NukeModel);
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Nuke registered.");
		}
	}
	public class NukeValuable : Trap
	{
		private ParticleScriptExplosion particleScriptExplosion;

		private int HitCount;

		public Transform Center;

		public override void Start()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			if ((Object)component == (Object)null)
			{
				BigNuke.instance.logger.LogError((object)"Failed to get PhysGrabObjectImpactDetector component!");
				return;
			}
			Value val = ScriptableObject.CreateInstance<Value>();
			val.valueMin = Math.Max(0, BigNuke.instance.minValue.Value);
			val.valueMax = Math.Max(val.valueMin, BigNuke.instance.maxValue.Value);
			ValuableObject component2 = ((Component)this).GetComponent<ValuableObject>();
			if ((Object)component2 == (Object)null)
			{
				BigNuke.instance.logger.LogError((object)"Failed to get ValuableObject component!");
				return;
			}
			component2.valuePreset = val;
			component.onBreakHeavy.AddListener(new UnityAction(PotentialExplode));
			component.onDestroy.AddListener(new UnityAction(Explode));
			((Trap)this).Start();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			Center = ((Component)this).transform.Find("Object/Center");
		}

		public void Explode()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			particleScriptExplosion.Spawn(Center.position, Math.Max(1f, BigNuke.instance.explosionRange.Value), BigNuke.instance.explosionPlayerDamage, BigNuke.instance.explosionEnemyDamage, 1f, false, false, 1f);
		}

		public void PotentialExplode()
		{
			if (base.isLocal && BigNuke.instance.maxHitCount.Value > 0)
			{
				if (HitCount >= BigNuke.instance.maxHitCount.Value - 1)
				{
					Explode();
				}
				else
				{
					HitCount++;
				}
			}
		}
	}
}