Decompiled source of ScorchWurmTweaks v1.0.0

ScorchWurmTweaks.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Scorchling;
using Microsoft.CodeAnalysis;
using On.EntityStates.Scorchling;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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("ScorchWurmTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScorchWurmTweaks")]
[assembly: AssemblyTitle("ScorchWurmTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 ScorchWurmTweaks
{
	public class Cunt : MonoBehaviour
	{
		private void Start()
		{
			Object.Destroy((Object)(object)((Component)this).GetComponent<EffectManagerHelper>());
		}
	}
	[BepInPlugin("com.Nuxlar.ScorchWurmTweaks", "ScorchWurmTweaks", "1.0.0")]
	public class ScorchWurmTweaks : BaseUnityPlugin
	{
		private GameObject scorchlingProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Scorchling/ScorchlingBombProjectile.prefab").WaitForCompletion();

		private GameObject scorchlingDOTProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Scorchling/LavaBombHeatOrbProjectile.prefab").WaitForCompletion();

		private GameObject scorchlingMaster = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Scorchling/ScorchlingMaster.prefab").WaitForCompletion();

		private GameObject scorchlingOrbGhost = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Scorchling/LavaBombHeatOrbGhost.prefab").WaitForCompletion();

		public static ConfigEntry<bool> changeDOTDuration;

		public static ConfigEntry<bool> changeAI;

		public static ConfigEntry<bool> changeDamage;

		private static ConfigFile SWTConfig { get; set; }

		public void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			SWTConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.ScorchWurmTweaks.cfg", true);
			changeDOTDuration = SWTConfig.Bind<bool>("General", "Change duration of DOT sphere", true, "Should the duration of the fire orb be reduced?");
			changeAI = SWTConfig.Bind<bool>("General", "Change AI", true, "Should the AI be changed?");
			changeDamage = SWTConfig.Bind<bool>("General", "Change damage", true, "Should the damage of the lava bomb be reduced?");
			scorchlingOrbGhost.AddComponent<Cunt>();
			if (changeDOTDuration.Value)
			{
				scorchlingDOTProjectile.GetComponent<DestroyOnTimer>().duration = 5f;
				scorchlingDOTProjectile.GetComponent<ProjectileDotZone>().lifetime = 5f;
			}
			if (changeAI.Value)
			{
				foreach (AISkillDriver item in scorchlingMaster.GetComponents<AISkillDriver>().ToList())
				{
					if (item.customName == "LavaBomb")
					{
						item.minDistance = 0f;
					}
					if (item.customName == "FollowNodeGraphToTarget")
					{
						item.minDistance = 25f;
					}
					if (item.customName == "ChaseOffNodegraph" || item.customName == "ChaseOffNodegraphClose")
					{
						Object.Destroy((Object)(object)item);
					}
				}
				ScorchlingBreach.OnEnter += new hook_OnEnter(TweakBreach);
			}
			if (changeDamage.Value)
			{
				ScorchlingLavaBomb.OnEnter += new hook_OnEnter(TweakLavaBomb);
			}
		}

		private void TweakLavaBomb(orig_OnEnter orig, ScorchlingLavaBomb self)
		{
			ScorchlingLavaBomb.mortarDamageCoefficient = 1f;
			orig.Invoke(self);
		}

		private void TweakBreach(orig_OnEnter orig, ScorchlingBreach self)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			IntPtr functionPointer = typeof(BaseState).GetMethod("OnEnter").MethodHandle.GetFunctionPointer();
			((Action)Activator.CreateInstance(typeof(Action), self, functionPointer))();
			self.proceedImmediatelyToLavaBomb = true;
			self.amServer = NetworkServer.active;
			self.scorchlingController = ((Component)((EntityState)self).characterBody).GetComponent<ScorchlingController>();
			Util.PlaySound(self.preBreachSoundString, ((EntityState)self).gameObject);
			if (self.amServer)
			{
				if (self.proceedImmediatelyToLavaBomb)
				{
					self.breachToBurrow = 1f;
				}
				self.breachToBurrow += self.crackToBreachTime;
				self.burrowToEndOfTime += self.breachToBurrow;
				self.breachPosition = ((EntityState)self).characterBody.footPosition;
				if (Object.op_Implicit((Object)(object)((EntityState)self).characterMotor))
				{
					((EntityState)self).characterMotor.walkSpeedPenaltyCoefficient = 0f;
				}
				((EntityState)self).characterBody.SetAimTimer(self.breachToBurrow);
				TeleportHelper.TeleportBody(((EntityState)self).characterBody, self.breachPosition);
				EffectManager.SpawnEffect(self.crackEffectPrefab, new EffectData
				{
					origin = self.breachPosition,
					scale = self.crackRadius
				}, true);
				self.scorchlingController.SetTeleportPermission(false);
			}
		}
	}
}