Decompiled source of PeakPocalypse v0.1.0

plugins/com.github.Evanovah.PeakPocalypse.dll

Decompiled 9 hours ago
using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.Evanovah.PeakPocalypse")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.Evanovah.PeakPocalypse")]
[assembly: AssemblyTitle("PeakPocalypse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 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 PeakPocalypse
{
	[BepInPlugin("com.github.Evanovah.PeakPocalypse", "PeakPocalypse", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private string _statusMessage = "";

		private float _statusTimer;

		private float _zombieSpawnTimer = 120f;

		public const string Id = "com.github.Evanovah.PeakPocalypse";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PeakPocalypse";

		public static string Version => "0.1.0";

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("com.github.Evanovah.PeakPocalypse");
			val.PatchAll();
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void OnGUI()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00fc: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1
			};
			val.normal.textColor = Color.white;
			GUIStyle val2 = val;
			GUIContent val3 = new GUIContent("PeakPocalypse");
			Vector2 val4 = val2.CalcSize(val3);
			Rect val5 = default(Rect);
			((Rect)(ref val5))..ctor((float)Screen.width - val4.x - 10f, 10f, val4.x, val4.y);
			GUIStyle val6 = new GUIStyle(val2);
			val6.normal.textColor = Color.black;
			GUIStyle val7 = val6;
			Rect val8 = default(Rect);
			((Rect)(ref val8))..ctor(((Rect)(ref val5)).x + 2f, ((Rect)(ref val5)).y + 2f, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height);
			GUI.Label(val8, val3, val7);
			GUI.Label(val5, val3, val2);
			if (_statusTimer > 0f)
			{
				GUIStyle val9 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16
				};
				val9.normal.textColor = Color.yellow;
				GUIStyle val10 = val9;
				GUIContent val11 = new GUIContent(_statusMessage);
				Vector2 val12 = val10.CalcSize(val11);
				Rect val13 = default(Rect);
				((Rect)(ref val13))..ctor((float)Screen.width - val12.x - 10f, 40f, val12.x, val12.y);
				GUI.Label(val13, val11, val10);
			}
		}

		private void ShowStatus(string message)
		{
			_statusMessage = message;
			_statusTimer = 3f;
			Log.LogInfo((object)message);
		}

		private void Update()
		{
			if (_statusTimer > 0f)
			{
				_statusTimer -= Time.deltaTime;
			}
			_zombieSpawnTimer -= Time.deltaTime;
			if (_zombieSpawnTimer <= 0f)
			{
				_zombieSpawnTimer = 120f;
				SpawnZombieNearPlayer();
			}
		}

		private void SpawnZombieNearPlayer()
		{
			//IL_003f: 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_00a6: 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_00b2: 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_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_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient)
			{
				ShowStatus("Only the host can spawn zombies!");
				return;
			}
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null)
			{
				ShowStatus("No local character found!");
				return;
			}
			Rigidbody componentInChildren = ((Component)localCharacter).GetComponentInChildren<Rigidbody>();
			Vector3 position;
			Vector3 val;
			if ((Object)(object)componentInChildren != (Object)null)
			{
				position = componentInChildren.position;
				val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : ((Component)localCharacter).transform.forward);
			}
			else if ((Object)(object)Camera.main != (Object)null)
			{
				position = ((Component)Camera.main).transform.position;
				val = ((Component)Camera.main).transform.forward;
			}
			else
			{
				position = ((Component)localCharacter).transform.position;
				val = ((Component)localCharacter).transform.forward;
			}
			Vector3 val2 = position + val * 5f;
			PhotonNetwork.Instantiate("MushroomZombie", val2, Quaternion.identity, (byte)0, (object[])null);
			ShowStatus("Zombie spawned near player!");
		}
	}
	[HarmonyPatch(typeof(MushroomZombieBiteCollider), "OnTriggerEnter")]
	internal static class ZombieBiteNoSporesPatch
	{
		private static bool Prefix(MushroomZombieBiteCollider __instance, Collider other)
		{
			if (Time.time - __instance.lastBitLocalCharacter < 5f)
			{
				return false;
			}
			Character val = default(Character);
			if (!CharacterRagdoll.TryGetCharacterFromCollider(other, ref val) || !val.IsLocal)
			{
				return false;
			}
			__instance.lastBitLocalCharacter = Time.time;
			float num = (val.data.isSkeleton ? (__instance.parentZombie.biteInitialInjury / 8f * 2f) : __instance.parentZombie.biteInitialInjury);
			val.refs.afflictions.AddStatus((STATUSTYPE)0, num, false, true, true);
			val.Fall(__instance.parentZombie.biteStunTime, 0f);
			__instance.parentZombie.OnBitCharacter(val);
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}