Decompiled source of AuroraEventManager v1.0.5

plugins/AuroraEventManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AuroraEventManager.Core;
using AuroraEventManager.Data;
using AuroraEventManager.Events;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AuroraEventManager")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AuroraEventManager")]
[assembly: AssemblyTitle("AuroraEventManager")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AuroraEventManager
{
	[BepInPlugin("com.peepsquick.auroraeventmanager", "Aurora Event Manager", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AuroraEventManagerPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.peepsquick.auroraeventmanager";

		public const string PluginName = "Aurora Event Manager";

		public const string PluginVersion = "2.0.0";

		private static Harmony _harmony;

		public static ConfigEntry<string> ModPassword;

		private const string ValidPassword = "peaches";

		public static ConfigEntry<int> MinEventDelay;

		public static ConfigEntry<int> MaxEventDelay;

		public static ConfigEntry<int> TriviaAnswerTime;

		public static ConfigEntry<bool> EnableTrivia;

		public static ConfigEntry<int> MonsterEventDuration;

		public static ConfigEntry<bool> EnableTreasureGiant;

		public static ConfigEntry<bool> EnableTreasureSwarm;

		public static ConfigEntry<bool> EnableFavorGiant;

		public static ConfigEntry<bool> EnableFavorSwarm;

		public static ConfigEntry<bool> EnableMeatGiant;

		public static ConfigEntry<bool> EnableMeatSwarm;

		public static ConfigEntry<bool> EnableMosquitoGiant;

		public static ConfigEntry<bool> EnableMosquitoSwarm;

		public static ConfigEntry<bool> EnableBlessingRested;

		public static ConfigEntry<bool> EnableBlessingWeight;

		public static ConfigEntry<bool> EnableBlessingEikthyr;

		public static ConfigEntry<bool> EnableBlessingElder;

		public static ConfigEntry<bool> EnableBlessingBonemass;

		public static ConfigEntry<bool> EnableBlessingModer;

		public static ConfigEntry<bool> EnableBlessingYagluth;

		public static ConfigEntry<bool> EnableBlessingQueen;

		public static ConfigEntry<bool> EnableBlessingFader;

		public static ConfigEntry<bool> EnableBlessingDamage;

		public static ConfigEntry<bool> EnableBlessingDefense;

		public static ConfigEntry<bool> EnableGuessNumber;

		public static ConfigEntry<bool> EnableTeleportHaldor;

		public static ConfigEntry<bool> EnableTeleportHildir;

		public static ConfigEntry<bool> EnableTeleportChokepointA;

		public static ConfigEntry<bool> EnableTeleportChokepointB;

		public static ConfigEntry<bool> EnableTeleportChokepointC;

		public static ConfigEntry<bool> EnableReaction;

		public static ConfigEntry<bool> EnableActivityCrate;

		public static ConfigEntry<int> ActivityCratePayoutDay;

		public static ConfigEntry<int> ActivityCratePayoutHour;

		public static ConfigEntry<bool> EnableHiddenHaldor;

		public static ConfigEntry<bool> EnableDancingRitual;

		public static ConfigEntry<bool> EnablePraiseOdin;

		public static ConfigEntry<bool> EnableFreyjasFury;

		public static ConfigEntry<bool> EnableTyrsWoodenRain;

		public static ConfigEntry<bool> EnablePvPDuel;

		public static ConfigEntry<bool> EnableArrowRain;

		public static ConfigEntry<bool> EnableChainRain;

		public static ConfigEntry<bool> EnableMetalRain;

		public static ConfigEntry<bool> EnableAmbush;

		public static ConfigEntry<bool> EnableHourlyBlueprintReward;

		public static ConfigEntry<int> HourlyBlueprintIntervalMinutes;

		public static ConfigEntry<bool> EnableHourlyWeightBuff;

		public static ConfigEntry<int> HourlyWeightBuffIntervalMinutes;

		public static ConfigEntry<float> WeightBuffAmount;

		public static ConfigEntry<float> WeightBuffDurationHours;

		public static ConfigEntry<bool> EnableDailyGift;

		public static ConfigEntry<int> DailyGiftIntervalHours;

		public static ConfigEntry<bool> EnableDanceEvent;

		public static ConfigEntry<bool> EnableVibeEvent;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Expected O, but got Unknown
			ModPassword = ((BaseUnityPlugin)this).Config.Bind<string>("Security", "Password", "ashatasthvbahs", "Server authentication password (only checked on dedicated servers)");
			if ((int)SystemInfo.graphicsDeviceType == 4 && ModPassword.Value != "peaches")
			{
				Debug.LogError((object)"[AuroraEventManager] Invalid server password. Mod disabled.");
				((BaseUnityPlugin)this).Logger.LogError((object)"Aurora Event Manager: Invalid password. Mod will not load on this server.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogMessage((object)"═══════════════════════════════════════════════════");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Aurora Event Manager - The most advanced event system in Valheim");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"═══════════════════════════════════════════════════");
			Debug.Log((object)"[AuroraEventManager] ═══════════════════════════════════════════════════");
			Debug.Log((object)"[AuroraEventManager] Aurora Event Manager - The most advanced event system in Valheim");
			Debug.Log((object)"[AuroraEventManager] ═══════════════════════════════════════════════════");
			MinEventDelay = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinEventDelay", 5, "Minimum minutes between events");
			MaxEventDelay = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxEventDelay", 500, "Maximum minutes between events");
			TriviaAnswerTime = ((BaseUnityPlugin)this).Config.Bind<int>("Trivia", "AnswerTime", 60, "Seconds players have to answer trivia questions");
			EnableTrivia = ((BaseUnityPlugin)this).Config.Bind<bool>("Trivia", "EnableTrivia", true, "Enable the Trivia event");
			MonsterEventDuration = ((BaseUnityPlugin)this).Config.Bind<int>("MonsterEvents", "Duration", 60, "Seconds before event monsters despawn");
			EnableTreasureGiant = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableTreasureGiant", true, "Enable the Treasure Giant event");
			EnableTreasureSwarm = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableTreasureSwarm", true, "Enable the Treasure Swarm event");
			EnableFavorGiant = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableFavorGiant", true, "Enable the Favor Giant event");
			EnableFavorSwarm = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableFavorSwarm", true, "Enable the Favor Swarm event");
			EnableMeatGiant = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableMeatGiant", true, "Enable the Meat Giant event");
			EnableMeatSwarm = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableMeatSwarm", true, "Enable the Meat Swarm event");
			EnableMosquitoGiant = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableMosquitoGiant", true, "Enable the Giant Mosquito event");
			EnableMosquitoSwarm = ((BaseUnityPlugin)this).Config.Bind<bool>("MonsterEvents", "EnableMosquitoSwarm", true, "Enable the Mosquito Swarm event");
			EnableBlessingRested = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingRested", true, "Enable the Rested blessing (30 min)");
			EnableBlessingWeight = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingWeight", true, "Enable the Weight/Carry blessing (FreyjaWeightHour)");
			EnableBlessingEikthyr = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingEikthyr", true, "Enable the Eikthyr guardian power blessing (20 min)");
			EnableBlessingElder = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingElder", true, "Enable the Elder guardian power blessing (20 min)");
			EnableBlessingBonemass = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingBonemass", true, "Enable the Bonemass guardian power blessing (20 min)");
			EnableBlessingModer = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingModer", true, "Enable the Moder guardian power blessing (20 min)");
			EnableBlessingYagluth = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingYagluth", true, "Enable the Yagluth guardian power blessing (20 min)");
			EnableBlessingQueen = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingQueen", true, "Enable the Queen guardian power blessing (20 min)");
			EnableBlessingFader = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingFader", true, "Enable the Fader guardian power blessing (20 min)");
			EnableBlessingDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingDamage", true, "Enable the Damage blessing (+50% damage, 30 min)");
			EnableBlessingDefense = ((BaseUnityPlugin)this).Config.Bind<bool>("BlessingEvents", "EnableBlessingDefense", true, "Enable the Defense blessing (+50% defense, 30 min)");
			EnableGuessNumber = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableGuessNumber", true, "Enable the Guess the Number event");
			EnableTeleportHaldor = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableTeleportHaldor", true, "Enable free teleport to Haldor");
			EnableTeleportHildir = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableTeleportHildir", true, "Enable free teleport to Hildir");
			EnableTeleportChokepointA = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableTeleportChokepointA", true, "Enable free teleport to Chokepoint A");
			EnableTeleportChokepointB = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableTeleportChokepointB", true, "Enable free teleport to Chokepoint B");
			EnableTeleportChokepointC = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableTeleportChokepointC", true, "Enable free teleport to Chokepoint C");
			EnableReaction = ((BaseUnityPlugin)this).Config.Bind<bool>("MiniGameEvents", "EnableReaction", true, "Enable the Reaction (type word first) event - requires 3+ players");
			EnableActivityCrate = ((BaseUnityPlugin)this).Config.Bind<bool>("ActivityCrate", "EnableActivityCrate", true, "Enable the Activity Crate system for weekly rewards");
			ActivityCratePayoutDay = ((BaseUnityPlugin)this).Config.Bind<int>("ActivityCrate", "PayoutDay", 0, "Day of week for payout (0=Sunday, 1=Monday, etc)");
			ActivityCratePayoutHour = ((BaseUnityPlugin)this).Config.Bind<int>("ActivityCrate", "PayoutHour", 18, "Hour for payout (24-hour format, 18 = 6PM)");
			EnableHiddenHaldor = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableHiddenHaldor", true, "Enable Hidden Haldor event - find the trader for treasure!");
			EnableDancingRitual = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableDancingRitual", true, "Enable Dancing Ritual event - dance together to clear weather!");
			EnablePraiseOdin = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnablePraiseOdin", true, "Enable Praise Odin event - shout praise to smelt ores instantly!");
			EnableFreyjasFury = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableFreyjasFury", true, "Enable Freyja's Fury event - kills monsters around a player!");
			EnableTyrsWoodenRain = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableTyrsWoodenRain", true, "Enable Tyr's Wooden Rain event - rains random wood on a player!");
			EnablePvPDuel = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnablePvPDuel", true, "Enable PvP Duel event - players can shout 'pvp?' to initiate duels!");
			EnableArrowRain = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableArrowRain", true, "Enable Ullr's Arrow Rain event - rains random arrows on a player!");
			EnableChainRain = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableChainRain", true, "Enable Loki's Chain Rain event - rains chains on a player!");
			EnableMetalRain = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableMetalRain", true, "Enable Sindri's Metal Rain event - rains a random metal ingot (Tin/Copper/Bronze/Iron/Silver/BlackMetal) on a player!");
			EnableAmbush = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableAmbush", true, "Enable Ambush event - players opt-in to face waves of monsters!");
			EnableHourlyBlueprintReward = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableHourlyBlueprintReward", true, "Enable hourly blueprint reward - every online player gets a random ABP_ blueprint added to their Activity Crate!");
			HourlyBlueprintIntervalMinutes = ((BaseUnityPlugin)this).Config.Bind<int>("SpecialEvents", "HourlyBlueprintIntervalMinutes", 60, "Interval in minutes between hourly blueprint reward grants");
			EnableHourlyWeightBuff = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableHourlyWeightBuff", true, "Enable Heimdall's Gift - every hour, one random online player gets +1000 carry weight for 6 hours (lasts until death/logout)");
			HourlyWeightBuffIntervalMinutes = ((BaseUnityPlugin)this).Config.Bind<int>("SpecialEvents", "HourlyWeightBuffIntervalMinutes", 60, "Interval in minutes between Heimdall's Gift rolls");
			WeightBuffAmount = ((BaseUnityPlugin)this).Config.Bind<float>("SpecialEvents", "WeightBuffAmount", 1000f, "Amount of bonus carry weight Heimdall's Gift grants");
			WeightBuffDurationHours = ((BaseUnityPlugin)this).Config.Bind<float>("SpecialEvents", "WeightBuffDurationHours", 6f, "Duration of Heimdall's Gift in hours (effectively ends on death/logout)");
			EnableDailyGift = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableDailyGift", true, "Enable Freyja's Bounty - every 24h, one random player gets a surprise gift in their Activity Crate");
			DailyGiftIntervalHours = ((BaseUnityPlugin)this).Config.Bind<int>("SpecialEvents", "DailyGiftIntervalHours", 24, "Interval in hours between Freyja's Bounty rolls");
			EnableDanceEvent = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableDanceEvent", true, "Enable Freyja's Circle - all online vikings must /dance to receive +1h Rested");
			EnableVibeEvent = ((BaseUnityPlugin)this).Config.Bind<bool>("SpecialEvents", "EnableVibeEvent", true, "Enable Dwarven Work Song - all online vikings must /cheer to receive +1000 carry weight for 6h");
			CreatureManager.OnVanillaCreaturesAvailable += RegisterEventCreatures;
			_harmony = new Harmony("com.peepsquick.auroraeventmanager");
			_harmony.PatchAll();
			Debug.Log((object)"[AuroraEventManager] Harmony PatchAll completed");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Aurora Event Manager 2.0.0 loaded!");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			CreatureManager.OnVanillaCreaturesAvailable -= RegisterEventCreatures;
			EventManagerCore.Shutdown();
		}

		private void RegisterEventCreatures()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[AuroraEventManager] Registering custom event creatures via Jötunn CreatureManager...");
			try
			{
				CreatureConfig val = new CreatureConfig();
				val.Name = "Treasure Giant";
				CustomCreature val2 = new CustomCreature("AEM_TreasureGiant", "Goblin", val);
				ConfigureEventCreature(val2.Prefab, 5f, new Color(1f, 0.84f, 0f), 3000f, "Treasure Giant", isBoss: true);
				CreatureManager.Instance.AddCreature(val2);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_TreasureGiant");
				CreatureConfig val3 = new CreatureConfig();
				val3.Name = "Treasure Goblin";
				CustomCreature val4 = new CustomCreature("AEM_TreasureGoblin", "Goblin", val3);
				ConfigureEventCreature(val4.Prefab, 1f, new Color(1f, 0.84f, 0f), 50f, "Treasure Goblin", isBoss: false);
				CreatureManager.Instance.AddCreature(val4);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_TreasureGoblin");
				CreatureConfig val5 = new CreatureConfig();
				val5.Name = "Favor Dragon";
				CustomCreature val6 = new CustomCreature("AEM_FavorDragon", "Hatchling", val5);
				ConfigureEventCreature(val6.Prefab, 3f, new Color(0.3f, 0.5f, 1f), 5000f, "Favor Dragon", isBoss: true);
				CreatureManager.Instance.AddCreature(val6);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_FavorDragon");
				CreatureConfig val7 = new CreatureConfig();
				val7.Name = "Favor Drake";
				CustomCreature val8 = new CustomCreature("AEM_FavorDrake", "Hatchling", val7);
				ConfigureEventCreature(val8.Prefab, 1f, new Color(0.3f, 0.5f, 1f), 30f, "Favor Drake", isBoss: false);
				CreatureManager.Instance.AddCreature(val8);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_FavorDrake");
				CreatureConfig val9 = new CreatureConfig();
				val9.Name = "Meat Giant";
				CustomCreature val10 = new CustomCreature("AEM_MeatGiant", "Boar", val9);
				ConfigureEventCreature(val10.Prefab, 5f, new Color(1f, 0.4f, 0.5f), 2000f, "Meat Giant", isBoss: true);
				CreatureManager.Instance.AddCreature(val10);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_MeatGiant");
				CreatureConfig val11 = new CreatureConfig();
				val11.Name = "Meat Boar";
				CustomCreature val12 = new CustomCreature("AEM_MeatBoar", "Boar", val11);
				ConfigureEventCreature(val12.Prefab, 1f, new Color(1f, 0.4f, 0.5f), 30f, "Meat Boar", isBoss: false);
				CreatureManager.Instance.AddCreature(val12);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_MeatBoar");
				CreatureConfig val13 = new CreatureConfig();
				val13.Name = "Giant Mosquito";
				CustomCreature val14 = new CustomCreature("AEM_GiantMosquito", "Deathsquito", val13);
				ConfigureEventCreature(val14.Prefab, 5f, new Color(1f, 0.2f, 0.2f), 1500f, "Giant Mosquito", isBoss: true);
				CreatureManager.Instance.AddCreature(val14);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_GiantMosquito");
				CreatureConfig val15 = new CreatureConfig();
				val15.Name = "Void Mosquito";
				CustomCreature val16 = new CustomCreature("AEM_VoidMosquito", "Deathsquito", val15);
				ConfigureEventCreature(val16.Prefab, 1f, new Color(1f, 0.2f, 0.2f), 20f, "Void Mosquito", isBoss: false);
				CreatureManager.Instance.AddCreature(val16);
				Debug.Log((object)"[AuroraEventManager] Registered: AEM_VoidMosquito");
				Debug.Log((object)"[AuroraEventManager] Successfully registered 8 custom event creatures via Jötunn!");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[AuroraEventManager] Failed to register creatures: " + ex.Message + "\n" + ex.StackTrace));
			}
			CreatureManager.OnVanillaCreaturesAvailable -= RegisterEventCreatures;
		}

		private void ConfigureEventCreature(GameObject prefab, float scale, Color glowColor, float health, string displayName, bool isBoss)
		{
			//IL_0006: 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_00a2: 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)
			//IL_00b8: 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_00d3: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			prefab.transform.localScale = Vector3.one * scale;
			Character component = prefab.GetComponent<Character>();
			prefab.GetComponent<Humanoid>();
			MonsterAI component2 = prefab.GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_name = displayName;
				component.m_health = health;
				component.m_boss = isBoss;
			}
			CharacterDrop component3 = prefab.GetComponent<CharacterDrop>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.m_drops = new List<Drop>();
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_attackPlayerObjects = false;
				component2.m_alertRange = 30f;
			}
			if ((Object)(object)prefab.transform.Find("AEM_Glow") == (Object)null)
			{
				GameObject val = new GameObject("AEM_Glow");
				val.transform.SetParent(prefab.transform);
				val.transform.localPosition = Vector3.up * (isBoss ? 3f : 1f);
				Light obj = val.AddComponent<Light>();
				obj.type = (LightType)2;
				obj.color = glowColor;
				obj.intensity = (isBoss ? 3f : 2f);
				obj.range = (isBoss ? 25f : 15f);
				val.AddComponent<PulsingLight>();
			}
		}
	}
	public class PulsingLight : MonoBehaviour
	{
		private Light _light;

		private float _baseIntensity;

		private float _pulseSpeed = 2f;

		private float _pulseAmount = 0.5f;

		private void Start()
		{
			_light = ((Component)this).GetComponent<Light>();
			if ((Object)(object)_light != (Object)null)
			{
				_baseIntensity = _light.intensity;
			}
		}

		private void Update()
		{
			if ((Object)(object)_light != (Object)null)
			{
				float num = Mathf.Sin(Time.time * _pulseSpeed) * _pulseAmount + 1f;
				_light.intensity = _baseIntensity * num;
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public static class ZNetScene_Awake_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(ZNetScene __instance)
		{
			if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
			{
				Debug.Log((object)"[AuroraEventManager] Initializing Aurora Event Manager on server...");
				EventManagerCore.Initialize();
				ActivityTracker.Initialize();
				ActivityCrateManager.Initialize();
				NewPlayerTracker.Initialize();
				PvPDuelEvent.Initialize();
			}
		}
	}
	[HarmonyPatch(typeof(Game), "Start")]
	public static class Game_Start_Patch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			Debug.Log((object)"[AuroraEventManager] Registering client RPC handlers...");
			RewardHandler.RegisterClientRPCs();
			ActivityCrateUI.Initialize();
			ActivityCrateManager.Initialize();
		}
	}
	[HarmonyPatch(typeof(Hud), "Awake")]
	public static class Hud_Awake_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Hud __instance)
		{
			Debug.Log((object)"[AuroraEventManager] HUD initialized, setting up crate button...");
			ActivityCrateUI.Instance?.SetupCrateButton();
		}
	}
	[HarmonyPatch(typeof(ZRoutedRpc), "HandleRoutedRPC")]
	public static class ZRoutedRpc_HandleRoutedRPC_Patch
	{
	}
	[HarmonyPatch(typeof(Chat), "SendText")]
	public static class Chat_SendText_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Chat __instance, Type type, string text)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			if ((int)type == 2 && text?.Trim()?.ToLower() == "pvp?" && ZRoutedRpc.instance != null && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				string playerName = Player.m_localPlayer.GetPlayerName();
				ZNet.GetUID();
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "AEM_DuelRequest", new object[1] { playerName });
			}
		}
	}
	[HarmonyPatch(typeof(Chat), "OnNewChatMessage")]
	public static class Chat_OnNewChatMessage_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(GameObject go, long senderID, Vector3 pos, Type type, UserInfo sender, string text)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && sender != null && !(sender.Name == "Event Manager") && (Object)(object)EventManagerCore.Instance != (Object)null && (int)type == 2)
			{
				EventManagerCore.Instance.OnPlayerChat(sender.Name, text);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Character_Damage_Patch
	{
		private static Random _random = new Random();

		[HarmonyPrefix]
		public static void Prefix(Character __instance, HitData hit)
		{
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return;
			}
			Character attacker = hit.GetAttacker();
			if (!((Object)(object)attacker != (Object)null))
			{
				return;
			}
			string name = ((Object)((Component)attacker).gameObject).name;
			if (!IsEventMonster(((Component)attacker).gameObject))
			{
				return;
			}
			Debug.Log((object)("[AuroraEventManager] Event monster " + name + " attacking " + ((Object)__instance).name));
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null)
			{
				ZNetView component = ((Component)attacker).GetComponent<ZNetView>();
				if (((component != null) ? component.GetZDO() : null) != null)
				{
					string @string = component.GetZDO().GetString("AEM_StatusEffect", "");
					if (!string.IsNullOrEmpty(@string))
					{
						ApplyStatusEffect(val, @string);
						Debug.Log((object)("[AuroraEventManager] Applied " + @string + " debuff to " + val.GetPlayerName()));
					}
					else
					{
						Debug.Log((object)("[AuroraEventManager] No status effect configured for " + name));
					}
				}
			}
			hit.m_damage.m_damage = 0f;
			hit.m_damage.m_blunt = 0f;
			hit.m_damage.m_slash = 0f;
			hit.m_damage.m_pierce = 0f;
			hit.m_damage.m_chop = 0f;
			hit.m_damage.m_pickaxe = 0f;
			hit.m_damage.m_fire = 0f;
			hit.m_damage.m_frost = 0f;
			hit.m_damage.m_lightning = 0f;
			hit.m_damage.m_poison = 0f;
			hit.m_damage.m_spirit = 0f;
			hit.m_pushForce = 0f;
			hit.m_backstabBonus = 0f;
			hit.m_staggerMultiplier = 0f;
		}

		[HarmonyPostfix]
		public static void Postfix(Character __instance, HitData hit)
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return;
			}
			string name = ((Object)((Component)__instance).gameObject).name;
			if (!IsEventMonster(((Component)__instance).gameObject))
			{
				return;
			}
			Debug.Log((object)("[AuroraEventManager] Event monster " + name + " was hit!"));
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)("[AuroraEventManager] No ZNetView on " + name));
				return;
			}
			if (component.GetZDO() == null)
			{
				Debug.LogWarning((object)("[AuroraEventManager] No ZDO on " + name));
				return;
			}
			if (!component.IsOwner())
			{
				Debug.Log((object)("[AuroraEventManager] Not owner of " + name + ", skipping loot"));
				return;
			}
			ZDO zDO = component.GetZDO();
			float @float = zDO.GetFloat("AEM_LastHitTime", 0f);
			if (Time.time - @float < 0.5f)
			{
				Debug.Log((object)("[AuroraEventManager] Cooldown active for " + name));
				return;
			}
			zDO.Set("AEM_LastHitTime", Time.time);
			string @string = zDO.GetString("AEM_ItemPool", "");
			if (string.IsNullOrEmpty(@string))
			{
				Debug.LogWarning((object)("[AuroraEventManager] No item pool in ZDO for " + name));
				return;
			}
			int @int = zDO.GetInt("AEM_HitDropMin", 1);
			int int2 = zDO.GetInt("AEM_HitDropMax", 3);
			string[] array = @string.Split(new char[1] { ',' });
			string text = array[_random.Next(array.Length)];
			int num = _random.Next(@int, int2 + 1);
			Vector3 val = ((hit.m_point != Vector3.zero) ? hit.m_point : ((Component)__instance).transform.position);
			Debug.Log((object)$"[AuroraEventManager] HIT LOOT: {num}x {text} at {val}");
			RewardHandler.DropItemsAtPosition(text, num, val);
		}

		private static bool IsEventMonster(GameObject go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			if (((Object)go).name.Contains("AEM_"))
			{
				return true;
			}
			ZNetView component = go.GetComponent<ZNetView>();
			if (((component != null) ? component.GetZDO() : null) != null && component.GetZDO().GetBool("AEM_IsEventMonster", false))
			{
				return true;
			}
			return false;
		}

		private static void ApplyStatusEffect(Player player, string effectName)
		{
			if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(effectName))
			{
				return;
			}
			try
			{
				SEMan sEMan = ((Character)player).GetSEMan();
				if (sEMan == null)
				{
					return;
				}
				if (ObjectDB.instance?.m_StatusEffects != null)
				{
					foreach (StatusEffect statusEffect in ObjectDB.instance.m_StatusEffects)
					{
						if ((Object)(object)statusEffect != (Object)null && ((Object)statusEffect).name == effectName)
						{
							StatusEffect val = sEMan.AddStatusEffect(statusEffect.NameHash(), true, 0, 0f);
							if ((Object)(object)val != (Object)null)
							{
								val.m_ttl = 1.5f;
							}
							return;
						}
					}
				}
				Debug.LogWarning((object)("[AuroraEventManager] Status effect '" + effectName + "' not found in ObjectDB"));
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Failed to apply status effect: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Character), "OnDeath")]
	public static class Character_OnDeath_Patch
	{
		private static Random _random = new Random();

		[HarmonyPrefix]
		public static void Prefix(Character __instance)
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			string name = ((Object)((Component)__instance).gameObject).name;
			if (!name.Contains("AEM_"))
			{
				return;
			}
			Debug.Log((object)("[AuroraEventManager] Event monster dying: " + name));
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || component.GetZDO() == null)
			{
				Debug.LogWarning((object)("[AuroraEventManager] No ZNetView/ZDO on dying " + name));
				return;
			}
			if (!component.IsOwner())
			{
				Debug.Log((object)("[AuroraEventManager] Not owner of dying " + name + ", skipping death loot"));
				return;
			}
			ZDO zDO = component.GetZDO();
			if (zDO.GetBool("AEM_DeathLootDropped", false))
			{
				Debug.Log((object)("[AuroraEventManager] Death loot already dropped for " + name));
				return;
			}
			zDO.Set("AEM_DeathLootDropped", true);
			string @string = zDO.GetString("AEM_ItemPool", "");
			if (string.IsNullOrEmpty(@string))
			{
				Debug.LogWarning((object)("[AuroraEventManager] No item pool in ZDO for dying " + name));
				return;
			}
			int @int = zDO.GetInt("AEM_KillDropMin", 10);
			int int2 = zDO.GetInt("AEM_KillDropMax", 20);
			string[] array = @string.Split(new char[1] { ',' });
			string text = array[_random.Next(array.Length)];
			int num = _random.Next(@int, int2 + 1);
			Debug.Log((object)$"[AuroraEventManager] DEATH LOOT: {num}x {text}");
			RewardHandler.DropItemsAtPosition(text, num, ((Component)__instance).transform.position);
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "OnDeath")]
	public static class CharacterDrop_OnDeath_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterDrop __instance)
		{
			string name = ((Object)((Component)__instance).gameObject).name;
			if (name.Contains("AEM_"))
			{
				Debug.Log((object)("[AuroraEventManager] Blocking vanilla loot for " + name));
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "Start")]
	public static class Character_Start_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Character __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				string name = ((Object)((Component)__instance).gameObject).name;
				if (name.Contains("AEM_"))
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					bool flag = ((component != null) ? component.GetZDO() : null) != null;
					bool flag2 = component != null && component.IsOwner();
					Debug.Log((object)$"[AuroraEventManager] Event monster started: {name}, hasZDO={flag}, isOwner={flag2}");
				}
			}
		}
	}
	[HarmonyPatch(typeof(Trader), "Interact")]
	public static class Trader_Interact_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Trader __instance, Humanoid character, bool hold, bool alt, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || hold)
			{
				return true;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || component.GetZDO() == null)
			{
				return true;
			}
			if (!component.GetZDO().GetBool("AEM_HiddenHaldor", false))
			{
				return true;
			}
			Player val = (Player)(object)((character is Player) ? character : null);
			if ((Object)(object)val != (Object)null)
			{
				RewardHandler.NotifyHaldorFound(val.GetPlayerName());
				((Character)val).Message((MessageType)2, "You found Hidden Haldor!", 0, (Sprite)null);
				__result = true;
				return false;
			}
			return true;
		}
	}
}
namespace AuroraEventManager.Events
{
	public enum MonsterEventType
	{
		Giant,
		Swarm
	}
	public abstract class BaseMonsterEvent : BaseEvent
	{
		protected float _eventStartTime;

		protected float _eventDuration;

		protected string _eventInstanceId;

		protected int _spawnCount;

		protected List<ZDOID> _spawnedZDOIDs = new List<ZDOID>();

		protected abstract string CustomPrefabName { get; }

		protected abstract MonsterEventType EventType { get; }

		protected abstract string[] ItemPool { get; }

		protected abstract string StatusEffectOnHit { get; }

		protected abstract bool MonsterFlees { get; }

		protected virtual int HitDropMin
		{
			get
			{
				if (EventType != 0)
				{
					return 1;
				}
				return 2;
			}
		}

		protected virtual int HitDropMax
		{
			get
			{
				if (EventType != 0)
				{
					return 2;
				}
				return 5;
			}
		}

		protected virtual int KillDropMin
		{
			get
			{
				if (EventType != 0)
				{
					return 8;
				}
				return 30;
			}
		}

		protected virtual int KillDropMax
		{
			get
			{
				if (EventType != 0)
				{
					return 12;
				}
				return 50;
			}
		}

		protected virtual int SwarmCount => 5;

		public BaseMonsterEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 3,
				MinPlayers = 1,
				IsGlobalEvent = false,
				RequiresTargetPlayer = true
			};
		}

		public override bool CanTrigger()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0080: 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)
			if (!base.CanTrigger())
			{
				return false;
			}
			if (base.TargetPosition != Vector3.zero)
			{
				if (!BaseEvent.IsValidMonsterEventLocation(base.TargetPosition))
				{
					Debug.Log((object)("[AuroraEventManager] " + EventName + " cannot trigger - player too close to workbench"));
					return false;
				}
				if (!PrivateArea.CheckAccess(base.TargetPosition, 0f, false, false))
				{
					Debug.Log((object)("[AuroraEventManager] " + EventName + " cannot trigger - position is inside ward area"));
					return false;
				}
				PlayerBehaviorTracker instance = PlayerBehaviorTracker.Instance;
				if (instance.IsPositionSheltered(base.TargetPosition))
				{
					Debug.Log((object)("[AuroraEventManager] " + EventName + " cannot trigger - position is sheltered"));
					return false;
				}
				if (instance.IsPositionInPlayerBase(base.TargetPosition))
				{
					Debug.Log((object)("[AuroraEventManager] " + EventName + " cannot trigger - position is in player base"));
					return false;
				}
			}
			return true;
		}

		protected override void OnEventStart()
		{
			_eventDuration = AuroraEventManagerPlugin.MonsterEventDuration.Value;
			_eventStartTime = Time.time;
			_eventInstanceId = $"{EventId}_{DateTime.UtcNow.Ticks}";
			_spawnCount = 0;
			_spawnedZDOIDs.Clear();
			string text = ((EventType == MonsterEventType.Giant) ? "GIANT" : "SWARM");
			string message = "<color=#00FFFF>[" + text + "]</color> A <color=#FFA500>" + EventName + "</color> has appeared near <color=#FFFF00>" + base.TargetPlayerName + "</color>! Hunt it down for loot!";
			SendEventShout(message);
			SpawnMonsters();
			Debug.Log((object)$"[AuroraEventManager] {EventName} started with {_spawnCount} monsters");
		}

		protected override void OnEventStop()
		{
			DespawnAllMonsters();
			EventManagerCore.Instance?.OnEventEnded(this);
			Debug.Log((object)("[AuroraEventManager] " + EventName + " ended"));
		}

		protected override void OnEventUpdate()
		{
			//IL_005d: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time - _eventStartTime < 3f)
			{
				return;
			}
			if (Time.time - _eventStartTime >= _eventDuration)
			{
				SendEventShout("<color=#FFA500>[EVENT]</color> The " + EventName + " has escaped! Time ran out.");
				Stop();
				return;
			}
			int num = 0;
			foreach (ZDOID spawnedZDOID in _spawnedZDOIDs)
			{
				if (spawnedZDOID != ZDOID.None)
				{
					ZDOMan instance = ZDOMan.instance;
					if (((instance != null) ? instance.GetZDO(spawnedZDOID) : null) != null)
					{
						num++;
					}
				}
			}
			if (num == 0 && _spawnCount > 0)
			{
				SendEventShout("<color=#00FF00>[EVENT]</color> All " + EventName + " creatures have been defeated!");
				Stop();
			}
		}

		protected virtual void SpawnMonsters()
		{
			//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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			int num = ((EventType == MonsterEventType.Giant) ? 1 : SwarmCount);
			for (int i = 0; i < num; i++)
			{
				Vector3 spawnPosition = GetSpawnPosition(i);
				ZDOID val = SpawnEventMonster(spawnPosition);
				if (val != ZDOID.None)
				{
					_spawnedZDOIDs.Add(val);
					_spawnCount++;
				}
			}
			Debug.Log((object)$"[AuroraEventManager] Spawned {_spawnCount}x {CustomPrefabName}");
		}

		protected Vector3 GetSpawnPosition(int index)
		{
			//IL_0028: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (index == 0)
			{
				return base.TargetPosition;
			}
			float num = 360f / (float)SwarmCount * (float)index * ((float)Math.PI / 180f);
			float num2 = 3f;
			return base.TargetPosition + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2);
		}

		protected virtual ZDOID SpawnEventMonster(Vector3 position)
		{
			//IL_0052: 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_0059: 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_0036: 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_00ad: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			ZNetScene instance = ZNetScene.instance;
			GameObject val = ((instance != null) ? instance.GetPrefab(CustomPrefabName) : null);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)("[AuroraEventManager] Custom prefab not found: " + CustomPrefabName));
				return ZDOID.None;
			}
			Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
			GameObject val3 = Object.Instantiate<GameObject>(val, position, val2);
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError((object)("[AuroraEventManager] Failed to instantiate: " + CustomPrefabName));
				return ZDOID.None;
			}
			ZNetView component = val3.GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || component.GetZDO() == null)
			{
				Debug.LogError((object)"[AuroraEventManager] No ZNetView/ZDO on spawned monster");
				Object.Destroy((Object)(object)val3);
				return ZDOID.None;
			}
			ZDOID uid = component.GetZDO().m_uid;
			ZDO zDO = component.GetZDO();
			zDO.Set("AEM_IsEventMonster", true);
			zDO.Set("AEM_EventId", _eventInstanceId);
			zDO.Set("AEM_ItemPool", string.Join(",", ItemPool));
			zDO.Set("AEM_HitDropMin", HitDropMin);
			zDO.Set("AEM_HitDropMax", HitDropMax);
			zDO.Set("AEM_KillDropMin", KillDropMin);
			zDO.Set("AEM_KillDropMax", KillDropMax);
			zDO.Set("AEM_StatusEffect", StatusEffectOnHit ?? "");
			if (MonsterFlees)
			{
				MonsterAI component2 = val3.GetComponent<MonsterAI>();
				Character component3 = val3.GetComponent<Character>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.m_fleeIfLowHealth = 1f;
					component2.m_fleeIfNotAlerted = true;
					((BaseAI)component2).m_avoidFire = true;
				}
				if ((Object)(object)component3 != (Object)null)
				{
					component3.m_speed *= 1.1f;
					component3.m_runSpeed *= 1.1f;
				}
			}
			Debug.Log((object)$"[AuroraEventManager] Spawned {CustomPrefabName} at {position}, ZDOID: {uid}");
			return uid;
		}

		protected void DespawnAllMonsters()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (ZDOID spawnedZDOID in _spawnedZDOIDs)
			{
				if (spawnedZDOID == ZDOID.None)
				{
					continue;
				}
				ZDOMan instance = ZDOMan.instance;
				ZDO val = ((instance != null) ? instance.GetZDO(spawnedZDOID) : null);
				if (val == null)
				{
					Debug.Log((object)$"[AuroraEventManager] ZDO {spawnedZDOID} already gone");
					continue;
				}
				ZNetScene instance2 = ZNetScene.instance;
				ZNetView val2 = ((instance2 != null) ? instance2.FindInstance(val) : null);
				if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)null)
				{
					try
					{
						val2.ClaimOwnership();
						ZNetScene.instance.Destroy(((Component)val2).gameObject);
						num++;
						Debug.Log((object)$"[AuroraEventManager] Destroyed via local instance: {spawnedZDOID}");
					}
					catch (Exception ex)
					{
						Debug.LogWarning((object)("[AuroraEventManager] Local destroy failed: " + ex.Message));
						goto IL_00d6;
					}
					continue;
				}
				goto IL_00d6;
				IL_00d6:
				try
				{
					val.SetOwner(ZDOMan.GetSessionID());
					ZDOMan.instance.DestroyZDO(val);
					num++;
					Debug.Log((object)$"[AuroraEventManager] Destroyed via ZDO: {spawnedZDOID}");
				}
				catch (Exception ex2)
				{
					Debug.LogWarning((object)("[AuroraEventManager] ZDO destroy failed: " + ex2.Message));
				}
			}
			_spawnedZDOIDs.Clear();
			Debug.Log((object)$"[AuroraEventManager] Despawned {num} monsters total");
		}
	}
	public abstract class BaseBlessingEvent : BaseEvent
	{
		private struct PlayerInfo
		{
			public string Name;

			public long UID;
		}

		private const float ALL_PLAYERS_CHANCE = 0.1f;

		protected abstract string BlessingName { get; }

		protected abstract string StatusEffectName { get; }

		protected abstract float Duration { get; }

		protected abstract Color AnnouncementColor { get; }

		public BaseBlessingEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 9,
				MinPlayers = 1,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		protected override void OnEventStart()
		{
			if (Random.value < 0.1f)
			{
				ApplyToAllPlayers();
			}
			else
			{
				ApplyToRandomPlayer();
			}
			Stop();
		}

		protected override void OnEventStop()
		{
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
		}

		private void ApplyToAllPlayers()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			string text = ColorUtility.ToHtmlStringRGB(AnnouncementColor);
			string message = "<color=#FFD700>[BLESSING]</color> <color=#" + text + ">" + BlessingName + "</color> has been bestowed upon <color=#00FF00>ALL VIKINGS</color>!";
			SendEventShout(message);
			ApplyBlessingViaRPC(toAll: true, 0L);
			Debug.Log((object)("[AuroraEventManager] Applied " + BlessingName + " to ALL players via RPC"));
		}

		private void ApplyToRandomPlayer()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerInfo> allPlayerInfos = GetAllPlayerInfos();
			if (allPlayerInfos.Count != 0)
			{
				PlayerInfo playerInfo = allPlayerInfos[Random.Range(0, allPlayerInfos.Count)];
				string name = playerInfo.Name;
				long uID = playerInfo.UID;
				string text = ColorUtility.ToHtmlStringRGB(AnnouncementColor);
				string message = "<color=#FFD700>[BLESSING]</color> <color=#" + text + ">" + BlessingName + "</color> has been bestowed upon <color=#FFFF00>" + name + "</color>!";
				SendEventShout(message);
				ApplyBlessingViaRPC(toAll: false, uID);
				Debug.Log((object)$"[AuroraEventManager] Applied {BlessingName} to {name} (UID: {uID}) via RPC");
			}
		}

		protected virtual void ApplyBlessingViaRPC(bool toAll, long playerUID)
		{
			if (string.IsNullOrEmpty(StatusEffectName))
			{
				Debug.LogWarning((object)("[AuroraEventManager] No status effect name for " + BlessingName));
			}
			else if (toAll)
			{
				RewardHandler.SendBlessingToAllPlayers(StatusEffectName, Duration);
			}
			else
			{
				RewardHandler.SendBlessingToPlayer(playerUID, StatusEffectName, Duration);
			}
		}

		private List<PlayerInfo> GetAllPlayerInfos()
		{
			List<PlayerInfo> list = new List<PlayerInfo>();
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return list;
			}
			foreach (ZNetPeer peer in ZNet.instance.GetPeers())
			{
				if (peer != null && peer.m_uid != 0L)
				{
					list.Add(new PlayerInfo
					{
						Name = peer.m_playerName,
						UID = peer.m_uid
					});
				}
			}
			return list;
		}
	}
	public class RestedBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_rested";

		public override string EventName => "Blessing of Rest";

		protected override string BlessingName => "Blessing of Rest";

		protected override string StatusEffectName => "Rested";

		protected override float Duration => 1800f;

		protected override Color AnnouncementColor => new Color(0.5f, 0.8f, 1f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingRested.Value;
			}
			return false;
		}
	}
	public class WeightBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_weight";

		public override string EventName => "Blessing of Strength";

		protected override string BlessingName => "Blessing of Strength";

		protected override string StatusEffectName => "FreyjaWeightHour";

		protected override float Duration => 0f;

		protected override Color AnnouncementColor => new Color(1f, 0.6f, 0.2f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingWeight.Value;
			}
			return false;
		}
	}
	public class EikthyrBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_eikthyr";

		public override string EventName => "Power of Eikthyr";

		protected override string BlessingName => "Power of Eikthyr";

		protected override string StatusEffectName => "GP_Eikthyr";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.8f, 0.9f, 1f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingEikthyr.Value;
			}
			return false;
		}
	}
	public class ElderBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_elder";

		public override string EventName => "Power of The Elder";

		protected override string BlessingName => "Power of The Elder";

		protected override string StatusEffectName => "GP_TheElder";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.2f, 0.8f, 0.2f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingElder.Value;
			}
			return false;
		}
	}
	public class BonemassBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_bonemass";

		public override string EventName => "Power of Bonemass";

		protected override string BlessingName => "Power of Bonemass";

		protected override string StatusEffectName => "GP_Bonemass";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.6f, 0.8f, 0.2f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingBonemass.Value;
			}
			return false;
		}
	}
	public class ModerBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_moder";

		public override string EventName => "Power of Moder";

		protected override string BlessingName => "Power of Moder";

		protected override string StatusEffectName => "GP_Moder";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.7f, 0.9f, 1f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingModer.Value;
			}
			return false;
		}
	}
	public class YagluthBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_yagluth";

		public override string EventName => "Power of Yagluth";

		protected override string BlessingName => "Power of Yagluth";

		protected override string StatusEffectName => "GP_Yagluth";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(1f, 0.4f, 0.1f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingYagluth.Value;
			}
			return false;
		}
	}
	public class QueenBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_queen";

		public override string EventName => "Power of The Queen";

		protected override string BlessingName => "Power of The Queen";

		protected override string StatusEffectName => "GP_Queen";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.8f, 0.2f, 0.8f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingQueen.Value;
			}
			return false;
		}
	}
	public class FaderBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_fader";

		public override string EventName => "Power of The Fader";

		protected override string BlessingName => "Power of The Fader";

		protected override string StatusEffectName => "GP_Fader";

		protected override float Duration => 1200f;

		protected override Color AnnouncementColor => new Color(0.9f, 0.9f, 0.5f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingFader.Value;
			}
			return false;
		}
	}
	public class DamageBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_damage";

		public override string EventName => "Blessing of Fury";

		protected override string BlessingName => "Blessing of Fury (+50% Damage)";

		protected override string StatusEffectName => "CorpseRun";

		protected override float Duration => 1800f;

		protected override Color AnnouncementColor => new Color(1f, 0.2f, 0.2f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingDamage.Value;
			}
			return false;
		}
	}
	public class DefenseBlessingEvent : BaseBlessingEvent
	{
		public override string EventId => "blessing_defense";

		public override string EventName => "Blessing of Iron Skin";

		protected override string BlessingName => "Blessing of Iron Skin (+50% Defense)";

		protected override string StatusEffectName => "GP_Bonemass";

		protected override float Duration => 1800f;

		protected override Color AnnouncementColor => new Color(0.6f, 0.6f, 0.7f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableBlessingDefense.Value;
			}
			return false;
		}
	}
	public abstract class BaseEmoteEvent : BaseEvent
	{
		protected float _startTime;

		protected bool _completed;

		public static readonly HashSet<string> ActiveEmoters = new HashSet<string>();

		public static string ActiveEmoteCode = null;

		public static BaseEmoteEvent ActiveEvent = null;

		protected abstract string EmoteCode { get; }

		protected abstract float EventDuration { get; }

		protected abstract string StartAnnouncement { get; }

		protected abstract string SuccessAnnouncement { get; }

		protected abstract string FailAnnouncement { get; }

		protected override void OnEventStart()
		{
			_startTime = Time.time;
			_completed = false;
			ActiveEmoters.Clear();
			ActiveEmoteCode = EmoteCode;
			ActiveEvent = this;
			SendEventShout(StartAnnouncement);
			Debug.Log((object)("[AuroraEventManager] " + EventName + " started, listening for emote '" + EmoteCode + "'"));
		}

		protected override void OnEventStop()
		{
			ActiveEmoters.Clear();
			ActiveEmoteCode = null;
			ActiveEvent = null;
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (_completed)
			{
				return;
			}
			CheckEmoteZDOs();
			List<string> realPlayerNames = GetRealPlayerNames();
			if (realPlayerNames.Count > 0)
			{
				bool flag = true;
				foreach (string item in realPlayerNames)
				{
					if (!ActiveEmoters.Contains(item))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					_completed = true;
					OnAllEmotesCompleted(realPlayerNames);
					SendEventShout(SuccessAnnouncement);
					Stop();
					return;
				}
			}
			if (Time.time - _startTime >= EventDuration)
			{
				SendEventShout(FailAnnouncement);
				Stop();
			}
		}

		protected abstract void OnAllEmotesCompleted(List<string> playerNames);

		private void CheckEmoteZDOs()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			ZNet instance = ZNet.instance;
			List<ZNetPeer> list = ((instance != null) ? instance.GetPeers() : null);
			if (list == null)
			{
				return;
			}
			foreach (ZNetPeer item in list)
			{
				if (item == null || string.IsNullOrEmpty(item.m_playerName) || IsGhostName(item.m_playerName) || ActiveEmoters.Contains(item.m_playerName))
				{
					continue;
				}
				ZDOMan instance2 = ZDOMan.instance;
				ZDO val = ((instance2 != null) ? instance2.GetZDO(item.m_characterID) : null);
				if (val != null)
				{
					string @string = val.GetString("emote", "");
					if (!string.IsNullOrEmpty(@string) && @string.ToLower().Contains(EmoteCode.ToLower()))
					{
						ActiveEmoters.Add(item.m_playerName);
						Debug.Log((object)("[AuroraEventManager] " + EventName + ": " + item.m_playerName + " performed emote '" + @string + "'"));
					}
				}
			}
			if (!((Object)(object)Player.m_localPlayer != (Object)null))
			{
				return;
			}
			string playerName = Player.m_localPlayer.GetPlayerName();
			if (string.IsNullOrEmpty(playerName) || IsGhostName(playerName) || ActiveEmoters.Contains(playerName))
			{
				return;
			}
			ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
			ZDO val2 = ((component != null) ? component.GetZDO() : null);
			if (val2 != null)
			{
				string string2 = val2.GetString("emote", "");
				if (!string.IsNullOrEmpty(string2) && string2.ToLower().Contains(EmoteCode.ToLower()))
				{
					ActiveEmoters.Add(playerName);
				}
			}
		}

		protected static bool IsGhostName(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return false;
			}
			if (!name.Equals("Aurora", StringComparison.OrdinalIgnoreCase))
			{
				return name.StartsWith("Aurora", StringComparison.OrdinalIgnoreCase);
			}
			return true;
		}

		protected static List<string> GetRealPlayerNames()
		{
			List<string> list = new List<string>();
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				string playerName = Player.m_localPlayer.GetPlayerName();
				if (!string.IsNullOrEmpty(playerName) && !IsGhostName(playerName))
				{
					list.Add(playerName);
				}
			}
			ZNet instance = ZNet.instance;
			List<ZNetPeer> list2 = ((instance != null) ? instance.GetPeers() : null);
			if (list2 != null)
			{
				foreach (ZNetPeer item in list2)
				{
					if (item != null && !string.IsNullOrEmpty(item.m_playerName) && !IsGhostName(item.m_playerName) && !list.Contains(item.m_playerName))
					{
						list.Add(item.m_playerName);
					}
				}
			}
			return list;
		}

		public static void NotifyEmote(string playerName, string emote)
		{
			if (ActiveEvent != null && ActiveEmoteCode != null && !string.IsNullOrEmpty(playerName) && !string.IsNullOrEmpty(emote) && !IsGhostName(playerName) && emote.ToLower().Contains(ActiveEmoteCode.ToLower()))
			{
				ActiveEmoters.Add(playerName);
				Debug.Log((object)("[AuroraEventManager] NotifyEmote: " + playerName + " -> " + emote));
			}
		}
	}
	public class DanceOfFreyjaEvent : BaseEmoteEvent
	{
		public override string EventId => "dance_of_freyja";

		public override string EventName => "Freyja's Circle";

		protected override string EmoteCode => "dance";

		protected override float EventDuration => 90f;

		protected override string StartAnnouncement => "<color=#ffd700>[FREYJA'S CIRCLE]</color> <color=#ff88ff>Freyja the Golden</color> descends upon the realm! All vikings — type <color=#00ff00>/dance</color> or use the emote wheel (Dance) within <color=#ff6600>90 seconds</color> to earn her blessing: <color=#ffb6c1>+1 hour of Rested</color>!";

		protected override string SuccessAnnouncement => "<color=#ffd700>[FREYJA'S CIRCLE]</color> The Vanir goddess is pleased! All vikings receive her blessing — <color=#ffb6c1>+1 hour of Rested</color>. Dance in her halls forever!";

		protected override string FailAnnouncement => "<color=#ffd700>[FREYJA'S CIRCLE]</color> Not all vikings joined the dance. <color=#ff88ff>Freyja</color> turns away, disappointed.";

		public DanceOfFreyjaEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 7,
				MinPlayers = 1,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		public override bool CanStart()
		{
			if (!base.CanStart())
			{
				return false;
			}
			if (AuroraEventManagerPlugin.EnableDanceEvent != null && !AuroraEventManagerPlugin.EnableDanceEvent.Value)
			{
				return false;
			}
			return true;
		}

		protected override void OnAllEmotesCompleted(List<string> playerNames)
		{
			RewardHandler.SendBlessingToAllPlayers("Rested", 3600f);
			Debug.Log((object)$"[AuroraEventManager] DanceOfFreyja: blessing granted to {playerNames.Count} vikings");
		}
	}
	public class VibeWithDvergrEvent : BaseEmoteEvent
	{
		public override string EventId => "vibe_with_dvergr";

		public override string EventName => "Dwarven Work Song";

		protected override string EmoteCode => "vibe";

		protected override float EventDuration => 90f;

		protected override string StartAnnouncement => "<color=#ffd700>[DWARVEN WORK SONG]</color> The <color=#00ffff>Dvergr craftsmen</color> beckon from their mountain halls! All vikings — type <color=#00ff00>/vibe</color> in chat within <color=#ff6600>90 seconds</color> to earn the strength of giants: <color=#ffd700>+1000 carry weight for 6 hours</color>!";

		protected override string SuccessAnnouncement => "<color=#ffd700>[DWARVEN WORK SONG]</color> The Dvergr roar with pride! Their ancient work-song grants every viking <color=#ffd700>+1000 carry weight</color> for 6 hours. Haul your plunder home, warriors!";

		protected override string FailAnnouncement => "<color=#ffd700>[DWARVEN WORK SONG]</color> The <color=#00ffff>Dvergr</color> shake their heads and return to their halls.";

		public VibeWithDvergrEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 7,
				MinPlayers = 1,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		public override bool CanStart()
		{
			if (!base.CanStart())
			{
				return false;
			}
			if (AuroraEventManagerPlugin.EnableVibeEvent != null && !AuroraEventManagerPlugin.EnableVibeEvent.Value)
			{
				return false;
			}
			return true;
		}

		protected override void OnAllEmotesCompleted(List<string> playerNames)
		{
			foreach (string playerName in playerNames)
			{
				RewardHandler.ApplyWeightBuffToPlayer(playerName, 1000f, 21600f);
			}
			Debug.Log((object)$"[AuroraEventManager] VibeWithDvergr: weight buff granted to {playerNames.Count} vikings");
		}
	}
	[HarmonyPatch(typeof(Player), "StartEmote")]
	public static class Player_StartEmote_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Player __instance, string emote)
		{
			try
			{
				if (!((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(emote))
				{
					BaseEmoteEvent.NotifyEmote(__instance.GetPlayerName(), emote);
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Player_StartEmote_Patch error: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "TryRunCommand")]
	public static class Terminal_TryRunCommand_EmoteListener
	{
		[HarmonyPostfix]
		public static void Postfix(string text)
		{
			try
			{
				if (!string.IsNullOrEmpty(text))
				{
					string text2 = text.Trim().TrimStart(new char[1] { '/' }).ToLowerInvariant();
					if (!string.IsNullOrEmpty(text2) && BaseEmoteEvent.ActiveEmoteCode != null && text2.StartsWith(BaseEmoteEvent.ActiveEmoteCode.ToLowerInvariant()) && !((Object)(object)Player.m_localPlayer == (Object)null))
					{
						BaseEmoteEvent.NotifyEmote(Player.m_localPlayer.GetPlayerName(), BaseEmoteEvent.ActiveEmoteCode);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Terminal_TryRunCommand_EmoteListener error: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Chat), "SendText")]
	public static class Chat_SendText_EmoteListener
	{
		[HarmonyPostfix]
		public static void Postfix(string text)
		{
			try
			{
				if (string.IsNullOrEmpty(text))
				{
					return;
				}
				string text2 = text.Trim();
				if (!text2.StartsWith("/"))
				{
					return;
				}
				string text3 = text2.Substring(1).ToLowerInvariant().Split(new char[1] { ' ' })[0];
				if (BaseEmoteEvent.ActiveEmoteCode != null && !(text3 != BaseEmoteEvent.ActiveEmoteCode.ToLowerInvariant()) && !((Object)(object)Player.m_localPlayer == (Object)null))
				{
					BaseEmoteEvent.NotifyEmote(Player.m_localPlayer.GetPlayerName(), BaseEmoteEvent.ActiveEmoteCode);
					if (ZRoutedRpc.instance != null && (Object)(object)ZNet.instance != (Object)null)
					{
						ZNet.instance.IsServer();
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Chat_SendText_EmoteListener error: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Chat), "RPC_ChatMessage")]
	public static class Chat_RPC_ChatMessage_ServerEmoteListener
	{
		[HarmonyPostfix]
		public static void Postfix(long sender, Vector3 position, int type, UserInfo userInfo, string text)
		{
			try
			{
				if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || BaseEmoteEvent.ActiveEmoteCode == null || string.IsNullOrEmpty(text))
				{
					return;
				}
				string text2 = text.Trim();
				if (text2.StartsWith("/"))
				{
					text2 = text2.Substring(1);
				}
				if (!(text2.ToLowerInvariant().Split(new char[1] { ' ' })[0] != BaseEmoteEvent.ActiveEmoteCode.ToLowerInvariant()))
				{
					string text3 = userInfo?.Name;
					if (!string.IsNullOrEmpty(text3))
					{
						BaseEmoteEvent.NotifyEmote(text3, BaseEmoteEvent.ActiveEmoteCode);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Chat_RPC_ChatMessage_ServerEmoteListener error: " + ex.Message));
			}
		}
	}
	public class GuessNumberEvent : BaseEvent
	{
		private int _targetNumber;

		private float _eventStartTime;

		private float _eventDuration = 60f;

		private Dictionary<string, int> _playerGuesses = new Dictionary<string, int>();

		private bool _jackpotWon;

		public override string EventId => "guess_number";

		public override string EventName => "Guess the Number";

		public GuessNumberEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 8,
				MinPlayers = 1,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableGuessNumber.Value;
			}
			return false;
		}

		protected override void OnEventStart()
		{
			_targetNumber = Random.Range(1, 101);
			_eventStartTime = Time.time;
			_playerGuesses.Clear();
			_jackpotWon = false;
			string message = "<color=#FFD700>[GUESS THE NUMBER]</color> I'm thinking of a number between <color=#00FF00>1</color> and <color=#00FF00>100</color>! <color=#FFFF00>SHOUT your guess!</color> You have <color=#FF6600>60 seconds</color>! Jackpot for exact match: <color=#FFD700>5000 Coins + GoldIngot + 5 ReturnScroll!</color>";
			SendEventShout(message);
			Debug.Log((object)$"[AuroraEventManager] Guess the Number started. Target: {_targetNumber}");
		}

		protected override void OnEventStop()
		{
			if (!_jackpotWon)
			{
				DetermineWinner();
			}
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (!_jackpotWon && Time.time - _eventStartTime >= _eventDuration)
			{
				SendEventShout($"<color=#FFD700>[GUESS THE NUMBER]</color> Time's up! The number was <color=#00FF00>{_targetNumber}</color>!");
				Stop();
			}
		}

		public override void OnPlayerChat(string playerName, string message)
		{
			if (!_jackpotWon && int.TryParse(message.Trim(), out var result) && result >= 1 && result <= 100)
			{
				_playerGuesses[playerName] = result;
				Debug.Log((object)$"[AuroraEventManager] {playerName} guessed {result}");
				if (result == _targetNumber)
				{
					_jackpotWon = true;
					string message2 = $"<color=#FFD700>★★★ JACKPOT! ★★★</color> <color=#FFFF00>{playerName}</color> guessed the exact number <color=#00FF00>{_targetNumber}</color>! " + "Reward: <color=#FFD700>5000 Coins, 1 GoldIngot, 5 ReturnScroll!</color>";
					SendEventShout(message2);
					RewardHandler.GiveItemToPlayer(playerName, "Coins", 5000);
					RewardHandler.GiveItemToPlayer(playerName, "GoldIngot", 1);
					RewardHandler.GiveItemToPlayer(playerName, "ReturnScroll", 5);
					Stop();
				}
			}
		}

		private void DetermineWinner()
		{
			if (_playerGuesses.Count == 0)
			{
				SendEventShout("<color=#FFD700>[GUESS THE NUMBER]</color> No valid guesses were made!");
				return;
			}
			string text = null;
			int num = int.MaxValue;
			foreach (KeyValuePair<string, int> playerGuess in _playerGuesses)
			{
				int num2 = Math.Abs(playerGuess.Value - _targetNumber);
				if (num2 < num && num2 <= 5)
				{
					num = num2;
					text = playerGuess.Key;
				}
			}
			if (text == null)
			{
				SendEventShout($"<color=#FFD700>[GUESS THE NUMBER]</color> No one was close enough! The number was <color=#00FF00>{_targetNumber}</color>.");
				return;
			}
			int num3 = 0;
			switch (num)
			{
			case 1:
				num3 = 2000;
				break;
			case 2:
				num3 = 1000;
				break;
			case 3:
				num3 = 500;
				break;
			case 4:
				num3 = 200;
				break;
			case 5:
				num3 = 100;
				break;
			}
			if (num3 > 0)
			{
				int num4 = _playerGuesses[text];
				string message = $"<color=#FFD700>[GUESS THE NUMBER]</color> <color=#FFFF00>{text}</color> was closest with <color=#00FF00>{num4}</color>! " + $"(Number was {_targetNumber}, off by {num}) Reward: <color=#FFD700>{num3} Coins!</color>";
				SendEventShout(message);
				RewardHandler.GiveItemToPlayer(text, "Coins", num3);
			}
		}
	}
	public abstract class BaseTeleportEvent : BaseEvent
	{
		private float _eventStartTime;

		private float _eventDuration = 15f;

		private HashSet<string> _teleportedPlayers = new HashSet<string>();

		protected abstract string LocationName { get; }

		protected abstract Vector3 TeleportPosition { get; }

		public BaseTeleportEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 9,
				MinPlayers = 1,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		protected override void OnEventStart()
		{
			_eventStartTime = Time.time;
			_teleportedPlayers.Clear();
			string message = "<color=#00FFFF>[FREE TELEPORT]</color> Free teleport to <color=#FFD700>" + LocationName + "</color>! <color=#FFFF00>SHOUT 'GO' to travel!</color> You have <color=#FF6600>15 seconds!</color>";
			SendEventShout(message);
			Debug.Log((object)("[AuroraEventManager] Free Teleport to " + LocationName + " started"));
		}

		protected override void OnEventStop()
		{
			SendEventShout($"<color=#00FFFF>[FREE TELEPORT]</color> Teleport to {LocationName} has ended. {_teleportedPlayers.Count} vikings traveled!");
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (Time.time - _eventStartTime >= _eventDuration)
			{
				Stop();
			}
		}

		public override void OnPlayerChat(string playerName, string message)
		{
			//IL_0038: 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)
			if (message.Trim().ToUpperInvariant() == "GO" && !_teleportedPlayers.Contains(playerName))
			{
				_teleportedPlayers.Add(playerName);
				TeleportPlayer(playerName, TeleportPosition);
				string message2 = "<color=#00FFFF>[TELEPORT]</color> <color=#FFFF00>" + playerName + "</color> has teleported to <color=#FFD700>" + LocationName + "</color>!";
				SendEventShout(message2);
				Debug.Log((object)$"[AuroraEventManager] Teleported {playerName} to {LocationName} at {TeleportPosition}");
			}
		}

		private void TeleportPlayer(string playerName, Vector3 position)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			foreach (ZNetPeer peer in ZNet.instance.GetPeers())
			{
				if (peer != null && peer.m_playerName == playerName)
				{
					RewardHandler.TeleportPlayer(peer.m_uid, position);
					break;
				}
			}
		}
	}
	public class TeleportHaldorEvent : BaseTeleportEvent
	{
		public override string EventId => "teleport_haldor";

		public override string EventName => "Free Teleport to Haldor";

		protected override string LocationName => "Haldor the Trader";

		protected override Vector3 TeleportPosition => new Vector3(1613f, 40f, -3722f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTeleportHaldor.Value;
			}
			return false;
		}
	}
	public class TeleportHildirEvent : BaseTeleportEvent
	{
		public override string EventId => "teleport_hildir";

		public override string EventName => "Free Teleport to Hildir";

		protected override string LocationName => "Hildir the Merchant";

		protected override Vector3 TeleportPosition => new Vector3(512f, 50f, 1472f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTeleportHildir.Value;
			}
			return false;
		}
	}
	public class TeleportChokepointAEvent : BaseTeleportEvent
	{
		public override string EventId => "teleport_chokepoint_a";

		public override string EventName => "Free Teleport to Chokepoint A";

		protected override string LocationName => "Chokepoint A";

		protected override Vector3 TeleportPosition => new Vector3(389f, 35f, -389f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTeleportChokepointA.Value;
			}
			return false;
		}
	}
	public class TeleportChokepointBEvent : BaseTeleportEvent
	{
		public override string EventId => "teleport_chokepoint_b";

		public override string EventName => "Free Teleport to Chokepoint B";

		protected override string LocationName => "Chokepoint B";

		protected override Vector3 TeleportPosition => new Vector3(356f, 31f, 5099f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTeleportChokepointB.Value;
			}
			return false;
		}
	}
	public class TeleportChokepointCEvent : BaseTeleportEvent
	{
		public override string EventId => "teleport_chokepoint_c";

		public override string EventName => "Free Teleport to Chokepoint C";

		protected override string LocationName => "Chokepoint C";

		protected override Vector3 TeleportPosition => new Vector3(389f, 46f, -3644f);

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTeleportChokepointC.Value;
			}
			return false;
		}
	}
	public class ReactionEvent : BaseEvent
	{
		private string _targetWord;

		private float _eventStartTime;

		private float _eventDuration = 30f;

		private bool _winnerFound;

		private static readonly string[] ReactionWords = new string[120]
		{
			"ENCYCLOPEDIA", "REVOLUTIONARY", "EXTRAORDINARY", "CONGRATULATIONS", "COMMUNICATION", "RESPONSIBILITY", "UNDERSTANDING", "INTERNATIONAL", "ENVIRONMENTAL", "REPRESENTATIVE",
			"UNFORTUNATELY", "ADMINISTRATION", "ARCHAEOLOGICAL", "AUTOBIOGRAPHY", "BIODEGRADABLE", "CARDIOVASCULAR", "CHOREOGRAPHER", "CIRCUMFERENCE", "CLAUSTROPHOBIC", "COMMERCIALIZE",
			"COMPREHENSIVE", "CONCENTRATION", "CONFEDERATION", "CONSCIOUSNESS", "CONSTELLATION", "CONTAMINATION", "CONTROVERSIAL", "CRYSTALLIZATION", "DEFORESTATION", "DEMONSTRATION",
			"DETERMINATION", "DISAPPOINTMENT", "DISCRIMINATORY", "ELECTROMAGNETIC", "ENCAPSULATION", "ENTERTAINMENT", "ESTABLISHMENT", "EXPERIMENTATION", "EXTRAVAGANZA", "FORTIFICATION",
			"GENERALIZATION", "HALLUCINATION", "HORTICULTURIST", "HOSPITALIZATION", "HYPERVENTILATE", "IDENTIFICATION", "IMMOBILIZATION", "IMPLEMENTATION", "IMPROVISATION", "INCARCERATION",
			"INDESCRIBABLE", "INDISPENSABLE", "INFRASTRUCTURE", "INITIALIZATION", "INSTRUMENTATION", "INTERCONTINENTAL", "INTERPRETATION", "INVESTIGATION", "JUSTIFICATION", "KALEIDOSCOPE",
			"KNOWLEDGEABLE", "MATHEMATICIAN", "MEDITERRANEAN", "METEOROLOGICAL", "MICROPROCESSOR", "MISCELLANEOUS", "MISUNDERSTANDING", "MULTIPLICATION", "NATIONALIZATION", "NEIGHBORHOOD",
			"OBJECTIFICATION", "ORGANIZATIONAL", "OUTSTANDINGLY", "OVERCOMPENSATE", "OVERWHELMING", "PARLIAMENTARIAN", "PHARMACEUTICAL", "PHOTOSYNTHESIS", "PHYSIOTHERAPIST", "POLITICIZATION",
			"PREDETERMINATION", "PROFESSIONALISM", "PROPORTIONALLY", "PSYCHOLOGICALLY", "QUADRILATERAL", "QUALIFICATIONS", "QUESTIONNAIRE", "RATIONALIZATION", "RECOMMENDATION", "RECONCILIATION",
			"REHABILITATION", "REIMBURSEMENT", "REINFORCEMENT", "REORGANIZATION", "REPRESENTATIVE", "STANDARDIZATION", "STEREOTYPICAL", "SUBCONSCIOUSLY", "SUPERINTENDENT", "SUPPLEMENTARY",
			"SYNCHRONIZATION", "TECHNOLOGICAL", "TELECOMMUNICATIONS", "TEMPERAMENTAL", "THERMODYNAMICS", "TRANSFORMATION", "TRANSLITERATION", "TRANSPORTATION", "TROUBLESHOOTING", "ULTRAVIOLET",
			"UNCOMFORTABLE", "UNDERESTIMATE", "UNPRECEDENTED", "UNQUESTIONABLE", "VASCULARIZATION", "VISUALIZATION", "VULNERABILITIES", "WEATHERIZATION", "WHISTLEBLOWER", "WORKMANSHIP"
		};

		public override string EventId => "reaction";

		public override string EventName => "Reaction Challenge";

		public ReactionEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 8,
				MinPlayers = 3,
				IsGlobalEvent = true,
				RequiresTargetPlayer = false
			};
		}

		public override bool CanStart()
		{
			if (!base.CanStart())
			{
				return false;
			}
			if (!AuroraEventManagerPlugin.EnableReaction.Value)
			{
				return false;
			}
			ZNet instance = ZNet.instance;
			return ((instance == null) ? null : instance.GetPeers()?.Count).GetValueOrDefault() >= 3;
		}

		protected override void OnEventStart()
		{
			_targetWord = ReactionWords[Random.Range(0, ReactionWords.Length)];
			_eventStartTime = Time.time;
			_winnerFound = false;
			string message = "<color=#FF00FF>[REACTION]</color> <color=#FFFF00>TYPE THIS WORD FIRST:</color> <color=#00FF00>" + _targetWord + "</color> <color=#AAAAAA>(SHOUT it!)</color>";
			SendEventShout(message);
			Debug.Log((object)("[AuroraEventManager] Reaction challenge started. Word: " + _targetWord));
		}

		protected override void OnEventStop()
		{
			if (!_winnerFound)
			{
				SendEventShout("<color=#FF00FF>[REACTION]</color> Time's up! No one typed <color=#00FF00>" + _targetWord + "</color> correctly!");
			}
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (!_winnerFound && Time.time - _eventStartTime >= _eventDuration)
			{
				Stop();
			}
		}

		public override void OnPlayerChat(string playerName, string message)
		{
			if (!_winnerFound && message.Trim().ToUpperInvariant() == _targetWord)
			{
				_winnerFound = true;
				float num = Time.time - _eventStartTime;
				string message2 = "<color=#FF00FF>[REACTION]</color> <color=#FFD700>★ WINNER ★</color> " + $"<color=#FFFF00>{playerName}</color> typed it first in <color=#00FF00>{num:F2}s</color>!";
				SendEventShout(message2);
				GiveReactionReward(playerName);
				Stop();
			}
		}

		private void GiveReactionReward(string playerName)
		{
			string[] array = new string[6] { "Coins", "Amber", "AmberPearl", "Ruby", "SilverNecklace", "GoldNecklace" };
			int[] obj = new int[6] { 500, 5, 3, 2, 1, 1 };
			int num = Random.Range(0, array.Length);
			string text = array[num];
			int num2 = obj[num];
			RewardHandler.GiveItemToPlayer(playerName, text, num2);
			Debug.Log((object)$"[AuroraEventManager] Reaction reward: {num2}x {text} to {playerName}");
		}
	}
	public class TreasureGiantEvent : BaseMonsterEvent
	{
		public override string EventId => "treasure_giant";

		public override string EventName => "Treasure Giant";

		protected override string CustomPrefabName => "AEM_TreasureGiant";

		protected override MonsterEventType EventType => MonsterEventType.Giant;

		protected override string StatusEffectOnHit => "Frost";

		protected override bool MonsterFlees => false;

		protected override string[] ItemPool => new string[5] { "Coins", "Amber", "AmberPearl", "Ruby", "SilverNecklace" };

		protected override int HitDropMin => 5;

		protected override int HitDropMax => 15;

		protected override int KillDropMin => 100;

		protected override int KillDropMax => 200;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTreasureGiant.Value;
			}
			return false;
		}
	}
	public class TreasureSwarmEvent : BaseMonsterEvent
	{
		public override string EventId => "treasure_swarm";

		public override string EventName => "Treasure Swarm";

		protected override string CustomPrefabName => "AEM_TreasureGoblin";

		protected override MonsterEventType EventType => MonsterEventType.Swarm;

		protected override string StatusEffectOnHit => "";

		protected override bool MonsterFlees => true;

		protected override string[] ItemPool => new string[3] { "Coins", "Amber", "AmberPearl" };

		protected override int HitDropMin => 2;

		protected override int HitDropMax => 5;

		protected override int KillDropMin => 20;

		protected override int KillDropMax => 40;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableTreasureSwarm.Value;
			}
			return false;
		}
	}
	public class FavorGiantEvent : BaseMonsterEvent
	{
		public override string EventId => "favor_giant";

		public override string EventName => "Favor Dragon";

		protected override string CustomPrefabName => "AEM_FavorDragon";

		protected override MonsterEventType EventType => MonsterEventType.Giant;

		protected override string StatusEffectOnHit => "Frost";

		protected override bool MonsterFlees => false;

		protected override string[] ItemPool => new string[1] { "Favor" };

		protected override int HitDropMin => 1;

		protected override int HitDropMax => 3;

		protected override int KillDropMin => 20;

		protected override int KillDropMax => 40;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableFavorGiant.Value;
			}
			return false;
		}
	}
	public class FavorSwarmEvent : BaseMonsterEvent
	{
		public override string EventId => "favor_swarm";

		public override string EventName => "Favor Swarm";

		protected override string CustomPrefabName => "AEM_FavorDrake";

		protected override MonsterEventType EventType => MonsterEventType.Swarm;

		protected override string StatusEffectOnHit => "";

		protected override bool MonsterFlees => true;

		protected override string[] ItemPool => new string[1] { "Favor" };

		protected override int HitDropMin => 1;

		protected override int HitDropMax => 2;

		protected override int KillDropMin => 5;

		protected override int KillDropMax => 10;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableFavorSwarm.Value;
			}
			return false;
		}
	}
	public class MeatGiantEvent : BaseMonsterEvent
	{
		public override string EventId => "meat_giant";

		public override string EventName => "Meat Giant";

		protected override string CustomPrefabName => "AEM_MeatGiant";

		protected override MonsterEventType EventType => MonsterEventType.Giant;

		protected override string StatusEffectOnHit => "Burning";

		protected override bool MonsterFlees => false;

		protected override string[] ItemPool => new string[3] { "RawMeat", "CookedMeat", "LeatherScraps" };

		protected override int HitDropMin => 3;

		protected override int HitDropMax => 8;

		protected override int KillDropMin => 50;

		protected override int KillDropMax => 100;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableMeatGiant.Value;
			}
			return false;
		}
	}
	public class MeatSwarmEvent : BaseMonsterEvent
	{
		public override string EventId => "meat_swarm";

		public override string EventName => "Meat Swarm";

		protected override string CustomPrefabName => "AEM_MeatBoar";

		protected override MonsterEventType EventType => MonsterEventType.Swarm;

		protected override string StatusEffectOnHit => "";

		protected override bool MonsterFlees => true;

		protected override string[] ItemPool => new string[2] { "RawMeat", "LeatherScraps" };

		protected override int HitDropMin => 1;

		protected override int HitDropMax => 3;

		protected override int KillDropMin => 10;

		protected override int KillDropMax => 20;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableMeatSwarm.Value;
			}
			return false;
		}
	}
	public class MosquitoGiantEvent : BaseMonsterEvent
	{
		public override string EventId => "mosquito_giant";

		public override string EventName => "Giant Mosquito";

		protected override string CustomPrefabName => "AEM_GiantMosquito";

		protected override MonsterEventType EventType => MonsterEventType.Giant;

		protected override string StatusEffectOnHit => "Poison";

		protected override bool MonsterFlees => false;

		protected override string[] ItemPool => new string[2] { "VoidShardRed", "VoidShardBlue" };

		protected override int HitDropMin => 2;

		protected override int HitDropMax => 5;

		protected override int KillDropMin => 30;

		protected override int KillDropMax => 60;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableMosquitoGiant.Value;
			}
			return false;
		}
	}
	public class MosquitoSwarmEvent : BaseMonsterEvent
	{
		public override string EventId => "mosquito_swarm";

		public override string EventName => "Mosquito Swarm";

		protected override string CustomPrefabName => "AEM_VoidMosquito";

		protected override MonsterEventType EventType => MonsterEventType.Swarm;

		protected override string StatusEffectOnHit => "";

		protected override bool MonsterFlees => true;

		protected override string[] ItemPool => new string[2] { "VoidShardRed", "VoidShardBlue" };

		protected override int HitDropMin => 1;

		protected override int HitDropMax => 2;

		protected override int KillDropMin => 8;

		protected override int KillDropMax => 15;

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableMosquitoSwarm.Value;
			}
			return false;
		}
	}
	public class ArrowRainEvent : BaseEvent
	{
		private float _eventStartTime;

		private float _eventDuration = 60f;

		private float _lastDropTime;

		private float _dropInterval;

		private int _totalDropped;

		private int _maxDrops = 250;

		private string _arrowType;

		private long _targetPlayerUID;

		private static readonly string[] ArrowPrefabs = new string[14]
		{
			"ArrowWood", "ArrowFire", "ArrowFlint", "ArrowBronze", "ArrowIron", "ArrowSilver", "ArrowObsidian", "ArrowPoison", "ArrowFrost", "ArrowNeedle",
			"ArrowCarapace", "ArrowSpine", "ArrowFlametal", "ArrowFlametalNew"
		};

		public override string EventId => "arrow_rain";

		public override string EventName => "Ullr's Arrow Rain";

		public ArrowRainEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 8,
				MinPlayers = 1,
				IsGlobalEvent = false,
				RequiresTargetPlayer = true
			};
		}

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableArrowRain.Value;
			}
			return false;
		}

		protected override void OnEventStart()
		{
			_eventStartTime = Time.time;
			_lastDropTime = Time.time;
			_totalDropped = 0;
			_maxDrops = Random.Range(20, 667);
			_dropInterval = _eventDuration / (float)_maxDrops;
			if (_dropInterval < 0.05f)
			{
				_dropInterval = 0.05f;
			}
			_arrowType = ArrowPrefabs[Random.Range(0, ArrowPrefabs.Length)];
			_targetPlayerUID = GetPlayerUID(base.TargetPlayerName);
			string itemDisplayName = GetItemDisplayName(_arrowType);
			SendEventShout("<color=#8B4513>[ULLR'S ARROWS]</color> <color=#FFD700>Ullr the Hunter</color> blesses <color=#FFFF00>" + base.TargetPlayerName + "</color> with his arrows: <color=#90EE90>" + itemDisplayName + "</color>!");
			Debug.Log((object)$"[AuroraEventManager] Arrow Rain started for {base.TargetPlayerName} - {_arrowType} x{_maxDrops}");
		}

		protected override void OnEventStop()
		{
			SendEventShout($"<color=#8B4513>[ULLR'S ARROWS]</color> The arrow rain ends. <color=#FFFF00>{base.TargetPlayerName}</color> received <color=#90EE90>{_totalDropped}</color> drops!");
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (Time.time - _eventStartTime >= _eventDuration || _totalDropped >= _maxDrops)
			{
				Stop();
			}
			else if (Time.time - _lastDropTime >= _dropInterval)
			{
				_lastDropTime = Time.time;
				DropArrowAbovePlayer();
			}
		}

		private void DropArrowAbovePlayer()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 currentPlayerPosition = GetCurrentPlayerPosition();
			if (currentPlayerPosition == Vector3.zero)
			{
				return;
			}
			float num = Random.Range(-5f, 5f);
			float num2 = Random.Range(-5f, 5f);
			Vector3 val = currentPlayerPosition + new Vector3(num, 15f + Random.Range(0f, 5f), num2);
			ObjectDB instance = ObjectDB.instance;
			GameObject val2 = ((instance != null) ? instance.GetItemPrefab(_arrowType) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)("[AuroraEventManager] Arrow prefab not found: " + _arrowType));
				_totalDropped++;
				return;
			}
			ItemDrop component = Object.Instantiate<GameObject>(val2, val, Quaternion.identity).GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_itemData.m_stack = Random.Range(3, 16);
			}
			_totalDropped++;
		}

		private Vector3 GetCurrentPlayerPosition()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0059: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			ZNet instance = ZNet.instance;
			List<ZNetPeer> list = ((instance != null) ? instance.GetPeers() : null);
			if (list == null)
			{
				return Vector3.zero;
			}
			foreach (ZNetPeer item in list)
			{
				if (item == null || item.m_uid != _targetPlayerUID)
				{
					continue;
				}
				ZDOID characterID = item.m_characterID;
				if (!((ZDOID)(ref characterID)).IsNone())
				{
					ZDOMan instance2 = ZDOMan.instance;
					ZDO val = ((instance2 != null) ? instance2.GetZDO(characterID) : null);
					if (val != null)
					{
						return val.GetPosition();
					}
				}
			}
			return base.TargetPosition;
		}

		private long GetPlayerUID(string playerName)
		{
			ZNet instance = ZNet.instance;
			List<ZNetPeer> list = ((instance != null) ? instance.GetPeers() : null);
			if (list == null)
			{
				return 0L;
			}
			foreach (ZNetPeer item in list)
			{
				if (item != null && item.m_playerName == playerName)
				{
					return item.m_uid;
				}
			}
			return 0L;
		}

		private string GetItemDisplayName(string prefabName)
		{
			try
			{
				ObjectDB instance = ObjectDB.instance;
				GameObject val = ((instance != null) ? instance.GetItemPrefab(prefabName) : null);
				if ((Object)(object)val != (Object)null)
				{
					ItemDrop component = val.GetComponent<ItemDrop>();
					if ((Object)(object)component != (Object)null)
					{
						return Localization.instance.Localize(component.m_itemData.m_shared.m_name);
					}
				}
			}
			catch
			{
			}
			return prefabName;
		}
	}
	public class ChainRainEvent : BaseEvent
	{
		private float _eventStartTime;

		private float _eventDuration = 60f;

		private float _lastDropTime;

		private float _dropInterval;

		private int _totalDropped;

		private int _maxDrops = 250;

		private long _targetPlayerUID;

		public override string EventId => "chain_rain";

		public override string EventName => "Loki's Chain Rain";

		public ChainRainEvent()
		{
			Config = new EventConfig
			{
				Enabled = true,
				Weight = 3,
				MinPlayers = 1,
				IsGlobalEvent = false,
				RequiresTargetPlayer = true
			};
		}

		public override bool CanStart()
		{
			if (base.CanStart())
			{
				return AuroraEventManagerPlugin.EnableChainRain.Value;
			}
			return false;
		}

		protected override void OnEventStart()
		{
			_eventStartTime = Time.time;
			_lastDropTime = Time.time;
			_totalDropped = 0;
			_maxDrops = Random.Range(1, 41);
			_dropInterval = _eventDuration / (float)_maxDrops;
			if (_dropInterval < 0.05f)
			{
				_dropInterval = 0.05f;
			}
			_targetPlayerUID = GetPlayerUID(base.TargetPlayerName);
			SendEventShout("<color=#888888>[LOKI'S CHAINS]</color> <color=#FFD700>Loki's chains</color> rain from the sky upon <color=#FFFF00>" + base.TargetPlayerName + "</color>!");
			Debug.Log((object)$"[AuroraEventManager] Chain Rain started for {base.TargetPlayerName} - x{_maxDrops}");
		}

		protected override void OnEventStop()
		{
			SendEventShout($"<color=#888888>[LOKI'S CHAINS]</color> The chains stop falling. <color=#FFFF00>{base.TargetPlayerName}</color> received <color=#90EE90>{_totalDropped}</color> chains!");
			EventManagerCore.Instance?.OnEventEnded(this);
		}

		protected override void OnEventUpdate()
		{
			if (Time.time - _eventStartTime >= _eventDuration || _totalDropped >= _maxDrops)
			{
				Stop();
			}
			else if (Time.time - _lastDropTime >= _dropInterval)
			{
				_lastDropTime = Time.time;
				DropChainAbovePlayer();
			}
		}

		private void DropChainAbovePlayer()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Vector3 currentPlayerPosition = GetCurrentPlayerPosition();
			if (currentPlayerPosition == Vector3.zero)
			{
				return;
			}
			float num = Random.Range(-5f, 5f);
			float num2 = Random.Range(-5f, 5f);
			Vector3 val = currentPlayerPosition + new Vector3(num, 15f + Random.Range(0f, 5f), num2);
			ObjectDB instance = ObjectDB.instance;
			GameObject val2 = ((instance != null) ? instance.GetItemPrefab("Chain") : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)"[AuroraEventManager] Chain prefab not found!");
				_totalDropped++;
				return;
			}
			ItemDrop component = Object.Instantiate<GameObject>(val2, val, Quaternion.identity).GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_itemData.m_stack = 1;
			}
			_totalDropped++;
		}

		private Vector3 GetCurrentPlayerPosition()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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 (migh