Decompiled source of MoreZombie v1.0.5

MoreZombies.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Peak.Afflictions;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreZombies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreZombies")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("29961BBA-9F47-46BC-8719-4FE6A884342E")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreZombies
{
	[BepInPlugin("com.yourname.morezombies", "More Zombies Hell", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"[MoreZombies] Mod đang khởi động! Chuẩn bị giải phóng thảm họa nấm...");
			Harmony val = new Harmony("com.yourname.morezombies");
			val.PatchAll();
			Logger.LogInfo((object)"[MoreZombies] Đã cấy ghép mã độc Harmony thành công!");
		}
	}
	public class ZombieHellPatches
	{
		[HarmonyPatch(typeof(Character), "Start")]
		public static class Inject_Custom_Spawner_Patch
		{
			[HarmonyPostfix]
			public static void Postfix(Character __instance)
			{
				if (__instance.IsLocal && PhotonNetwork.IsMasterClient && (Object)(object)((Component)__instance).gameObject.GetComponent<CustomZombieSpawner>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<CustomZombieSpawner>();
				}
			}
		}

		[HarmonyPatch(typeof(MushroomZombie), "Awake")]
		public static class Zombie_Speed_Patch
		{
			[HarmonyPostfix]
			public static void Postfix(MushroomZombie __instance)
			{
				NavMeshAgent component = ((Component)__instance).GetComponent<NavMeshAgent>();
				if ((Object)(object)component != (Object)null)
				{
					component.speed *= 1.25f;
				}
			}
		}

		[HarmonyPatch(typeof(Affliction_ZombieBite), "OnApplied")]
		public static class Zombie_Bite_Nuke_Patch
		{
			[HarmonyPostfix]
			public static void Postfix(Character ___character)
			{
				if ((Object)(object)___character != (Object)null && ___character.IsLocal)
				{
					___character.refs.afflictions.AddStatus((STATUSTYPE)10, 0.5f, false, true, true, false);
				}
			}
		}

		[HarmonyPatch(typeof(MushroomZombie), "DoWakingUp")]
		public static class Zombie_Instant_WakeUp_Patch
		{
			[HarmonyPrefix]
			public static void Prefix(MushroomZombie __instance, ref float ___timeSpentWakingUp)
			{
				__instance.initialWakeUpTime = 0f;
				___timeSpentWakingUp = 999f;
			}
		}
	}
	public class CustomZombieSpawner : MonoBehaviour
	{
		private float spawnInterval = 60f;

		private float timer = 0f;

		private void Update()
		{
			//IL_0019: 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)
			if (!PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string text = ((Scene)(ref activeScene)).name.ToLower();
			if (!text.Contains("airport") && !text.Contains("lobby") && !text.Contains("menu"))
			{
				timer += Time.deltaTime;
				if (timer >= spawnInterval)
				{
					timer = 0f;
					SpawnZombieInFront();
				}
			}
		}

		private void SpawnZombieInFront()
		{
			//IL_0054: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			//IL_0147: 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)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			Character component = ((Component)this).GetComponent<Character>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			float num = Random.Range(12f, 18f);
			float num2 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
			float num3 = Mathf.Cos(num2) * num;
			float num4 = Mathf.Sin(num2) * num;
			Vector3 val = component.Center + new Vector3(num3, 0f, num4);
			val.y += 20f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, Vector3.down, ref val2, 50f))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			else
			{
				val = component.Center + ((Component)component).transform.forward * 5f;
				val.y += 2f;
			}
			Campfire[] array = Object.FindObjectsByType<Campfire>((FindObjectsSortMode)0);
			Campfire[] array2 = array;
			foreach (Campfire val3 in array2)
			{
				if ((Object)(object)val3 != (Object)null && Vector3.Distance(val, ((Component)val3).transform.position) <= 30f)
				{
					Debug.Log((object)"[ZombieHell] Đã chặn đẻ Zombie vì nằm trong khu vực 30m của Lửa Trại!");
					return;
				}
			}
			Vector3 val4 = component.Center - val;
			val4.y = 0f;
			Quaternion val5 = Quaternion.LookRotation(val4);
			try
			{
				GameObject val6 = PhotonNetwork.Instantiate("MushroomZombie", val, val5, (byte)0, (object[])null);
				if ((Object)(object)val6 != (Object)null)
				{
					val6.AddComponent<ZombieSkeletonTimer>();
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[ZombieHell] Lỗi khi spawn Zombie: " + ex.Message));
			}
		}
	}
	public class ZombieSkeletonTimer : MonoBehaviour
	{
		private bool isReverting = false;

		private void Start()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviour)this).StartCoroutine(RevertToSkeleton(90f));
				((MonoBehaviour)this).StartCoroutine(CampfireRadar());
			}
		}

		private IEnumerator CampfireRadar()
		{
			while (!isReverting)
			{
				yield return (object)new WaitForSeconds(1f);
				Campfire[] allCampfires = Object.FindObjectsByType<Campfire>((FindObjectsSortMode)0);
				Campfire[] array = allCampfires;
				foreach (Campfire cf in array)
				{
					if ((Object)(object)cf != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)cf).transform.position) <= 30f)
					{
						Debug.Log((object)"[ZombieHell] Zombie bước vào vùng Lửa Trại 30m! Hóa xương lập tức.");
						TriggerSkeleton();
						yield break;
					}
				}
			}
		}

		private IEnumerator RevertToSkeleton(float delayTime)
		{
			yield return (object)new WaitForSeconds(delayTime);
			TriggerSkeleton();
		}

		private void TriggerSkeleton()
		{
			if (isReverting)
			{
				return;
			}
			isReverting = true;
			MushroomZombie component = ((Component)this).GetComponent<MushroomZombie>();
			if ((Object)(object)component != (Object)null)
			{
				PhotonView component2 = ((Component)component).GetComponent<PhotonView>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.RPC("RPC_SpawnSkelly", (RpcTarget)0, Array.Empty<object>());
					((MonoBehaviour)this).StartCoroutine(DestroyZombie());
				}
				else
				{
					PhotonNetwork.Destroy(((Component)this).gameObject);
				}
			}
		}

		private IEnumerator DestroyZombie()
		{
			yield return (object)new WaitForSeconds(0.2f);
			if ((Object)(object)((Component)this).gameObject != (Object)null)
			{
				PhotonNetwork.Destroy(((Component)this).gameObject);
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}