Decompiled source of Scoutmasters Rampage v2.2.0

tony.and.Snoszs-Scoutmasters Rampage.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using Zorro.Core;

[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("ScoutmasterRampage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+754f024f0f511c024abf0129ee68ae82157a75e4")]
[assembly: AssemblyProduct("ScoutmasterRampage")]
[assembly: AssemblyTitle("ScoutmasterRampage")]
[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 ScoutmasterRampage
{
	[BepInPlugin("tony4twentys.scoutmastersrampage", "Scoutmasters Rampage", "2.2.0")]
	public class ScoutmasterRampagePlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RunManager), "StartRun")]
		public class StartRunPatch
		{
			private static void Postfix()
			{
				if (!((Object)(object)Singleton<MapHandler>.Instance == (Object)null) && PhotonNetwork.IsMasterClient)
				{
					Instance.litFireCount = -1;
					Instance.respawnEndTime = -1f;
					Instance.scoutmasterHasSpawned = false;
					Instance.IncreaseLitFireCount();
				}
			}
		}

		[HarmonyPatch(typeof(Scoutmaster), "FixedUpdate")]
		private static class FixedUpdatePatch
		{
			private static bool Prefix(Scoutmaster __instance)
			{
				if (__instance.character.data.fallSeconds > 0f)
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(CharacterGrabbing), "GrabAction")]
		public class ScoutmasterGrabActionPatch
		{
			private static bool Prefix(CharacterGrabbing __instance, Collision collision)
			{
				//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_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Invalid comparison between Unknown and I4
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Expected I4, but got Unknown
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.character.data.isScoutmaster || !((MonoBehaviourPun)__instance.character).photonView.IsMine || Object.op_Implicit((Object)(object)__instance.character.data.grabJoint) || !__instance.character.data.isReaching || __instance.character.data.sinceLetGoOfFriend < 0.35f || !Object.op_Implicit((Object)(object)collision.rigidbody))
				{
					return true;
				}
				if (!PhotonNetwork.IsMasterClient)
				{
					return true;
				}
				Character componentInParent = ((Component)collision.transform).GetComponentInParent<Character>();
				if (Object.op_Implicit((Object)(object)componentInParent) && !((Object)(object)componentInParent == (Object)(object)__instance.character))
				{
					BodypartType partType = componentInParent.GetPartType(collision.rigidbody);
					if ((int)partType != -1 && (Object)(object)__instance.character.data.grabbedPlayer == (Object)null && Instance.sinceLastGrabbedTimer >= Instance.sinceLastGrabbedMinTime)
					{
						((MonoBehaviourPun)__instance.character).photonView.RPC("RPCA_GrabAttach", (RpcTarget)0, new object[3]
						{
							((MonoBehaviourPun)componentInParent).photonView,
							(int)partType,
							((Component)collision.rigidbody).transform.InverseTransformPoint(((Component)__instance.character.GetBodypart((BodypartType)10).Rig).transform.position)
						});
						Instance.sinceLastGrabbedTimer = 0f;
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Scoutmaster), "DoVisuals")]
		public static class DoVisualsPatch
		{
			private static bool Prefix(Scoutmaster __instance)
			{
				//IL_0078: 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)
				if (Instance.configDisableScreenEffect.Value || Instance.configScreenEffectPower.Value <= 0f)
				{
					__instance.mat.SetFloat("_Strength", 0f);
					return false;
				}
				float num = 0f;
				if ((Object)(object)__instance.currentTarget != (Object)null)
				{
					__instance.currentTarget.data.myersDistance = Vector3.Distance(__instance.character.Center, __instance.currentTarget.Center);
				}
				if ((Object)(object)__instance.currentTarget != (Object)null && __instance.currentTarget.IsLocal)
				{
					num = Mathf.InverseLerp(50f, 5f, __instance.distanceToTarget);
				}
				num *= Instance.configScreenEffectPower.Value;
				__instance.mat.SetFloat("_Strength", Mathf.Lerp(__instance.mat.GetFloat("_Strength"), num, Time.deltaTime * 0.5f));
				return false;
			}
		}

		[HarmonyPatch(typeof(Scoutmaster), "Update")]
		public class ScoutmasterUpdatePatch
		{
			private static bool Prefix(Scoutmaster __instance)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				if (!PhotonNetwork.IsMasterClient)
				{
					return true;
				}
				__instance.UpdateAchievement();
				__instance.DoVisuals();
				if (UnityInput.Current.GetKeyDown(Instance.configForceScoutmasterRespawn.Value))
				{
					Instance.MoveScoutmaster(Character.localCharacter);
				}
				if (Instance.isSpawning && !Instance.isFleeing)
				{
					Instance.HandleIsSpawning();
					return false;
				}
				if (!Instance.scoutmasterHasSpawned)
				{
					return false;
				}
				if (Instance.resetInputRequest)
				{
					__instance.ResetInput();
					Instance.resetInputRequest = false;
				}
				if (Instance.HandleFleeing(__instance))
				{
					return false;
				}
				if ((Object)(object)__instance.character.data.grabbedPlayer == (Object)null)
				{
					Instance.sinceLastGrabbedTimer += Time.deltaTime;
				}
				Instance.HandleTargeting(__instance);
				if ((Object)(object)__instance.currentTarget == (Object)null)
				{
					return false;
				}
				__instance.distanceToTarget = Vector3.Distance(__instance.character.Center, __instance.currentTarget.Center);
				Instance.Chase(__instance);
				return false;
			}
		}

		[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
		public class CampfireLight_RpcPatch
		{
			private static void Postfix(Campfire __instance)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					Instance.IncreaseLitFireCount();
				}
			}
		}

		[HarmonyPatch(typeof(ScoutmasterSpawner), "SpawnScoutmaster")]
		public class ScoutmasterSpawnerPatch
		{
			private static void Postfix(ScoutmasterSpawner __instance)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					Instance.scoutmaster = Instance.allScoutmasters[0];
					Instance.scoutmasterCharacter = ((Component)Instance.scoutmaster).GetComponent<Character>();
				}
			}
		}

		[HarmonyPatch(typeof(Scoutmaster), "TeleportFarAway")]
		public class ScoutmasterTeleportPatch
		{
			private static void Postfix(Scoutmaster __instance)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				if (Instance.isFleeing && PhotonNetwork.IsMasterClient)
				{
					((Component)__instance).GetComponent<PhotonView>().RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						(object)new Vector3(0f, 0f, 5000f),
						false
					});
					((Component)__instance).GetComponent<PhotonView>().RPC("StopClimbingRpc", (RpcTarget)0, new object[1] { 0f });
					__instance.discovered = null;
				}
			}
		}

		[HarmonyPatch(typeof(Bonkable), "Bonk")]
		private static class BonkPatch
		{
			private static bool Prefix(Bonkable __instance, Collision coll)
			{
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: 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_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				if (!PhotonNetwork.IsMasterClient)
				{
					return true;
				}
				Scoutmaster componentInParent = coll.gameObject.GetComponentInParent<Scoutmaster>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return true;
				}
				if (Object.op_Implicit((Object)(object)componentInParent.character) && Time.time > __instance.lastBonkedTime + __instance.bonkCooldown)
				{
					componentInParent.character.Fall(5f, 0f);
					if (componentInParent.isThrowing)
					{
						((MonoBehaviour)componentInParent).StopCoroutine("IThrow");
						componentInParent.isThrowing = false;
					}
					if ((Object)(object)componentInParent.character.data.grabbedPlayer != (Object)null)
					{
						componentInParent.character.view.RPC("RPCA_GrabUnattach", (RpcTarget)0, Array.Empty<object>());
					}
					for (int i = 0; i < __instance.bonk.Length; i++)
					{
						__instance.bonk[i].Play(((Component)__instance).transform.position);
					}
					__instance.lastBonkedTime = Time.time;
					Character character = componentInParent.character;
					Vector3 relativeVelocity = coll.relativeVelocity;
					character.AddForceAtPosition(-((Vector3)(ref relativeVelocity)).normalized * __instance.bonkForce, ((ContactPoint)(ref coll.contacts[0])).point, __instance.bonkRange);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(BananaPeel), "Update")]
		private static class UpdatePatch
		{
			private static void Postfix(BananaPeel __instance)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Invalid comparison between Unknown and I4
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				Scoutmaster val = default(Scoutmaster);
				if ((int)__instance.item.itemState == 0 && PhotonNetwork.IsMasterClient && Scoutmaster.GetPrimaryScoutmaster(ref val) && !(__instance.counter < 3f) && !(Vector3.Distance(val.character.Center, ((Component)__instance).transform.position) > 3f) && val.character.data.isGrounded && !(((Vector3)(ref val.character.data.avarageVelocity)).magnitude < 1.5f))
				{
					__instance.counter = 0f;
					((Component)__instance).GetComponent<PhotonView>().RPC("RPCA_TriggerBanana", (RpcTarget)0, new object[1] { val.character.view.ViewID });
					PhotonNetwork.Destroy(((Component)__instance).gameObject);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <WaitAndCallback>d__57 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float waitSeconds;

			public Action callback;

			public ScoutmasterRampagePlugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitAndCallback>d__57(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(waitSeconds);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					callback?.Invoke();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static ScoutmasterRampagePlugin Instance;

		private ConfigEntry<float> configInitialSpawn;

		private ConfigEntry<float> configFire2Delay;

		private ConfigEntry<float> configFire3Delay;

		private ConfigEntry<float> configFire4Delay;

		private ConfigEntry<float> configFire5Delay;

		private ConfigEntry<bool> configEnableLogs;

		private ConfigEntry<KeyCode> configForceScoutmasterRespawn;

		private ConfigEntry<bool> configDisableScreenEffect;

		private ConfigEntry<float> configScreenEffectPower;

		private float[] respawnDelays;

		private int litFireCount = -1;

		private float respawnEndTime = -1f;

		private const string LogPrefix = "[Scoutmasters Rampage] ";

		public float horizontalTolerance = 2f;

		public float lingerTime = 3f;

		private float lingerTimer = 0f;

		private float minVerticalDistance = 10f;

		private float minTeleportDistanceToTarget = 30f;

		private float maxTeleportDistanceToTarget = 50f;

		private float maxTeleportHeightDistanceToTarget = 15f;

		private float targetingTime = 3f;

		private float targetingTimer = 0f;

		private float sinceLastGrabbedMinTime = 3f;

		private float sinceLastGrabbedTimer = 0f;

		private float fleeTime = 4f;

		private float fleeTimer = 0f;

		private bool scoutmasterHasSpawned = false;

		private bool resetInputRequest = false;

		public const float FALLTIME = 5f;

		private bool isSpawning = false;

		private Scoutmaster scoutmaster;

		private Character scoutmasterCharacter;

		private bool isFleeing;

		private List<Scoutmaster> allScoutmasters = (List<Scoutmaster>)AccessTools.Field(typeof(Scoutmaster), "AllScoutmasters").GetValue(null);

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			new Harmony("tony4twentys.scoutmastersrampage").PatchAll();
			LogInfo("Plugin initialized and waiting for gameplay scene.");
			SetupConfig();
		}

		private void SetupConfig()
		{
			configForceScoutmasterRespawn = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ForceScoutmasterRespawn", (KeyCode)282, "Keybinding to force respawn the scoutmaster in case he gets stuck or bugs out.");
			configDisableScreenEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableScreenEffect", false, "Turns the scoutmaster screen effect off if set to true.");
			configScreenEffectPower = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScreenEffectPower", 0.5f, "How much the screen effect is reduced (0 = off, 0.5 = half, 1 = normal)");
			configInitialSpawn = ((BaseUnityPlugin)this).Config.Bind<float>("Delays", "InitialSpawn", 300f, "Delay (in seconds) after expedition starts before the Scoutmaster spawns.");
			configFire2Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Delays", "Fire2Respawn", 600f, "Delay (in seconds) after fire 2 is lit before Scoutmaster respawns.");
			configFire3Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Delays", "Fire3Respawn", 900f, "Delay (in seconds) after fire 3 is lit before Scoutmaster respawns.");
			configFire4Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Delays", "Fire4Respawn", 420f, "Delay (in seconds) after fire 4 is lit before Scoutmaster respawns.");
			configFire5Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Delays", "Fire5Respawn", 900f, "Delay (in seconds) after fire 5 is lit before Scoutmaster respawns.");
			configEnableLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableLogs", true, "Enable detailed plugin logs");
			respawnDelays = new float[5] { configInitialSpawn.Value, configFire2Delay.Value, configFire3Delay.Value, configFire4Delay.Value, configFire5Delay.Value };
		}

		private void WaitForValidCharacterAndSpawn()
		{
			LogInfo("Checking for valid player to spawn behind.");
			Character val = null;
			float num = float.MaxValue;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (!allCharacter.isBot && !allCharacter.data.dead && !allCharacter.data.fullyPassedOut)
				{
					float y = allCharacter.data.groundPos.y;
					if (y < num)
					{
						num = y;
						val = allCharacter;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				LogInfo("Valid player found — proceeding with Scoutmaster spawn.");
				MoveScoutmaster(val);
				isSpawning = false;
			}
			LogWarning("No valid players found yet — waiting 1s...");
			Instance.respawnEndTime += 3f;
		}

		private void IncreaseLitFireCount()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Instance.litFireCount++;
			LogInfo($"Fire lit. Count: {Instance.litFireCount}");
			if (litFireCount < respawnDelays.Length)
			{
				if (litFireCount == 0)
				{
					LogInfo("Starting initial spawn timer (fire 1).");
				}
				else
				{
					LogInfo($"Despawning Scoutmaster and setting respawn timer from fire {litFireCount + 1}.");
					DespawnScoutmaster();
				}
				respawnEndTime = respawnDelays[litFireCount];
				LogInfo($"Setting respawnEndTime: {respawnEndTime}. Starting spawn delay");
				isSpawning = true;
			}
		}

		private void MoveScoutmaster(Character character)
		{
			//IL_0034: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)scoutmaster == (Object)null || (Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"Scoutmaster or character does not exist");
				return;
			}
			Vector3 val = character.data.groundPos - ((Component)character).transform.forward * 10f;
			object arg = val;
			Player owner = character.refs.view.Owner;
			LogInfo(string.Format("Moving Scoutmaster to {0} behind {1}", arg, ((owner != null) ? owner.NickName : null) ?? "Unknown"));
			PhotonView component = ((Component)scoutmaster).GetComponent<PhotonView>();
			if ((Object)(object)scoutmaster.character.data.grabbedPlayer != (Object)null)
			{
				if (scoutmaster.isThrowing)
				{
					((MonoBehaviour)scoutmaster).StopCoroutine("IThrow");
					scoutmaster.isThrowing = false;
				}
				scoutmaster.character.view.RPC("RPCA_GrabUnattach", (RpcTarget)0, Array.Empty<object>());
				scoutmaster.character.data.isReaching = false;
				scoutmaster.character.input.useSecondaryIsPressed = false;
			}
			component.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, false });
			component.RPC("RPCA_SetCurrentTarget", (RpcTarget)0, new object[2]
			{
				((MonoBehaviourPun)character).photonView.ViewID,
				5f
			});
			scoutmasterHasSpawned = true;
			Instance.resetInputRequest = true;
		}

		public void Chase(Scoutmaster scoutmaster)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			HandleClimbing(scoutmaster, scoutmaster.currentTarget.Center);
			if (!HandleGrabbedPlayer(scoutmaster))
			{
				scoutmaster.LookAt(scoutmaster.currentTarget.Head);
				float num = Vector3.Distance(scoutmaster.character.Center, scoutmaster.currentTarget.Center);
				HandleWalkTowards(scoutmaster, scoutmaster.currentTarget.Head, 1f);
				scoutmaster.character.input.sprintIsPressed = num > 15f;
				if (Vector3.Distance(scoutmaster.character.Center, scoutmaster.currentTarget.Center) < 3f && scoutmaster.character.data.sinceClimb > 1f && scoutmaster.character.data.isGrounded && scoutmaster.character.data.fallSeconds <= 0f)
				{
					scoutmaster.character.input.useSecondaryIsPressed = true;
					Instance.resetInputRequest = true;
				}
			}
		}

		private void HandleWalkTowards(Scoutmaster scoutmaster, Vector3 targetPos, float mult)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_008d: 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)
			//IL_00c2: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			float num = HelperFunctions.FlatDistance(scoutmaster.character.Center, targetPos);
			if (num <= 15f)
			{
				scoutmaster.character.refs.movement.movementModifier = 1.2f;
			}
			else
			{
				scoutmaster.character.refs.movement.movementModifier = 1f;
			}
			if (IsTargetHoldingLitFaerieLanternCondition(scoutmaster) && num < 20f)
			{
				mult = 0f - mult;
			}
			scoutmaster.character.input.movementInput = new Vector2(0f, mult);
			TryToStartWallClimb(scoutmaster.character);
			if (!scoutmaster.character.data.isClimbing)
			{
				RaycastHit val = HelperFunctions.LineCheck(scoutmaster.character.Center, scoutmaster.character.Center + Vector3.down * 3f, (LayerType)1, 0f, (QueryTriggerInteraction)1);
				if (!((Object)(object)((RaycastHit)(ref val)).transform == (Object)null))
				{
				}
			}
			HandleStuckAboveOrBelowTarget(scoutmaster);
		}

		private void HandleStuckAboveOrBelowTarget(Scoutmaster scoutmaster)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(scoutmaster.character.Center.x, scoutmaster.character.Center.z);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(scoutmaster.currentTarget.Center.x, scoutmaster.currentTarget.Center.z);
			float num = Vector2.Distance(val, val2);
			bool flag = num <= horizontalTolerance;
			float num2 = Mathf.Abs(scoutmaster.character.Center.y - scoutmaster.currentTarget.Center.y);
			bool flag2 = num2 >= minVerticalDistance;
			if (flag && flag2)
			{
				lingerTimer += Time.deltaTime;
				if (lingerTimer >= lingerTime)
				{
					TryTeleportNearbyTarget(scoutmaster);
					lingerTimer = 0f;
				}
			}
			else
			{
				lingerTimer = 0f;
			}
		}

		private void TryTeleportNearbyTarget(Scoutmaster scoutmaster)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			//IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			int num = 50;
			while (num > 0)
			{
				num--;
				Vector3 onUnitSphere = Random.onUnitSphere;
				Vector3 val = scoutmaster.currentTarget.Center + Vector3.up * 500f + onUnitSphere * 95f;
				Vector3 val2 = Vector3.down;
				if (num < 25)
				{
					val = scoutmaster.currentTarget.Center + Vector3.up;
					val2 = Random.onUnitSphere;
				}
				RaycastHit val3 = HelperFunctions.LineCheck(val, val + val2 * 1000f, (LayerType)1, 0f, (QueryTriggerInteraction)1);
				if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val3)).transform))
				{
					float num2 = Vector3.Distance(((RaycastHit)(ref val3)).point, scoutmaster.currentTarget.Center);
					float num3 = Mathf.Abs(((RaycastHit)(ref val3)).point.y - scoutmaster.currentTarget.Center.y);
					if (!scoutmaster.AnyoneCanSeePos(((RaycastHit)(ref val3)).point + Vector3.up) && num2 >= minTeleportDistanceToTarget && num2 <= maxTeleportDistanceToTarget && num3 <= maxTeleportHeightDistanceToTarget)
					{
						scoutmaster.character.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
						{
							((RaycastHit)(ref val3)).point + Vector3.up,
							false
						});
						scoutmaster.character.view.RPC("StopClimbingRpc", (RpcTarget)0, new object[1] { 0f });
						break;
					}
				}
			}
		}

		private void HandleClimbing(Scoutmaster scoutmaster, Vector3 target)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (!scoutmaster.character.data.isClimbing)
			{
				return;
			}
			scoutmaster.ClimbTowards(target, 1f);
			if (target.y < scoutmaster.character.Center.y)
			{
				RaycastHit val = HelperFunctions.LineCheck(scoutmaster.character.Center, target, (LayerType)1, 0f, (QueryTriggerInteraction)1);
				if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).transform))
				{
					scoutmaster.character.refs.climbing.StopClimbing();
				}
			}
		}

		private bool HandleGrabbedPlayer(Scoutmaster scoutmaster)
		{
			if ((Object)(object)scoutmaster.character.data.grabbedPlayer != (Object)null)
			{
				scoutmaster.HoldPlayer();
				Instance.resetInputRequest = true;
				return true;
			}
			return false;
		}

		private void HandleIsSpawning()
		{
			if (Instance.respawnEndTime > 0f)
			{
				Instance.respawnEndTime -= Time.deltaTime;
			}
			else
			{
				Instance.WaitForValidCharacterAndSpawn();
			}
		}

		private bool HandleFleeing(Scoutmaster __instance)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_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_00fd: 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)
			if (Instance.isFleeing)
			{
				fleeTimer += Time.deltaTime;
				if (fleeTimer >= fleeTime)
				{
					__instance.TeleportFarAway();
					fleeTimer = 0f;
					scoutmasterHasSpawned = false;
					Instance.isFleeing = false;
					return true;
				}
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f, 0f, 0f);
				if ((Object)(object)__instance.currentTarget != (Object)null)
				{
					Vector3 val2 = __instance.character.Center - __instance.currentTarget.Center;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					val = __instance.character.Center + normalized * 10f;
				}
				if (__instance.character.data.isClimbing)
				{
					Instance.HandleClimbing(__instance, val);
					return true;
				}
				HandleWalkTowards(__instance, val, 1f);
				__instance.character.input.sprintIsPressed = true;
				return true;
			}
			return false;
		}

		private void HandleTargeting(Scoutmaster scoutmaster)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			targetingTimer += Time.deltaTime;
			if (targetingTimer < targetingTime)
			{
				return;
			}
			List<Character> allCharacters = Character.AllCharacters;
			Character val = null;
			float num = float.MaxValue;
			foreach (Character item in allCharacters)
			{
				if (!item.isBot && !item.data.dead && !item.data.fullyPassedOut && !item.data.passedOut && !item.data.fullyConscious)
				{
					float num2 = Vector3.Distance(item.Center, scoutmaster.character.Center);
					if (num2 < num)
					{
						val = item;
						num = num2;
					}
				}
			}
			if ((Object)(object)val != (Object)null && (Object)(object)scoutmaster.currentTarget != (Object)(object)val && !scoutmaster.isThrowing)
			{
				scoutmaster.RPCA_SetCurrentTarget(val.view.ViewID, 0f);
			}
			targetingTimer = 0f;
		}

		public bool CanClimb(Character character)
		{
			if (character.data.sinceClimb < 0.2f)
			{
				return false;
			}
			if (character.data.isRopeClimbing)
			{
				return false;
			}
			if (character.data.isVineClimbing)
			{
				return false;
			}
			return true;
		}

		private void TryToStartWallClimb(Character character)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			if (!CanClimb(character))
			{
				return;
			}
			Vector3 center = character.Center;
			Vector3 normalized = ((Vector3)(ref character.data.lookDirection_Flat)).normalized;
			Vector3 val = center + normalized * 1.25f;
			RaycastHit val2 = HelperFunctions.LineCheck(center, val, (LayerType)1, 0f, (QueryTriggerInteraction)1);
			if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform))
			{
				val2 = HelperFunctions.LineCheck(center, val, (LayerType)1, 0.05f, (QueryTriggerInteraction)1);
			}
			if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform))
			{
				val2 = HelperFunctions.LineCheck(center, val, (LayerType)1, 0.1f, (QueryTriggerInteraction)1);
			}
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform))
			{
				bool flag = !character.refs.climbing.AcceptableGrabAngle(((RaycastHit)(ref val2)).normal, ((RaycastHit)(ref val2)).collider);
				bool flag2 = !(character.refs.climbing.sinceLastClimbStarted > 1f) && character.OutOfStamina();
				if (!(flag || flag2))
				{
					character.data.sinceCanClimb = 0f;
					character.refs.climbing.sinceLastClimbStarted = 0f;
					character.view.RPC("StartClimbRpc", (RpcTarget)0, new object[2]
					{
						((RaycastHit)(ref val2)).point,
						((RaycastHit)(ref val2)).normal
					});
				}
			}
		}

		public bool IsTargetHoldingLitFaerieLanternCondition(Scoutmaster scoutmaster)
		{
			if ((Object)(object)scoutmaster.currentTarget == (Object)null)
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)scoutmaster.currentTarget.data.currentItem) && scoutmaster.currentTarget.data.currentItem.itemID == 43 && scoutmaster.currentTarget.data.currentItem.GetData<BoolItemData>((DataEntryKey)3).Value)
			{
				return true;
			}
			return false;
		}

		[IteratorStateMachine(typeof(<WaitAndCallback>d__57))]
		public IEnumerator WaitAndCallback(float waitSeconds, Action callback)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitAndCallback>d__57(0)
			{
				<>4__this = this,
				waitSeconds = waitSeconds,
				callback = callback
			};
		}

		private void DespawnScoutmaster()
		{
			if ((Object)(object)scoutmaster != (Object)null)
			{
				scoutmaster.currentTarget = null;
				((Component)scoutmaster).GetComponent<PhotonView>().RPC("RPCA_SetCurrentTarget", (RpcTarget)0, new object[2] { -1, 0f });
				isFleeing = true;
			}
		}

		private void LogInfo(string msg)
		{
			ConfigEntry<bool> obj = configEnableLogs;
			if (obj == null || obj.Value)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[Scoutmasters Rampage] " + msg));
			}
		}

		private void LogWarning(string msg)
		{
			ConfigEntry<bool> obj = configEnableLogs;
			if (obj == null || obj.Value)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[Scoutmasters Rampage] " + msg));
			}
		}
	}
}