Decompiled source of Hurry Up v1.0.1

BepInEx/plugins/hurryup.dll

Decompiled 2 weeks ago
using System;
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;
using Zorro.Core.Serizalization;

[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]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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)
			{
				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)
		{
			__instance.initialWaitTime -= Plugin.lavaAdditionalWaitTime.Value;
		}
	}
	[HarmonyPatch(typeof(LavaRising), "Update")]
	internal static class LavaSpeedPatch
	{
		internal static void Postfix(LavaRising __instance)
		{
			if (__instance.started && !__instance.ended)
			{
				__instance.timeTraveled += (__instance.travelTime / Plugin.lavaRiseTime.Value - 1f) * Time.deltaTime;
			}
		}
	}
	[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 < 15f && !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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00e6: Expected I4, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			if (!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)
			{
				return;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (allCharacter.data.isInFog)
				{
					if (allCharacter.data.passedOut && Plugin.instantFogGiveUp.Value && !allCharacter.data.dead)
					{
						allCharacter.DieInstantly();
						break;
					}
					allCharacter.refs.afflictions.AddStatus((STATUSTYPE)2, 0.01f * (Plugin.fogDamageMultiplier.Value - 1f), false, true);
					StatusSyncData val3 = default(StatusSyncData);
					val3.statusList = new List<float>(allCharacter.refs.afflictions.currentStatuses);
					byte[] array = IBinarySerializable.ToManagedArray<StatusSyncData>(val3);
					((MonoBehaviourPun)allCharacter.refs.afflictions).photonView.RPC("SyncStatusesRPC", (RpcTarget)5, new object[1] { array });
				}
			}
			procXtraCold = 0f;
		}
	}
	internal class fogMechanicHandler : MonoBehaviour
	{
		public List<Player> playersGivenChance = new List<Player>();

		public float timer = 0f;

		public void Update()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			if (Plugin.fogMechanicMotivation.Value)
			{
				float num = 0.04f;
				timer += Time.deltaTime;
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (allCharacter.data.isInFog && timer > Plugin.motivationInterval.Value && allCharacter.refs.afflictions.statusSum < 0.9f - Plugin.motivationPenalty.Value * num)
					{
						Affliction_FasterBoi val = (Affliction_FasterBoi)Affliction.CreateBlankAffliction((AfflictionType)2);
						((Affliction)val).totalTime = Plugin.motivationLength.Value;
						val.cachedDrowsy = 0f;
						val.climbSpeedMod = Plugin.motivationSpeedMult.Value - 1f;
						val.moveSpeedMod = Plugin.motivationSpeedMult.Value - 1f;
						allCharacter.refs.afflictions.AddAffliction((Affliction)(object)val, false);
						allCharacter.refs.afflictions.AddStatus(Plugin.motivationPenaltyType.Value, Plugin.motivationPenalty.Value * num, false, true);
						PushAllTheStuff(pushAfflictions: true, Plugin.motivationPenalty.Value != 0f, allCharacter);
					}
				}
				if (timer > Plugin.motivationInterval.Value)
				{
					timer = 0f;
				}
			}
			if (!Plugin.fogMechanicFinalShot.Value)
			{
				return;
			}
			float num2 = 0.04f;
			foreach (Character allCharacter2 in Character.AllCharacters)
			{
				if (allCharacter2.data.isInFog && allCharacter2.refs.afflictions.statusSum > 0.9f - Plugin.finalShotPenalty.Value * num2 && !playersGivenChance.Contains(allCharacter2.player) && allCharacter2.refs.afflictions.statusSum + Plugin.finalShotPenalty.Value * num2 < 1f)
				{
					allCharacter2.refs.afflictions.AddStatus(Plugin.finalShotPenaltyType.Value, Plugin.finalShotPenalty.Value * num2, false, true);
					Affliction_FasterBoi val2 = (Affliction_FasterBoi)Affliction.CreateBlankAffliction((AfflictionType)2);
					((Affliction)val2).totalTime = Plugin.finalShotLength.Value;
					val2.cachedDrowsy = 0f;
					val2.climbSpeedMod = Plugin.finalEnergyDrinkPower.Value - 1f;
					val2.moveSpeedMod = Plugin.finalEnergyDrinkPower.Value - 1f;
					allCharacter2.refs.afflictions.AddAffliction((Affliction)(object)val2, false);
					Affliction val3 = Affliction.CreateBlankAffliction((AfflictionType)1);
					val3.totalTime = Plugin.finalShotLength.Value;
					allCharacter2.refs.afflictions.AddAffliction(val3, false);
					Affliction val4 = Affliction.CreateBlankAffliction((AfflictionType)16);
					val4.totalTime = Plugin.finalShotLength.Value;
					allCharacter2.refs.afflictions.AddAffliction(val4, false);
					PushAllTheStuff(pushAfflictions: true, Plugin.finalShotPenalty.Value != 0f, allCharacter2);
					playersGivenChance.Add(allCharacter2.player);
				}
			}
		}

		public void PushAllTheStuff(bool pushAfflictions, bool pushStatuses, Character c)
		{
			//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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (pushAfflictions)
			{
				AfflictionSyncData val = default(AfflictionSyncData);
				val.afflictions = new List<Affliction>(c.refs.afflictions.afflictionList);
				byte[] array = IBinarySerializable.ToManagedArray<AfflictionSyncData>(val);
				((MonoBehaviourPun)c).photonView.RPC("SyncAfflictionsRPC", (RpcTarget)5, new object[1] { array });
			}
			if (pushStatuses)
			{
				StatusSyncData val2 = default(StatusSyncData);
				val2.statusList = new List<float>(c.refs.afflictions.currentStatuses);
				byte[] array2 = IBinarySerializable.ToManagedArray<StatusSyncData>(val2);
				((MonoBehaviourPun)c.refs.afflictions).photonView.RPC("SyncStatusesRPC", (RpcTarget)5, new object[1] { array2 });
			}
		}
	}
	[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> finalShotPenalty;

		public static ConfigEntry<float> finalShotLength;

		public static ConfigEntry<float> finalEnergyDrinkPower;

		public static ConfigEntry<STATUSTYPE> finalShotPenaltyType;

		public static ConfigEntry<STATUSTYPE> motivationPenaltyType;

		public static ConfigEntry<float> motivationPenalty;

		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> lavaAdditionalWaitTime;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: 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 (Can be laggy in big lobbies, set value to 1 to disable)", 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");
			motivationInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Motivation Interval", 3f, "The interval at which the energy drink effect is applied");
			motivationLength = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Motivation Length", 3f, "How long the effect lasts");
			motivationSpeedMult = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Motivation Speed Multiplier", 2f, "How much the players speed is multiplied by when motivated");
			motivationPenaltyType = ((BaseUnityPlugin)this).Config.Bind<STATUSTYPE>("Fog Mechanic", "Motivation Penalty Type", (STATUSTYPE)0, "The type of status a player gets from motivation activating");
			motivationPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Motivation Penalty Amount", 1f, "How much status a player gains from motivation activating");
			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");
			finalShotLength = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Final Shot Length", 15f, "How long the effects last");
			finalEnergyDrinkPower = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Final Shot Speed Multiplier", 2f, "How much speed multiplier the player gets from the energy drink effect");
			finalShotPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Fog Mechanic", "Final Shot Penalty Amount", 1f, "How much status a player gains from activating a final shot");
			finalShotPenaltyType = ((BaseUnityPlugin)this).Config.Bind<STATUSTYPE>("Fog Mechanic", "Final Shot Penalty Type", (STATUSTYPE)5, "The type of status a player gets from final shot activating");
			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 Time", 1200f, "How many seconds it takes for the lava to reach the top");
			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");
			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)
		{
		}
	}
}