Decompiled source of ScorchWurmTweaks v1.1.1

plugins/ScorchWurmTweaks/ScorchWurmTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Scorchling;
using HG.Reflection;
using IL;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On;
using On.EntityStates.Scorchling;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ScorchWurmTweaks")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyInformationalVersion("1.0.0+d3f9c4a6ffc54e6aa0fb482b29f352bf8344d7b9")]
[assembly: AssemblyProduct("ScorchWurmTweaks")]
[assembly: AssemblyTitle("ScorchWurmTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScorchWurmTweaks
{
	public class BreachComponentNux : NetworkBehaviour
	{
		[SyncVar(hook = "OnShouldReposition")]
		public Vector3 breachPosition = Vector3.zero;

		private EntityStateMachine entityStateMachine;

		public Vector3 NetworkbreachPosition
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return breachPosition;
			}
			[param: In]
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				ref Vector3 reference = ref breachPosition;
				if (NetworkServer.localClientActive && !((NetworkBehaviour)this).syncVarHookGuard)
				{
					((NetworkBehaviour)this).syncVarHookGuard = true;
					OnShouldReposition(value);
					((NetworkBehaviour)this).syncVarHookGuard = false;
				}
				((NetworkBehaviour)this).SetSyncVar<Vector3>(value, ref reference, 1u);
			}
		}

		private void OnShouldReposition(Vector3 newPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			NetworkbreachPosition = newPosition;
			if (Object.op_Implicit((Object)(object)entityStateMachine))
			{
				entityStateMachine.SetNextState((EntityState)(object)new BetterScorchlingBurrow());
			}
		}

		private void Start()
		{
			foreach (EntityStateMachine item in ((Component)this).GetComponents<EntityStateMachine>().ToList())
			{
				if (item.customName == "Body")
				{
					entityStateMachine = item;
				}
			}
		}

		private void UNetVersion()
		{
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (forceAll)
			{
				writer.Write(breachPosition);
				return true;
			}
			bool flag = false;
			if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(breachPosition);
			}
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
			}
			return flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (initialState)
			{
				breachPosition = reader.ReadVector3();
				return;
			}
			int num = (int)reader.ReadPackedUInt32();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				OnShouldReposition(reader.ReadVector3());
			}
		}
	}
	public class BetterScorchlingBurrow : BaseState
	{
		public string burrowSoundString = "Play_scorchling_burrow";

		public string burrowLoopSoundString = "Play_scorchling_burrow_loop";

		public string burrowStopLoopSoundString = "Stop_scorchling_burrow_loop";

		public GameObject burrowEffectPrefab = Main.burrowEffectPrefab;

		public float burrowRadius = 1f;

		public float animDurationBurrow = 1f;

		public float burrowAnimationDuration = 1f;

		public float teleportDelay = 2f;

		private ScorchlingController sController;

		private bool waitingForBurrow;

		public override void OnEnter()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			((BaseState)this).OnEnter();
			sController = ((Component)((EntityState)this).characterBody).GetComponent<ScorchlingController>();
			if (!sController.isBurrowed)
			{
				Util.PlaySound(burrowSoundString, ((EntityState)this).gameObject);
				Util.PlaySound(burrowLoopSoundString, ((EntityState)this).gameObject);
				EffectManager.SpawnEffect(burrowEffectPrefab, new EffectData
				{
					origin = ((EntityState)this).characterBody.footPosition,
					scale = burrowRadius
				}, true);
				((EntityState)this).PlayAnimation("FullBody, Override", "Burrow", "Burrow.playbackRate", animDurationBurrow, 0f);
				if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
				{
					((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 0f;
				}
				if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
				{
					((EntityState)this).characterBody.isSprinting = false;
				}
				waitingForBurrow = true;
			}
		}

		public override void FixedUpdate()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			((EntityState)this).FixedUpdate();
			HandleWaitForBurrow();
			if (!(((EntityState)this).fixedAge <= teleportDelay))
			{
				((EntityState)this).outer.SetNextState((EntityState)new ScorchlingBreach());
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
			HandleWaitForBurrow();
		}

		private void HandleWaitForBurrow()
		{
			if (waitingForBurrow && !((double)((EntityState)this).fixedAge <= (double)burrowAnimationDuration))
			{
				sController.Burrow();
				waitingForBurrow = false;
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			if (waitingForBurrow)
			{
				return (InterruptPriority)5;
			}
			return (InterruptPriority)1;
		}
	}
	public class CheckReposition : BaseState
	{
		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			if (NetworkServer.active)
			{
				ShouldReposition();
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			((EntityState)this).outer.SetNextStateToMain();
		}

		private void ShouldReposition()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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)
			bool flag = true;
			Target currentEnemy = ((Component)((EntityState)this).characterBody.master).GetComponent<BaseAI>().currentEnemy;
			CharacterBody val = ((currentEnemy != null) ? currentEnemy.characterBody : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			BreachComponentNux component = ((EntityState)this).gameObject.GetComponent<BreachComponentNux>();
			Vector3 footPosition = ((EntityState)this).characterBody.footPosition;
			NodeGraph nodeGraph = SceneInfo.instance.GetNodeGraph((GraphType)0);
			Vector3 val2 = RaycastToFloor(val.coreTransform.position);
			if (val2 == val.coreTransform.position)
			{
				flag = false;
			}
			List<NodeIndex> list = nodeGraph.FindNodesInRange(val2, 10f, 20f, (HullMask)2);
			Vector3 val3 = default(Vector3);
			bool flag2 = false;
			int num = 35;
			while (!flag2)
			{
				NodeIndex val4 = list.ElementAt(Random.Range(0, list.Count));
				nodeGraph.GetNodePosition(val4, ref val3);
				double num2 = Vector3.Distance(footPosition, val3);
				num--;
				if (num2 > 35.0 || num < 0)
				{
					flag2 = true;
				}
			}
			Vector3 val5 = val3;
			if (component.breachPosition == val5)
			{
				flag = false;
			}
			if (flag)
			{
				component.NetworkbreachPosition = val5;
			}
		}

		private Vector3 RaycastToFloor(Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(new Ray(position, Vector3.down), ref val, 200f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return position;
			}
			return ((RaycastHit)(ref val)).point;
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)7;
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("ScorchWurmTweaks");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "ScorchWurmTweaks".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.ScorchWurmTweaks", "ScorchWurmTweaks", "1.1.1")]
	public class Main : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__BaseStateOnEnterCallerMethodModifier;
		}

		public const string PluginGUID = "Nuxlar.ScorchWurmTweaks";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "ScorchWurmTweaks";

		public const string PluginVersion = "1.1.1";

		public static GameObject burrowEffectPrefab;

		private const BindingFlags allFlags = (BindingFlags)(-1);

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			Instance = this;
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			MethodInfo? method = typeof(Main).GetMethod("BaseStateOnEnterCaller", (BindingFlags)(-1));
			object obj = <>O.<0>__BaseStateOnEnterCallerMethodModifier;
			if (obj == null)
			{
				Manipulator val = BaseStateOnEnterCallerMethodModifier;
				<>O.<0>__BaseStateOnEnterCallerMethodModifier = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)method, (Manipulator)obj);
			bool flag = default(bool);
			ContentAddition.AddEntityState<CheckReposition>(ref flag);
			ContentAddition.AddEntityState<BetterScorchlingBurrow>(ref flag);
			LoadAssets();
			TweakBody();
			TweakBurrowDef();
			TweakBreachDef();
			TweakSkillDrivers();
			TweakProjectileGhost();
			ScorchlingController.Update += new Manipulator(PreventBreakage);
			ScorchlingBreach.OnEnter += new hook_OnEnter(TweakBreachState);
			SpawnState.OnEnter += new hook_OnEnter(TweakSpawnState);
			ScorchlingController.Start += new hook_Start(IncreaseTrailDelay);
			ScorchlingController.Burrow += new hook_Burrow(ReplaceBurrow);
			ScorchlingController.Breach += new hook_Breach(ReplaceBreach);
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}

		private void PreventBreakage(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction instr = null;
			FieldReference val3 = default(FieldReference);
			ILLabel val2 = default(ILLabel);
			if (val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterMotor>(x, "get_isGrounded"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2),
				(Instruction x) => MatchAny(x, out instr)
			}))
			{
				val.Emit(OpCodes.Br, instr);
			}
		}

		private void IncreaseTrailDelay(orig_Start orig, ScorchlingController self)
		{
			self.timeInAirToShutOffDustTrail = 10f;
			orig.Invoke(self);
		}

		private void TweakSpawnState(orig_OnEnter orig, SpawnState self)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			orig.Invoke(self);
			((EntityState)self).outer.SetNextState((EntityState)new ScorchlingBreach());
		}

		private void ReplaceBurrow(orig_Burrow orig, ScorchlingController self)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			self.isRecentlyBurrowed = true;
			self.isBurrowed = true;
			self.SetTeleportPermission(true);
			if (NetworkServer.active)
			{
				self.ensureBurrowSkill.stock = 0;
				if (self.characterBody.GetBuffCount(Buffs.HiddenInvincibility.buffIndex) < 1)
				{
					self.characterBody.AddBuff(Buffs.HiddenInvincibility.buffIndex);
				}
			}
			self.originalLayer = ((Component)self).gameObject.layer;
			((Component)self).gameObject.layer = LayerIndex.GetAppropriateFakeLayerForTeam(self.characterBody.teamComponent.teamIndex).intVal;
			if (Object.op_Implicit((Object)(object)self.baseDirt) && Object.op_Implicit((Object)(object)self.dustTrail))
			{
				self.baseDirt.SetActive(false);
				self.dustTrail.SetActive(true);
				self.dustTrailActive = true;
				self.armatureObject.SetActive(false);
				self.meshObject.SetActive(false);
			}
			self.enemyDetection.Enable();
		}

		private void ReplaceBreach(orig_Breach orig, ScorchlingController self)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			self.isBurrowed = false;
			self.SetTeleportPermission(false);
			if (NetworkServer.active)
			{
				self.characterBody.RemoveBuff(Buffs.HiddenInvincibility.buffIndex);
				self.lavaBombSkill.stock = 1;
				if (Object.op_Implicit((Object)(object)self.characterBody))
				{
					self.characterBody.isSprinting = false;
				}
				self.breachBaseDirtRotation = self.baseDirt.transform.rotation;
				((Quaternion)(ref self.breachBaseDirtRotation)).eulerAngles = new Vector3(((Quaternion)(ref self.breachBaseDirtRotation)).eulerAngles.x, Mathf.Floor(((Quaternion)(ref self.breachBaseDirtRotation)).eulerAngles.y), ((Quaternion)(ref self.breachBaseDirtRotation)).eulerAngles.z);
				self.baseDirt.transform.localEulerAngles = Vector3.zero;
				self.baseDirt.transform.rotation = self.breachBaseDirtRotation;
			}
			((Component)self).gameObject.layer = self.originalLayer;
			if (Object.op_Implicit((Object)(object)self.baseDirt) && Object.op_Implicit((Object)(object)self.dustTrail))
			{
				self.baseDirt.SetActive(true);
				self.dustTrail.SetActive(false);
				self.dustTrailActive = false;
				self.armatureObject.SetActive(true);
				self.meshObject.SetActive(true);
			}
			self.enemyDetection.Disable();
		}

		private void TweakBreachState(orig_OnEnter orig, ScorchlingBreach self)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			BaseStateOnEnterCaller((BaseState)(object)self);
			self.crackToBreachTime = 2f;
			self.breachToBurrow = 2f;
			self.proceedImmediatelyToLavaBomb = false;
			self.amServer = NetworkServer.active;
			self.scorchlingController = ((Component)((EntityState)self).characterBody).GetComponent<ScorchlingController>();
			Util.PlaySound(self.preBreachSoundString, ((EntityState)self).gameObject);
			Target currentEnemy = ((Component)((EntityState)self).characterBody.master).GetComponent<BaseAI>().currentEnemy;
			self.enemyCBody = ((currentEnemy != null) ? currentEnemy.characterBody : null);
			BreachComponentNux component = ((EntityState)self).gameObject.GetComponent<BreachComponentNux>();
			if (component.breachPosition != Vector3.zero)
			{
				self.breachPosition = component.breachPosition;
			}
			else
			{
				self.breachPosition = ((EntityState)self).characterBody.footPosition;
			}
			if (self.proceedImmediatelyToLavaBomb)
			{
				self.breachToBurrow = 1f;
			}
			self.breachToBurrow += self.crackToBreachTime;
			self.burrowToEndOfTime += self.breachToBurrow;
			((EntityState)self).characterBody.SetAimTimer(self.breachToBurrow);
			TeleportHelper.TeleportBody(((EntityState)self).characterBody, self.breachPosition, false);
			EffectManager.SpawnEffect(self.crackEffectPrefab, new EffectData
			{
				origin = self.breachPosition,
				scale = self.crackRadius
			}, true);
			self.scorchlingController.SetTeleportPermission(false);
		}

		private void LoadAssets()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Scorchling.VFXScorchlingEnterBurrow_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				burrowEffectPrefab = x.Result;
			};
		}

		private void TweakBreachDef()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC2_Scorchling.ScorchlingBreach_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				x.Result.activationState = new SerializableEntityStateType(typeof(CheckReposition));
			};
		}

		private void TweakBurrowDef()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC2_Scorchling.ScorchlingEnsureBurrow_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				SkillDef result = x.Result;
				result.activationState = new SerializableEntityStateType(typeof(CheckReposition));
				result.baseRechargeInterval = 12f;
			};
		}

		private void TweakBody()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Scorchling.ScorchlingBody_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				CharacterBody component = x.Result.GetComponent<CharacterBody>();
				component.baseMoveSpeed = 0f;
				x.Result.AddComponent<BreachComponentNux>();
				Object.Destroy((Object)(object)((Component)component).GetComponent<CharacterMotor>());
				Object.Destroy((Object)(object)((Component)component).GetComponent<KinematicCharacterMotor>());
			};
		}

		private void TweakProjectileGhost()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Scorchling.LavaBombHeatOrbGhost_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				GameObject result = x.Result;
				AnimationCurve val2 = new AnimationCurve();
				val2.AddKey(0f, 0f);
				val2.AddKey(1f, 1f);
				ObjectScaleCurve obj = ((Component)result.transform.GetChild(0)).gameObject.AddComponent<ObjectScaleCurve>();
				obj.overallCurve = val2;
				obj.useOverallCurveOnly = true;
				obj.timeMax = 0.25f;
			};
		}

		private void TweakSkillDrivers()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Scorchling.ScorchlingMaster_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				AISkillDriver[] components = x.Result.GetComponents<AISkillDriver>();
				foreach (AISkillDriver val2 in components)
				{
					if (val2.customName == "ChaseOffNodegraphClose" || val2.customName == "FollowNodeGraphToTarget")
					{
						Object.Destroy((Object)(object)val2);
					}
					if (val2.customName == "ChaseOffNodegraph")
					{
						val2.customName = "Stare";
						val2.maxDistance = float.PositiveInfinity;
						val2.minDistance = 0f;
						val2.skillSlot = (SkillSlot)(-1);
						val2.requireSkillReady = false;
					}
					if (val2.customName == "Breach")
					{
						val2.maxDistance = float.PositiveInfinity;
						val2.skillSlot = (SkillSlot)2;
						val2.requiredSkill = null;
						val2.activationRequiresAimConfirmation = false;
						val2.aimType = (AimType)1;
					}
					if (val2.customName == "LavaBomb")
					{
						val2.maxDistance = 50f;
						val2.noRepeat = false;
					}
				}
			};
		}

		private static void BaseStateOnEnterCaller(BaseState self)
		{
		}

		private static void BaseStateOnEnterCallerMethodModifier(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Call, (MethodBase)typeof(BaseState).GetMethod("OnEnter", (BindingFlags)(-1)));
		}

		public static bool MatchAny(Instruction instr, out Instruction instruction)
		{
			instruction = instr;
			return true;
		}
	}
}