Decompiled source of Hurry Up v1.0.4

BepInEx/plugins/hurryup.dll

Decompiled a week 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using Photon.Pun;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("hurryup")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("hurryup")]
[assembly: AssemblyTitle("hurryup")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace hurryup
{
	[HarmonyPatch(typeof(CharacterAfflictions), "Awake")]
	internal static class fogMechanics
	{
		public static fogMechanicHandler fMechHandler;

		public static playersAtCampfireCheck currentCampfireChecker;

		internal static void Postfix(CharacterAfflictions __instance)
		{
			if (PhotonNetwork.IsMasterClient && __instance.character.IsLocal && !__instance.m_inAirport)
			{
				fMechHandler = ((Component)__instance.character).gameObject.AddComponent<fogMechanicHandler>();
				((Component)Singleton<OrbFogHandler>.Instance).gameObject.AddComponent<customFogHandler>();
			}
		}
	}
	[HarmonyPatch(typeof(LavaRising), "Awake")]
	internal static class setWaitTime
	{
		internal static void Prefix(LavaRising __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if ((int)__instance.risingFieldType == 0)
			{
				__instance.initialWaitTime -= Plugin.lavaAdditionalWaitTime.Value;
			}
			else if ((int)__instance.risingFieldType == 1)
			{
				__instance.initialWaitTime -= Plugin.gloomAdditionalWaitTime.Value;
			}
		}
	}
	[HarmonyPatch(typeof(LavaRising), "Update")]
	internal static class LavaSpeedPatch
	{
		internal static void Postfix(LavaRising __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Invalid comparison between Unknown and I4
			if (__instance.started && !__instance.ended)
			{
				if ((int)__instance.risingFieldType == 0)
				{
					__instance.timeTraveled += Time.deltaTime * (Plugin.lavaRiseTime.Value - 1f);
				}
				else if ((int)__instance.risingFieldType == 1)
				{
					__instance.timeTraveled += Time.deltaTime * (Plugin.gloomRiseTime.Value - 1f);
				}
				else
				{
					__instance.timeTraveled += Time.deltaTime * (Plugin.RisingGhostsSpeed.Value - 1f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
	internal static class resetLastShot
	{
		internal static void Postfix()
		{
			if ((Object)(object)fogMechanics.fMechHandler != (Object)null)
			{
				fogMechanics.fMechHandler.playersGivenChance.Clear();
			}
		}
	}
	[HarmonyPatch(typeof(Campfire), "Awake")]
	internal static class addChecksForCampfire
	{
		internal static void Postfix(Campfire __instance)
		{
			((Component)__instance).gameObject.AddComponent<playersAtCampfireCheck>().campfire = __instance;
		}
	}
	internal class playersAtCampfireCheck : MonoBehaviour
	{
		public List<Character> charactersNear = new List<Character>();

		public Campfire campfire;

		internal void Update()
		{
			//IL_006a: 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)
			if (campfire.Lit)
			{
				return;
			}
			charactersNear.Clear();
			fogMechanics.currentCampfireChecker = this;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (!((Object)(object)allCharacter == (Object)null) && !((MonoBehaviourPun)allCharacter).photonView.Owner.IsInactive)
				{
					float num = Vector3.Distance(((Component)this).transform.position, allCharacter.Center);
					if (num < 20f && !allCharacter.data.dead)
					{
						charactersNear.Add(allCharacter);
					}
				}
			}
		}
	}
	internal class customFogHandler : MonoBehaviour
	{
		public float procXtraCold = 0f;

		internal void Start()
		{
			FogSphereOrigin[] origins = Singleton<OrbFogHandler>.Instance.origins;
			foreach (FogSphereOrigin val in origins)
			{
				val.size -= Plugin.additionalFogSize.Value;
			}
			OrbFogHandler instance = Singleton<OrbFogHandler>.Instance;
			instance.maxWaitTime -= Plugin.additionalWaitTime.Value;
		}

		internal void Update()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected I4, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			if (Singleton<MapHandler>.Instance.currentSegment >= 3 || !Singleton<OrbFogHandler>.Instance.isMoving)
			{
				return;
			}
			procXtraCold += Time.deltaTime;
			OrbFogHandler instance = Singleton<OrbFogHandler>.Instance;
			instance.currentSize -= Plugin.additionalFogSpeed.Value * Time.deltaTime;
			if ((Object)(object)fogMechanics.currentCampfireChecker != (Object)null)
			{
				OrbFogHandler instance2 = Singleton<OrbFogHandler>.Instance;
				instance2.currentSize -= Plugin.additionalFogSpeedPerPlayer.Value * (float)fogMechanics.currentCampfireChecker.charactersNear.Count * Time.deltaTime;
			}
			float num = (Plugin.additionalFogSpeedPerPlayer.Value * (float)fogMechanics.currentCampfireChecker.charactersNear.Count + Plugin.additionalFogSpeed.Value + Singleton<OrbFogHandler>.Instance.speed) * Time.deltaTime;
			Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
			Segment val = currentSegment;
			Segment val2 = val;
			switch ((int)val2)
			{
			case 0:
			{
				OrbFogHandler instance5 = Singleton<OrbFogHandler>.Instance;
				instance5.currentSize -= num * (Plugin.fogSpeedMultiplierBeach.Value - 1f);
				break;
			}
			case 1:
			{
				OrbFogHandler instance4 = Singleton<OrbFogHandler>.Instance;
				instance4.currentSize -= num * (Plugin.fogSpeedMultiplierTropics.Value - 1f);
				break;
			}
			case 2:
			{
				OrbFogHandler instance3 = Singleton<OrbFogHandler>.Instance;
				instance3.currentSize -= num * (Plugin.fogSpeedMultiplierAlpine.Value - 1f);
				break;
			}
			}
			if (!(procXtraCold > 1f) || (Plugin.fogDamageMultiplier.Value == 1f && !Plugin.instantFogGiveUp.Value))
			{
				return;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (Vector3.Distance(Singleton<OrbFogHandler>.Instance.sphere.fogPoint, allCharacter.Center) > Singleton<OrbFogHandler>.Instance.currentSize)
				{
					float[] array = new float[CharacterAfflictions.NumStatusTypes];
					array[2] = 0.0105f * Plugin.fogDamageMultiplier.Value;
					((MonoBehaviourPun)allCharacter.refs.afflictions).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array });
					if (allCharacter.data.passedOut && Plugin.instantFogGiveUp.Value && !allCharacter.data.dead)
					{
						allCharacter.DieInstantly();
						break;
					}
				}
			}
			procXtraCold = 0f;
		}
	}
	internal class fogMechanicHandler : MonoBehaviour
	{
		public List<Player> playersGivenChance = new List<Player>();

		public float timer = 0f;

		public void Update()
		{
			//IL_0051: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if (Singleton<MapHandler>.Instance.currentSegment >= 3)
			{
				return;
			}
			if (Plugin.fogMechanicMotivation.Value)
			{
				Affliction val = default(Affliction);
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (Vector3.Distance(Singleton<OrbFogHandler>.Instance.sphere.fogPoint, allCharacter.Center) > Singleton<OrbFogHandler>.Instance.currentSize && !allCharacter.refs.afflictions.HasAfflictionType((AfflictionType)2, ref val) && !allCharacter.data.dead)
					{
						Item component = PhotonNetwork.Instantiate("0_Items/Energy Drink", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
						component.view.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
						allCharacter.FeedItem(component);
						if ((Object)(object)component != (Object)null)
						{
							PhotonNetwork.Destroy(((Component)component).gameObject);
						}
					}
				}
			}
			if (!Plugin.fogMechanicFinalShot.Value)
			{
				return;
			}
			foreach (Character allCharacter2 in Character.AllCharacters)
			{
				if (Vector3.Distance(Singleton<OrbFogHandler>.Instance.sphere.fogPoint, allCharacter2.Center) > Singleton<OrbFogHandler>.Instance.currentSize && allCharacter2.refs.afflictions.statusSum > 0.9f && !playersGivenChance.Contains(allCharacter2.player) && !allCharacter2.data.dead)
				{
					((MonoBehaviour)this).StartCoroutine((IEnumerator)ClearStatusEnoughForClimb(allCharacter2));
					playersGivenChance.Add(allCharacter2.player);
				}
			}
		}

		public IEnumerator<WaitForSeconds> ClearStatusEnoughForClimb(Character c)
		{
			yield return new WaitForSeconds(4f);
			if (!(c.refs.afflictions.statusSum >= 1f))
			{
				yield break;
			}
			float amoutNeededForClimb = -0.8f + c.refs.afflictions.statusSum;
			int[] favoredOrder = new int[7] { 1, 6, 2, 8, 3, 10, 0 };
			float[] amountPending = new float[CharacterAfflictions.NumStatusTypes];
			float pendingTotal = 0f;
			int[] array = favoredOrder;
			foreach (int i2 in array)
			{
				float amountTheyGot = c.refs.afflictions.GetCurrentStatus((STATUSTYPE)i2);
				while (0f - amountPending[i2] < amountTheyGot && pendingTotal < amoutNeededForClimb)
				{
					amountPending[i2] -= 0.025f;
					pendingTotal += 0.025f;
				}
				if (pendingTotal >= amoutNeededForClimb)
				{
					break;
				}
			}
			c.refs.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { amountPending });
			c.view.RPC("RPCA_UnFall", (RpcTarget)0, Array.Empty<object>());
			Item it = PhotonNetwork.Instantiate("0_Items/FortifiedMilk", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
			c.FeedItem(it);
			if ((Object)(object)it != (Object)null)
			{
				PhotonNetwork.Destroy(((Component)it).gameObject);
			}
			Item it2 = PhotonNetwork.Instantiate("0_Items/Energy Drink", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
			it2.view.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
			c.FeedItem(it2);
			if ((Object)(object)it2 != (Object)null)
			{
				PhotonNetwork.Destroy(((Component)it2).gameObject);
			}
			Item it3 = PhotonNetwork.Instantiate("0_Items/Lollipop", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
			it3.view.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
			c.FeedItem(it3);
			if ((Object)(object)it3 != (Object)null)
			{
				PhotonNetwork.Destroy(((Component)it3).gameObject);
			}
			for (int j = 0; j < 10; j++)
			{
				c.view.RPC("RPCA_UnFall", (RpcTarget)0, Array.Empty<object>());
				yield return new WaitForSeconds(1f);
			}
		}
	}
	[BepInPlugin("hurryupmod", "hurry up", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<float> additionalFogSpeed;

		public static ConfigEntry<float> additionalWaitTime;

		public static ConfigEntry<float> additionalFogSize;

		public static ConfigEntry<float> fogDamageMultiplier;

		public static ConfigEntry<float> additionalFogSpeedPerPlayer;

		public static ConfigEntry<bool> instantFogGiveUp;

		public static ConfigEntry<bool> calderaFog;

		public static ConfigEntry<bool> fogMechanicMotivation;

		public static ConfigEntry<float> motivationInterval;

		public static ConfigEntry<float> motivationSpeedMult;

		public static ConfigEntry<float> finalShotLength;

		public static ConfigEntry<float> finalEnergyDrinkPower;

		public static ConfigEntry<float> motivationLength;

		public static ConfigEntry<bool> fogMechanicFinalShot;

		public static ConfigEntry<float> fogSpeedMultiplierBeach;

		public static ConfigEntry<float> fogSpeedMultiplierTropics;

		public static ConfigEntry<float> fogSpeedMultiplierAlpine;

		public static ConfigEntry<float> lavaRiseTime;

		public static ConfigEntry<float> gloomRiseTime;

		public static ConfigEntry<float> RisingGhostsSpeed;

		public static ConfigEntry<float> lavaAdditionalWaitTime;

		public static ConfigEntry<float> gloomAdditionalWaitTime;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			additionalFogSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Options", "Additional Fog Speed (base fog speed is 0.4f)", 0f, "How much additional speed the fog has");
			additionalWaitTime = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Options", "Reduce Wait Time (base is 1000)", 0f, "How much less time the fog waits before moving, if players havent moved on");
			additionalFogSize = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Options", "Reduce Fog Size (base is 650)", 0f, "How much less starting size the fog has");
			fogDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Options", "Fog Damage Multiplier", 1f, "How much fog damage is multiplied by");
			additionalFogSpeedPerPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Options", "Additional Fog Speed Per Player At Campfire", 0f, "How much speed is added for each player at the campfire");
			instantFogGiveUp = ((BaseUnityPlugin)this).Config.Bind<bool>("Fog Options", "Instant Fog Give Up", false, "If this is true any passed out players will instanly die in the fog");
			fogMechanicMotivation = ((BaseUnityPlugin)this).Config.Bind<bool>("Fog Mechanic", "Motivating Fog", false, "If set to true, fog will periodically give the energy drink effect");
			fogMechanicFinalShot = ((BaseUnityPlugin)this).Config.Bind<bool>("Fog Mechanic", "Final Shot", false, "Once a player is about to die in the fog they are given the effect of a lollipop, energy drink, and fortified milk, once per segment");
			fogSpeedMultiplierAlpine = ((BaseUnityPlugin)this).Config.Bind<float>("Biome Fog", "Alpine Fog Speed Multiplier", 1f, "How much the fog speed is multiplied by at the alpine");
			fogSpeedMultiplierBeach = ((BaseUnityPlugin)this).Config.Bind<float>("Biome Fog", "Beach Fog Speed Multiplier", 1f, "How much the fog speed is multiplied by at the beach");
			fogSpeedMultiplierTropics = ((BaseUnityPlugin)this).Config.Bind<float>("Biome Fog", "Tropics Fog Speed Multiplier", 1f, "How much the fog speed is multiplied by at the tropics");
			lavaRiseTime = ((BaseUnityPlugin)this).Config.Bind<float>("Rising Lava", "Lava Rise Speed Multiplier", 1f, "How much faster the lava is");
			gloomRiseTime = ((BaseUnityPlugin)this).Config.Bind<float>("Rising Lava", "Gloom Rise Speed Multiplier", 1f, "How much faster the gloom is");
			RisingGhostsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Rising Lava", "Souls Rise Speed Multiplier (Nadir)", 1f, "How much faster the souls are");
			lavaAdditionalWaitTime = ((BaseUnityPlugin)this).Config.Bind<float>("Rising Lava", "Lava Reduce Wait Time (base is 180)", 0f, "How much less time the lava waits before rising");
			gloomAdditionalWaitTime = ((BaseUnityPlugin)this).Config.Bind<float>("Rising Lava", "Gloom Reduce Wait Time (base is 150)", 0f, "How much less time the gloom waits before rising");
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin hurry up is loaded!");
			Harmony val = new Harmony("hurryup");
			val.PatchAll();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}