Decompiled source of TrollPhysics v1.0.0

TrollPhysics.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("TrollPhysics")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrollPhysics")]
[assembly: AssemblyTitle("TrollPhysics")]
[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 TrollPhysics
{
	[HarmonyPatch]
	public static class HarmonyPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyIdentifier), "AddFlammable")]
		public static void OiledUp(EnemyIdentifier __instance)
		{
			if (TrollPhysicsPlugin.DoApplyTrollPhysics(__instance))
			{
				GameObjectExtensions.GetOrAddComponent<TrollPhysicsBehaviour>(((Component)__instance).gameObject);
			}
		}
	}
	public class TrollPhysicsBehaviour : MonoBehaviour
	{
		public float _time;

		public Rigidbody _body = null;

		public EnemyIdentifier _identifier;

		public float enemyMult = 1f;

		public void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			_body = ((Component)this).GetComponent<Rigidbody>();
			_identifier = ((Component)this).GetComponent<EnemyIdentifier>();
			if (Object.op_Implicit((Object)(object)_identifier.gce))
			{
				_identifier.gce.ForceOff();
			}
			if (TrollPhysicsPlugin.EnemyMultsDict.TryGetValue(EnemyTypes.GetEnemyName(_identifier.enemyType), out var value))
			{
				enemyMult = value;
			}
		}

		public void FixedUpdate()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			_time += Time.fixedDeltaTime * TrollPhysicsPlugin.TimeMult.Value;
			if (!Object.op_Implicit((Object)(object)_body))
			{
				Object.Destroy((Object)(object)this);
			}
			else if (TrollPhysicsPlugin.DoApplyTrollPhysics(_identifier))
			{
				Vector3 val = Vector3.up * ((_time + TrollPhysicsPlugin.StartForce.Value) * enemyMult);
				Rigidbody body = _body;
				body.velocity += val;
				Rigidbody body2 = _body;
				body2.position += val;
				if (_time > TrollPhysicsPlugin.KillTime.Value * TrollPhysicsPlugin.TimeMult.Value && TrollPhysicsPlugin.DoKill.Value)
				{
					_identifier.Explode(true);
				}
			}
		}
	}
	[BepInPlugin("bubbet.trollphysics", "Troll Physics", "1.0.0")]
	public class TrollPhysicsPlugin : BaseUnityPlugin
	{
		public static ConfigEntry<float> StartForce;

		public static ConfigEntry<float> TimeMult;

		public static ConfigEntry<float> KillTime;

		public static ConfigEntry<bool> DoKill;

		public static ConfigEntry<float> GasThreshold;

		public static ConfigEntry<string> Scenes;

		public static string[] ScenesArray;

		public static ConfigEntry<string> EnemyMults;

		public static Dictionary<string, float> EnemyMultsDict = new Dictionary<string, float>();

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			val.PatchAll();
			StartForce = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Start Force", 0.25f, (ConfigDescription)null);
			TimeMult = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Time Mult", 0.125f, "How slow time gets added to the force. 1 is realtime affects how quickly they build speed");
			KillTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Kill Time", 5f, "How long before they blow up.");
			DoKill = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Do Kill", true, "Do they blow up when the time is elapsed.");
			GasThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Gas Threshold", 4.5f, "How much oil is required to cover them in oil. 5 is fully covered.");
			Scenes = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Scenes", "Level 5-2;Level 5-4", "Which levels is it raining in.");
			EnemyMults = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Enemy Mults", "Gabriel, Judge of Hell=1.0;Sisyphean Insurrectionist=1.0;Sentry=1.0;V2=1.0;Mysterious Druid Knight (& Owl)=1.0;Gabriel, Apostate of Hate=1.0;BigJohnator=1.0;CancerousRodent=1.0;Centaur=1.0;Cerberus=1.0;Drone=1.0;Ferryman=1.0;Filth=1.0;FleshPanopticon=1.0;FleshPrison=1.0;Gutterman=1.0;Guttertank=1.0;HideousMass=1.0;Idol=1.0;Leviathan=1.0;MaliciousFace=1.0;Mannequin=1.0;Mindflayer=1.0;Minos=1.0;MinosPrime=1.0;Minotaur=1.0;Puppet=1.0;Schism=1.0;SisyphusPrime=1.0;Soldier=1.0;Stalker=1.0;Stray=1.0;Streetcleaner=1.0;Swordsmachine=1.0;V2Second=1.0;VeryCancerousRodent=1.0;Virtue=1.0;Wicked=1.0", "Enemy force multipliers. Newer enemies might not be present check EnemyTypes.GetEnemyName for those.");
			Scenes.SettingChanged += ScenesUpdated;
			EnemyMults.SettingChanged += EnemiesUpdated;
			ScenesUpdated(null, null);
			EnemiesUpdated(null, null);
		}

		public static void ScenesUpdated(object? sender, EventArgs? e)
		{
			ScenesArray = Scenes.Value.Split(new char[1] { ';' });
		}

		public static void EnemiesUpdated(object? sender, EventArgs? e)
		{
			EnemyMultsDict.Clear();
			string[] array = EnemyMults.Value.Split(new char[1] { ';' });
			foreach (string text in array)
			{
				string[] array2 = text.Split(new char[1] { '=' });
				if (float.TryParse(array2[1], out var result))
				{
					EnemyMultsDict[array2[0]] = result;
				}
			}
		}

		public static bool DoApplyTrollPhysics(EnemyIdentifier identifier)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			float num = identifier.flammables.Aggregate(0f, (float current, Flammable flammable2) => Mathf.Max(current, flammable2.fuel));
			if (num < GasThreshold.Value)
			{
				return false;
			}
			return (identifier.underwater || (ScenesArray.Contains(SceneHelper.CurrentScene) && OutdoorsChecker.CheckIfPositionOutdoors(((Component)identifier).gameObject.transform.position))) && !identifier.blessed;
		}
	}
}