Decompiled source of TsarBomb v1.0.2

plugins/TsarBomb.dll

Decompiled a day 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 PxntxrezStudio.TsarBomb;
using REPOLib.Modules;
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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("PxntxrezStudio")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TsarBomb")]
[assembly: AssemblyTitle("TsarBomb")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.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;
		}
	}
}
public class BarrelValuableTsarBomb : Trap
{
	private ParticleScriptExplosionTsarBomb particleScriptExplosionTsarBomb;

	private int HitCount;

	private int MaxHitCount;

	public Transform Center;

	public override void Start()
	{
		((Trap)this).Start();
		particleScriptExplosionTsarBomb = ((Component)this).GetComponent<ParticleScriptExplosionTsarBomb>();
		MaxHitCount = TsarBomb.ConfigData.MaxHitCount.Value;
	}

	public void Explode()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		particleScriptExplosionTsarBomb.Spawn(Center.position, 1f, 50, 100);
	}

	public void PotentialExplode()
	{
		if (base.isLocal)
		{
			if (HitCount >= MaxHitCount - 1)
			{
				Explode();
			}
			else
			{
				HitCount++;
			}
		}
	}
}
public class ParticleScriptExplosionTsarBomb : MonoBehaviour
{
	public ExplosionPreset explosionPreset;

	private GameObject explosionPrefab;

	private void Start()
	{
		explosionPrefab = Resources.Load<GameObject>("Effects/Part Prefab Explosion");
	}

	public ParticlePrefabExplosion Spawn(Vector3 position, float size, int damage, int enemyDamage, float forceMulti = 1f, bool onlyParticleEffect = false, bool disableSound = false, float shakeMultiplier = 3f)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		if (size < 0.25f)
		{
			if (!disableSound)
			{
				explosionPreset.explosionSoundSmall.Play(position, 1f, 1f, 1f, 1f);
				explosionPreset.explosionSoundSmallGlobal.Play(position, 1f, 1f, 1f, 1f);
			}
			if (shakeMultiplier != 0f)
			{
				GameDirector.instance.CameraImpact.ShakeDistance(24f * shakeMultiplier, 22f, 20f, ((Component)this).transform.position, 0.2f);
				GameDirector.instance.CameraShake.ShakeDistance(24f * shakeMultiplier, 22f, 20f, ((Component)this).transform.position, 0.5f);
			}
		}
		else if (size < 0.5f)
		{
			if (!disableSound)
			{
				explosionPreset.explosionSoundMedium.Play(position, 1f, 1f, 1f, 1f);
				explosionPreset.explosionSoundMediumGlobal.Play(position, 1f, 1f, 1f, 1f);
			}
			if (shakeMultiplier != 0f)
			{
				GameDirector.instance.CameraImpact.ShakeDistance(14f * shakeMultiplier, 10f, 16f, ((Component)this).transform.position, 0.2f);
				GameDirector.instance.CameraShake.ShakeDistance(5f * shakeMultiplier, 10f, 16f, ((Component)this).transform.position, 0.5f);
			}
		}
		else
		{
			if (!disableSound)
			{
				explosionPreset.explosionSoundBig.Play(position, 1f, 1f, 1f, 1f);
				explosionPreset.explosionSoundBigGlobal.Play(position, 1f, 1f, 1f, 1f);
			}
			if (shakeMultiplier != 0f)
			{
				GameDirector.instance.CameraImpact.ShakeDistance(25f * shakeMultiplier, 18f, 26f, ((Component)this).transform.position, 0.2f);
				GameDirector.instance.CameraShake.ShakeDistance(15f * shakeMultiplier, 18f, 26f, ((Component)this).transform.position, 0.5f);
			}
		}
		ParticlePrefabExplosion component = Object.Instantiate<GameObject>(explosionPrefab, position, Quaternion.identity).GetComponent<ParticlePrefabExplosion>();
		component.forceMultiplier = explosionPreset.explosionForceMultiplier * forceMulti;
		component.explosionSize = TsarBomb.ConfigData.ExplosionRadius.Value;
		component.explosionDamage = Mathf.RoundToInt((float)damage * TsarBomb.ConfigData.PlayerDamage.Value);
		component.explosionDamageEnemy = Mathf.RoundToInt((float)enemyDamage * TsarBomb.ConfigData.EnemyDamage.Value);
		component.lightColorOverTime = explosionPreset.lightColor;
		ColorOverLifetimeModule colorOverLifetime = component.particleFire.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(explosionPreset.explosionColors);
		colorOverLifetime = component.particleSmoke.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(explosionPreset.smokeColors);
		component.particleFire.Play();
		component.particleSmoke.Play();
		((Behaviour)component.light).enabled = true;
		if (TsarBomb.ConfigData.CanExplodeThroughWalls.Value)
		{
			HurtCollider[] componentsInChildren = ((Component)component).GetComponentsInChildren<HurtCollider>();
			foreach (HurtCollider val in componentsInChildren)
			{
				val.playerRayCast = false;
				val.enemyRayCast = false;
				val.physRayCast = false;
			}
		}
		else
		{
			HurtCollider[] componentsInChildren2 = ((Component)component).GetComponentsInChildren<HurtCollider>();
			foreach (HurtCollider val2 in componentsInChildren2)
			{
				val2.playerRayCast = true;
				val2.enemyRayCast = true;
				val2.physRayCast = true;
			}
		}
		return component;
	}
}
namespace PxntxrezStudio.TsarBomb
{
	[BepInPlugin("PxntxrezStudio.TsarBomb", "Tsar Bomb", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TsarBomb : BaseUnityPlugin
	{
		private const string modGUID = "PxntxrezStudio.TsarBomb";

		private const string modName = "Tsar Bomb";

		private const string modVersion = "1.0.1";

		internal static TsarBomb instance;

		internal static GameObject BombPrefab;

		public ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		public static TsarBombConfig ConfigData { get; private set; }

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"PxntxrezStudio.TsarBomb v1.0.1: Instance set.");
				ConfigData = new TsarBombConfig();
				ConfigData.Init(((BaseUnityPlugin)this).Config);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"PxntxrezStudio.TsarBomb v1.0.1: Config initialized.");
				string text = ((BaseUnityPlugin)this).Info.Location.Replace("TsarBomb.dll", "tsarbomb");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
					return;
				}
				BombPrefab = val.LoadAsset<GameObject>("TsarBomb");
				if ((Object)(object)BombPrefab == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load TsarBomb prefab!");
					return;
				}
				if ((Object)(object)BombPrefab.GetComponent<TsarBombValuable>() == (Object)null)
				{
					BombPrefab.AddComponent<TsarBombValuable>();
				}
				Valuables.RegisterValuable(BombPrefab);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"PxntxrezStudio.TsarBomb v1.0.1: TsarBomb registered successfully.");
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public class TsarBombConfig
	{
		private const int MinLimit = 1000;

		private const int MaxLimit = 500000;

		private const float MinWeight = 0.1f;

		private const float MaxWeight = 20f;

		private const int MinExplosionRadius = 1;

		private const int MaxExplosionRadius = 100;

		private const float MinExplosionDamage = 1f;

		private const float MaxExplosionDamage = 500f;

		private const int MinMaxHitCount = 0;

		private const int MaxMaxHitCount = 12;

		public ConfigEntry<int> MinValue { get; private set; }

		public ConfigEntry<int> MaxValue { get; private set; }

		public ConfigEntry<float> Weight { get; private set; }

		public ConfigEntry<int> ExplosionRadius { get; private set; }

		public ConfigEntry<float> PlayerDamage { get; private set; }

		public ConfigEntry<float> EnemyDamage { get; private set; }

		public ConfigEntry<bool> CanExplodeThroughWalls { get; private set; }

		public ConfigEntry<int> MaxHitCount { get; private set; }

		public void Init(ConfigFile config)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			MinValue = config.Bind<int>("Value", "Min Tsar Bomb Sell Price", 40000, new ConfigDescription("Minimum value of Tsar Bomb when sold.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1000, 500000), Array.Empty<object>()));
			MaxValue = config.Bind<int>("Value", "Max Tsar Bomb Sell Price", 75000, new ConfigDescription("Maximum value of Tsar Bomb when sold.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1000, 500000), Array.Empty<object>()));
			Weight = config.Bind<float>("Physics", "Weight", 8f, new ConfigDescription("Weight of Tsar Bomb (affects how heavy it feels).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			ExplosionRadius = config.Bind<int>("Explosion", "Explosion Radius", 15, new ConfigDescription("Explosion radius of Tsar Bomb. (For comparison: explosive grenade radius is 1)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			PlayerDamage = config.Bind<float>("Damage", "Player Damage", 50f, new ConfigDescription("Damage dealt to player by Tsar Bomb. Each increment of 1 increases the damage by 100 units.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 500f), Array.Empty<object>()));
			EnemyDamage = config.Bind<float>("Damage", "Enemy Damage", 50f, new ConfigDescription("Damage dealt to enemy by Tsar Bomb. Each increment of 1 increases the damage by 100 units.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 500f), Array.Empty<object>()));
			CanExplodeThroughWalls = config.Bind<bool>("Walls", "Explosion goes through walls?", true, new ConfigDescription("Enable or disable the ability to explode through walls.", (AcceptableValueBase)null, Array.Empty<object>()));
			MaxHitCount = config.Bind<int>("Trigger", "Max Hits Before Explosion", 1, new ConfigDescription("The amount of heavy hits required to trigger the explosion. (0 means only explode on destroy)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 12), Array.Empty<object>()));
		}
	}
	public class TsarBombValuable : MonoBehaviour
	{
		private void Awake()
		{
			ValuableObject component = ((Component)this).GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				TsarBomb.instance.Log.LogError((object)"TsarBombValuable: ValuableObject component not found!");
				return;
			}
			int value = TsarBomb.ConfigData.MinValue.Value;
			int value2 = TsarBomb.ConfigData.MaxValue.Value;
			Value val = ScriptableObject.CreateInstance<Value>();
			val.valueMin = Mathf.Max(0, value);
			val.valueMax = Mathf.Max(val.valueMin, (float)value2);
			component.valuePreset = val;
			float value3 = TsarBomb.ConfigData.Weight.Value;
			PhysAttribute val2 = ScriptableObject.CreateInstance<PhysAttribute>();
			val2.mass = value3;
			component.physAttributePreset = val2;
			Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.mass = value3;
				TsarBomb.instance.Log.LogInfo((object)$"TsarBombValuable: Rigidbody.mass set to {component2.mass}");
			}
			TsarBomb.instance.Log.LogInfo((object)$"TsarBombValuable: Set value {val.valueMin} - {val.valueMax}");
			TsarBomb.instance.Log.LogInfo((object)$"TsarBombValuable: Set weight (via physAttributePreset) to {value3}");
		}
	}
}