Decompiled source of FehuWarbands v421.101.5

FehuWarbands.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("FehuWarbands")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Hostile Player-Model Raiders & Infused Loot Mod for Valheim")]
[assembly: AssemblyFileVersion("420.101.4.0")]
[assembly: AssemblyInformationalVersion("420.101.4")]
[assembly: AssemblyProduct("FehuWarbands")]
[assembly: AssemblyTitle("FehuWarbands")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("420.101.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FehuWarbands
{
	[HarmonyPatch]
	internal static class AdminTestCommands
	{
		private const string RequestRpc = "FehuWarbands_AdminTest";

		private const string ResultRpc = "FehuWarbands_AdminTestResult";

		internal const string Usage = "Usage: fehuwarbands_spawn <Warrior|Pillager|Chieftain> <clanId>";

		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		[HarmonyPostfix]
		private static void RegisterPeer(ZNetPeer peer)
		{
			peer.m_rpc.Register<string, string>("FehuWarbands_AdminTest", (Action<ZRpc, string, string>)ReceiveRequest);
			peer.m_rpc.Register<string>("FehuWarbands_AdminTestResult", (Action<ZRpc, string>)ReceiveResult);
		}

		internal static void SpawnCommand(ConsoleEventArgs args)
		{
			Submit(args, testClans: false);
		}

		internal static void TestClansCommand(ConsoleEventArgs args)
		{
			Submit(args, testClans: true);
		}

		private static void Submit(ConsoleEventArgs args, bool testClans)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ZNet instance = ZNet.instance;
				if ((Object)(object)instance == (Object)null || !instance.LocalPlayerIsAdminOrHost())
				{
					args.Context.AddString("FehuWarbands: denied; server admin/host permission required.");
					return;
				}
				if (testClans && args.Length != 1)
				{
					args.Context.AddString("Usage: fehuwarbands_testclans");
					return;
				}
				string text = (testClans ? "testclans" : ((args.Length > 1) ? args[1] : null));
				string text2 = (testClans ? "" : ((args.Length == 3) ? args[2] : null));
				if (!testClans && !TryParse(text, text2, out var _, out var _, out var error))
				{
					args.Context.AddString(error);
					return;
				}
				if (instance.IsServer())
				{
					args.Context.AddString(Execute(isServer: true, authorized: true, instance.LocalPlayerCharacterID, text, text2));
					return;
				}
				ZRpc serverRPC = instance.GetServerRPC();
				if (serverRPC == null)
				{
					args.Context.AddString("FehuWarbands: server connection unavailable.");
					return;
				}
				serverRPC.Invoke("FehuWarbands_AdminTest", new object[2] { text, text2 });
				args.Context.AddString("FehuWarbands: admin test request sent to server.");
			}
			catch (Exception ex)
			{
				args.Context.AddString("FehuWarbands: command failed: " + ex.Message);
			}
		}

		private static void ReceiveRequest(ZRpc rpc, string role, string clan)
		{
			//IL_0062: 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)
			ZNet instance = ZNet.instance;
			if (!((Object)(object)instance == (Object)null) && instance.IsServer())
			{
				ZNetPeer val = instance.GetPeers().Find((ZNetPeer p) => p.m_rpc == rpc && p.IsReady() && !p.m_server);
				bool authorized = val != null && instance.IsAdmin(val.m_socket.GetHostName());
				string text;
				try
				{
					text = Execute(isServer: true, authorized, val?.m_characterID ?? ZDOID.None, role, clan);
				}
				catch (Exception ex)
				{
					text = "FehuWarbands: command failed: " + ex.Message;
				}
				rpc.Invoke("FehuWarbands_AdminTestResult", new object[1] { text });
			}
		}

		private static void ReceiveResult(ZRpc rpc, string result)
		{
			if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer() && rpc == ZNet.instance.GetServerRPC())
			{
				Console instance = Console.instance;
				if (instance != null)
				{
					((Terminal)instance).AddString(result);
				}
			}
		}

		internal static bool TryParse(string roleText, string clanText, out RaiderRole role, out string clan, out string error)
		{
			role = RaiderRole.Warrior;
			clan = null;
			error = "Usage: fehuwarbands_spawn <Warrior|Pillager|Chieftain> <clanId>";
			if (string.IsNullOrWhiteSpace(roleText) || string.IsNullOrWhiteSpace(clanText))
			{
				return false;
			}
			if (string.Equals(roleText, "Warrior", StringComparison.OrdinalIgnoreCase))
			{
				role = RaiderRole.Warrior;
			}
			else if (string.Equals(roleText, "Pillager", StringComparison.OrdinalIgnoreCase))
			{
				role = RaiderRole.Pillager;
			}
			else
			{
				if (!string.Equals(roleText, "Chieftain", StringComparison.OrdinalIgnoreCase))
				{
					error = "FehuWarbands: invalid role. Usage: fehuwarbands_spawn <Warrior|Pillager|Chieftain> <clanId>";
					return false;
				}
				role = RaiderRole.Chieftain;
			}
			clan = clanText.Trim().ToUpperInvariant();
			if (clan.Length > 64)
			{
				error = "FehuWarbands: clan ID must be 1-64 letters, digits, '_' or '-'.";
				return false;
			}
			string text = clan;
			foreach (char c in text)
			{
				if ((c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_' && c != '-')
				{
					error = "FehuWarbands: invalid clan ID; use letters, digits, '_' or '-'.";
					return false;
				}
			}
			error = null;
			return true;
		}

		internal static string Execute(bool isServer, bool authorized, ZDOID playerId, string roleText, string clanText)
		{
			//IL_0065: 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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			if (!isServer || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return "FehuWarbands: server authority required.";
			}
			if (!authorized)
			{
				return "FehuWarbands: denied; server admin/host permission required.";
			}
			bool flag = roleText == "testclans";
			RaiderRole role = RaiderRole.Warrior;
			string clan = null;
			if (!flag && !TryParse(roleText, clanText, out role, out clan, out var error))
			{
				return error;
			}
			object obj;
			if (!((ZDOID)(ref playerId)).IsNone())
			{
				ZDOMan instance = ZDOMan.instance;
				obj = ((instance != null) ? instance.GetZDO(playerId) : null);
			}
			else
			{
				obj = null;
			}
			ZDO val = (ZDO)obj;
			if (val == null)
			{
				return "FehuWarbands: executing player is not available on the server.";
			}
			Vector3 position = val.GetPosition();
			if (float.IsNaN(position.x) || float.IsNaN(position.y) || float.IsNaN(position.z) || float.IsInfinity(position.x) || float.IsInfinity(position.y) || float.IsInfinity(position.z))
			{
				return "FehuWarbands: invalid server player position.";
			}
			if (!flag)
			{
				if (!Spawn(position + new Vector3(0f, 0f, 4f), role, clan))
				{
					return "FehuWarbands: spawn failed; check server logs.";
				}
				return "FehuWarbands spawned: " + role.ToString() + " " + clan;
			}
			int num = 0;
			for (int i = 0; i < 2; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					if (Spawn(position + new Vector3((i == 0) ? (-4f) : 4f, 0f, 6f + (float)j * 2f), (j == 2) ? RaiderRole.Pillager : RaiderRole.Warrior, (i == 0) ? "RED" : "BLUE"))
					{
						num++;
					}
				}
			}
			if (num != 6)
			{
				return "FehuWarbands: test clan spawn incomplete (" + num + "/6); check server logs.";
			}
			return "FehuWarbands test clans spawned: RED vs BLUE";
		}

		private static bool Spawn(Vector3 position, RaiderRole role, string clan)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return (Object)(object)RaiderAI.SpawnRaider(new RaiderAI.RaiderSpawnRequest(position, (Biome)1, role, clan)) != (Object)null;
		}
	}
	[HarmonyPatch(typeof(Character), "HaveEitr")]
	internal class CharacterHaveEitrPatch
	{
		private static bool Prefix(Character __instance, ref bool __result)
		{
			if (RaiderAI.IsRaider(__instance))
			{
				__result = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "OnDeath")]
	internal class CharacterOnDeathPatch
	{
		private const string DeathRpc = "FehuWarbands_RaiderDeath";

		internal static event Action<RaiderDeathState> RaiderDied;

		private static void Prefix(Character __instance, out RaiderDeathState __state)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			ZNetView nView = GameApiAccess.GetNView(__instance);
			if (!((Object)(object)nView == (Object)null) && nView.IsOwner() && !((Object)(object)ZNet.instance == (Object)null))
			{
				__state = RaiderDeathState.Capture(nView.GetZDO(), ((Component)__instance).transform.position);
			}
		}

		private static void Postfix(RaiderDeathState __state)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (__state == null || (Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			if (ZNet.instance.IsServer())
			{
				Dispatch(__state);
				return;
			}
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null)
			{
				instance.InvokeRoutedRPC("FehuWarbands_RaiderDeath", new object[1] { __state.CharacterId });
			}
		}

		internal static void RegisterRpc()
		{
			ZRoutedRpc.instance.Register<ZDOID>("FehuWarbands_RaiderDeath", (Action<long, ZDOID>)OnRemoteDeath);
		}

		private static void OnRemoteDeath(long sender, ZDOID characterId)
		{
			//IL_001f: 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)
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			ZDO zDO = ZDOMan.instance.GetZDO(characterId);
			if (zDO != null && zDO.GetOwner() == sender)
			{
				RaiderDeathState raiderDeathState = RaiderDeathState.Capture(zDO, zDO.GetPosition());
				if (raiderDeathState != null)
				{
					Dispatch(raiderDeathState);
				}
			}
		}

		private static void Dispatch(RaiderDeathState state)
		{
			RaiderEvents.OnRaiderKilled(state);
			if (state.IsChieftain)
			{
				RaiderCombatTrace.ChieftainDeath();
			}
			CharacterOnDeathPatch.RaiderDied?.Invoke(state);
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	internal static class RaiderDeathRpcRegistrationPatch
	{
		private static void Postfix()
		{
			CharacterOnDeathPatch.RegisterRpc();
		}
	}
	[HarmonyPatch(typeof(Character), "UseEitr")]
	internal class CharacterUseEitrPatch
	{
		private static bool Prefix(Character __instance)
		{
			if (RaiderAI.IsRaider(__instance))
			{
				return false;
			}
			return true;
		}
	}
	public sealed class ChieftainBehavior : WarriorBehavior
	{
	}
	public sealed class ChieftainBehaviorFactory : IRaiderBehaviorFactory
	{
		private readonly float _minAttackInterval;

		private readonly float _viewRangeMultiplier;

		public ChieftainBehaviorFactory(float minAttackInterval = 1.25f, float viewRangeMultiplier = 1.2f)
		{
			_minAttackInterval = Mathf.Max(0.3f, minAttackInterval);
			_viewRangeMultiplier = Mathf.Max(0.5f, viewRangeMultiplier);
		}

		public void Attach(GameObject raiderObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)raiderObject == (Object)null))
			{
				ChieftainBehavior chieftainBehavior = raiderObject.GetComponent<ChieftainBehavior>();
				if ((Object)chieftainBehavior == (Object)null)
				{
					chieftainBehavior = raiderObject.AddComponent<ChieftainBehavior>();
				}
				chieftainBehavior.Configure(_minAttackInterval, _viewRangeMultiplier);
			}
		}
	}
	public class CommandRegistration
	{
		public string name = "";

		public string description = "";

		public string[] commands = new string[0];

		public void AddCommand()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			new ConsoleCommand(name, description, (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				string[] array = commands;
				foreach (string text in array)
				{
					args.Context.TryRunCommand(text, false, false);
				}
			}, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}
	}
	[HarmonyPatch]
	internal class FehuWarbandsDevCommands
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class _003C_003Ec
		{
			public static readonly _003C_003Ec _003C_003E9 = new _003C_003Ec();

			public static ConsoleEvent _003C_003E9__0_0;

			public static ConsoleOptionsFetcher _003C_003E9__0_1;

			public static ConsoleEvent _003C_003E9__0_2;

			public static ConsoleOptionsFetcher _003C_003E9__0_3;

			public static ConsoleOptionsFetcher _003C_003E9__0_4;

			public static ConsoleEvent _003C_003E9__0_5;

			public static ConsoleEvent _003C_003E9__0_6;

			public static ConsoleEvent _003C_003E9__0_7;

			public static ConsoleEvent _003C_003E9__0_8;

			public static ConsoleOptionsFetcher _003C_003E9__0_9;

			public static ConsoleEvent _003C_003E9__0_10;

			public static ConsoleOptionsFetcher _003C_003E9__0_11;

			public static ConsoleEvent _003C_003E9__0_12;

			public static ConsoleEvent _003C_003E9__0_13;

			public static ConsoleEvent _003C_003E9__0_14;

			public static ConsoleOptionsFetcher _003C_003E9__0_15;

			public static ConsoleEvent _003C_003E9__0_16;

			internal void _003CAddCustomCommands_003Eb__0_0(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 2)
				{
					if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
					{
						val = result;
					}
					else
					{
						args.Context.AddString("Invalid biome: " + args[1] + ". Using Meadows.");
					}
				}
				bool result2 = false;
				if (args.Length >= 3)
				{
					bool.TryParse(args[2], out result2);
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
				if ((Object)RaiderAI.SpawnRaider(val2, val, result2) != (Object)null)
				{
					args.Context.AddString(string.Format("Spawned {0} for biome {1} at {2}", result2 ? "Chieftain" : "Raider", val, val2));
					FehuWarbandsPlugin.LogDebug($"Dev command spawned raider: Biome={val}, Chieftain={result2}, Pos={val2}");
				}
				else
				{
					args.Context.AddString("Failed to spawn raider - check logs");
				}
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_1()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal void _003CAddCustomCommands_003Eb__0_2(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: 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)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
				}
				else if (args.Length >= 2)
				{
					if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
					{
						RaiderEvents.StartRaidManually(result);
						args.Context.AddString($"Raider clan raid event started for {result}!");
						FehuWarbandsPlugin.LogDebug($"Dev command started raid event for biome {result}");
					}
					else
					{
						args.Context.AddString("Invalid biome '" + args[1] + "'.");
					}
				}
				else
				{
					RaiderEvents.StartRaidManually();
					args.Context.AddString("Raider clan raid event started!");
					FehuWarbandsPlugin.LogDebug("Dev command started raid event");
				}
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_3()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_4()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal void _003CAddCustomCommands_003Eb__0_5(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: 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)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Vector2s zone = ZoneSystem.GetZone(((Component)Player.m_localPlayer).transform.position);
				args.Context.AddString($"Processing zone {zone}...");
				FehuWarbandsPlugin.LogDebug($"Dev command processing zone: {zone}");
				int num = RaiderTowerOverwrites.ProcessZoneLocations(zone);
				args.Context.AddString($"Processed {num} locations in zone {zone}");
			}

			internal void _003CAddCustomCommands_003Eb__0_6(ConsoleEventArgs args)
			{
				if (args.Length >= 2)
				{
					if (args[1].ToLower() == "on")
					{
						FehuWarbandsPlugin.EnableDebugLogging.Value = true;
						args.Context.AddString("Debug logging enabled");
					}
					else if (args[1].ToLower() == "off")
					{
						FehuWarbandsPlugin.EnableDebugLogging.Value = false;
						args.Context.AddString("Debug logging disabled");
					}
				}
				else
				{
					args.Context.AddString("Debug logging is currently " + (FehuWarbandsPlugin.EnableDebugLogging.Value ? "enabled" : "disabled"));
				}
			}

			internal void _003CAddCustomCommands_003Eb__0_7(ConsoleEventArgs args)
			{
				HashSet<string> processedLocations = RaiderTowerOverwrites.GetProcessedLocations();
				args.Context.AddString($"Processed {processedLocations.Count} locations:");
				foreach (string item in processedLocations)
				{
					args.Context.AddString("  - " + item);
				}
			}

			internal void _003CAddCustomCommands_003Eb__0_8(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2 || !Enum.TryParse<RaiderRole>(args[1], ignoreCase: true, out var result) || !Enum.IsDefined(typeof(RaiderRole), result))
				{
					args.Context.AddString("Usage: fehuwarbands_spawnrole <Warrior|Pillager|Chieftain> [Biome]");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 3 && Enum.TryParse<Biome>(args[2], ignoreCase: true, out Biome result2))
				{
					val = result2;
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
				Humanoid val3 = RaiderAI.SpawnRaider(new RaiderAI.RaiderSpawnRequest(val2, val, result));
				args.Context.AddString(((Object)val3 != (Object)null) ? $"Spawned {result} with {val} loadout at {val2}" : "Failed to spawn raider");
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_9()
			{
				return new List<string> { "Warrior", "Pillager", "Chieftain" };
			}

			internal void _003CAddCustomCommands_003Eb__0_10(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Expected O, but got Unknown
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Expected O, but got Unknown
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: fehuwarbands_spawngarrison <tower|village> [radius]");
					return;
				}
				string text = args[1].ToLowerInvariant();
				float num = 20f;
				if (args.Length >= 3 && float.TryParse(args[2], out var result))
				{
					num = Mathf.Clamp(result, 5f, 50f);
				}
				GameObject val = new GameObject("FehuWarbands_GarrisonRoot");
				val.transform.position = ((Component)Player.m_localPlayer).transform.position;
				if (text == "tower")
				{
					RaiderTowerOverwrites.SpawnTowerRaiders(val);
					args.Context.AddString($"Spawned tower garrison at {val.transform.position} (radius {num})");
				}
				else if (text == "village")
				{
					RaiderTowerOverwrites.SpawnVillageRaiders(val);
					args.Context.AddString($"Spawned village garrison at {val.transform.position} (radius {num})");
				}
				else
				{
					args.Context.AddString("Invalid garrison type. Use 'tower' or 'village'.");
				}
				Object.Destroy((Object)val);
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_11()
			{
				return new List<string> { "tower", "village" };
			}

			internal void _003CAddCustomCommands_003Eb__0_12(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2 || !int.TryParse(args[1], out var result))
				{
					args.Context.AddString("Usage: fehuwarbands_wave <waveNumber>");
					return;
				}
				if (!RaiderEvents.IsRaidActive())
				{
					RaiderEvents.StartRaidManually();
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(RaiderEvents), "SpawnWave", (Type[])null, (Type[])null);
				for (int i = 0; i < result; i++)
				{
					methodInfo.Invoke(null, null);
				}
				args.Context.AddString($"Spawned raid wave {result}");
			}

			internal void _003CAddCustomCommands_003Eb__0_13(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 2 && Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
				{
					val = result;
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f;
				RaiderLoot.DropRegularLoot(val2, val);
				args.Context.AddString($"Spawned regular loot for {val} biome at {val2}");
			}

			internal void _003CAddCustomCommands_003Eb__0_14(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Expected O, but got Unknown
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: fehuwarbands_location_add <prefabName>");
					args.Context.AddString("Available locations:");
					args.Context.AddString("  - CombatRuin01 (Meadows, 5W+1C)");
					args.Context.AddString("  - WoodHouse3 (Meadows, 5W+1C)");
					args.Context.AddString("  - Mistlands_Excavation3 (Mistlands, 7W+1C)");
					args.Context.AddString("  - Ruin3 (Plains, 5W+1C)");
					args.Context.AddString("  - StoneTowerRuins05 (Mountain, 5W+1C)");
					args.Context.AddString("  - Runestone_Greydwarfs (BlackForest, 4W+1C)");
					return;
				}
				string text = args[1];
				if (!RaiderLocationManager.IsRaiderLocation(text))
				{
					args.Context.AddString("Unknown raider location: " + text);
					return;
				}
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				GameObject clonedLocationPrefab = RaiderLocationManager.GetClonedLocationPrefab(text);
				if ((Object)clonedLocationPrefab == (Object)null)
				{
					args.Context.AddString("Failed to get prefab for " + text);
				}
				else if ((Object)Object.Instantiate<GameObject>(clonedLocationPrefab, position, Quaternion.identity) != (Object)null)
				{
					RaiderLocationManager.LocationDefinition locationDefinition = RaiderLocationManager.GetLocationDefinition(text);
					args.Context.AddString($"Spawned {text} at {position} ({locationDefinition.WarriorCount}W + {locationDefinition.ChieftainCount}C)");
					FehuWarbandsPlugin.LogDebug($"Dev command spawned raider location: {text} at {position}");
				}
				else
				{
					args.Context.AddString("Failed to spawn location " + text);
				}
			}

			internal List<string> _003CAddCustomCommands_003Eb__0_15()
			{
				return new List<string> { "CombatRuin01", "WoodHouse3", "Mistlands_Excavation3", "Ruin3", "StoneTowerRuins05", "Runestone_Greydwarfs" };
			}

			internal void _003CAddCustomCommands_003Eb__0_16(ConsoleEventArgs args)
			{
				args.Context.AddString("Populating world with raider locations...");
				args.Context.AddString("This requires the upgrade_world mod to be installed.");
				args.Context.AddString("");
				args.Context.AddString("Execute these commands in the upgrade_world console:");
				args.Context.AddString("  locations_add FW_CombatRuin01 quantity=10");
				args.Context.AddString("  locations_add FW_WoodHouse3 quantity=10");
				args.Context.AddString("  locations_add FW_Mistlands_Excavation3 quantity=10");
				args.Context.AddString("  locations_add FW_Ruin3 quantity=10");
				args.Context.AddString("  locations_add FW_StoneTowerRuins05 quantity=10");
				args.Context.AddString("  locations_add FW_Runestone_Greydwarfs quantity=10");
				args.Context.AddString("");
				args.Context.AddString("This will add 10 of each raider location to both explored and unexplored areas:");
				args.Context.AddString("  - FW_CombatRuin01 (Meadows, 5W+1C)");
				args.Context.AddString("  - FW_WoodHouse3 (Meadows, 5W+1C)");
				args.Context.AddString("  - FW_Mistlands_Excavation3 (Mistlands, 7W+1C)");
				args.Context.AddString("  - FW_Ruin3 (Plains, 5W+1C)");
				args.Context.AddString("  - FW_StoneTowerRuins05 (Mountain, 5W+1C)");
				args.Context.AddString("  - FW_Runestone_Greydwarfs (BlackForest, 4W+1C)");
				FehuWarbandsPlugin.LogDebug("Dev command displayed raider location population instructions");
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static ConsoleEvent <0>__SpawnCommand;

			public static ConsoleEvent <1>__TestClansCommand;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__1_0;

			public static ConsoleOptionsFetcher <>9__1_1;

			public static ConsoleEvent <>9__1_2;

			public static ConsoleOptionsFetcher <>9__1_3;

			public static ConsoleOptionsFetcher <>9__1_4;

			public static ConsoleEvent <>9__1_5;

			public static ConsoleEvent <>9__1_6;

			public static ConsoleEvent <>9__1_7;

			public static ConsoleEvent <>9__1_8;

			public static ConsoleOptionsFetcher <>9__1_9;

			public static ConsoleEvent <>9__1_10;

			public static ConsoleOptionsFetcher <>9__1_11;

			public static ConsoleEvent <>9__1_12;

			public static ConsoleEvent <>9__1_13;

			public static ConsoleEvent <>9__1_14;

			public static ConsoleOptionsFetcher <>9__1_15;

			public static ConsoleEvent <>9__1_16;

			internal void <AddCustomCommands>b__1_0(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 2)
				{
					if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
					{
						val = result;
					}
					else
					{
						args.Context.AddString("Invalid biome: " + args[1] + ". Using Meadows.");
					}
				}
				bool result2 = false;
				if (args.Length >= 3)
				{
					bool.TryParse(args[2], out result2);
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
				if ((Object)RaiderAI.SpawnRaider(val2, val, result2) != (Object)null)
				{
					args.Context.AddString(string.Format("Spawned {0} for biome {1} at {2}", result2 ? "Chieftain" : "Raider", val, val2));
					FehuWarbandsPlugin.LogDebug($"Dev command spawned raider: Biome={val}, Chieftain={result2}, Pos={val2}");
				}
				else
				{
					args.Context.AddString("Failed to spawn raider - check logs");
				}
			}

			internal List<string> <AddCustomCommands>b__1_1()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal void <AddCustomCommands>b__1_2(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: 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)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
				}
				else if (args.Length >= 2)
				{
					if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
					{
						RaiderEvents.StartRaidManually(result);
						args.Context.AddString($"Raider clan raid event started for {result}!");
						FehuWarbandsPlugin.LogDebug($"Dev command started raid event for biome {result}");
					}
					else
					{
						args.Context.AddString("Invalid biome '" + args[1] + "'.");
					}
				}
				else
				{
					RaiderEvents.StartRaidManually();
					args.Context.AddString("Raider clan raid event started!");
					FehuWarbandsPlugin.LogDebug("Dev command started raid event");
				}
			}

			internal List<string> <AddCustomCommands>b__1_3()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal List<string> <AddCustomCommands>b__1_4()
			{
				return new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
			}

			internal void <AddCustomCommands>b__1_5(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: 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)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Vector2s zone = ZoneSystem.GetZone(((Component)Player.m_localPlayer).transform.position);
				args.Context.AddString($"Processing zone {zone}...");
				FehuWarbandsPlugin.LogDebug($"Dev command processing zone: {zone}");
				int num = RaiderTowerOverwrites.ProcessZoneLocations(zone);
				args.Context.AddString($"Processed {num} locations in zone {zone}");
			}

			internal void <AddCustomCommands>b__1_6(ConsoleEventArgs args)
			{
				if (args.Length >= 2)
				{
					if (args[1].ToLower() == "on")
					{
						FehuWarbandsPlugin.EnableDebugLogging.Value = true;
						args.Context.AddString("Debug logging enabled");
					}
					else if (args[1].ToLower() == "off")
					{
						FehuWarbandsPlugin.EnableDebugLogging.Value = false;
						args.Context.AddString("Debug logging disabled");
					}
				}
				else
				{
					args.Context.AddString("Debug logging is currently " + (FehuWarbandsPlugin.EnableDebugLogging.Value ? "enabled" : "disabled"));
				}
			}

			internal void <AddCustomCommands>b__1_7(ConsoleEventArgs args)
			{
				HashSet<string> processedLocations = RaiderTowerOverwrites.GetProcessedLocations();
				args.Context.AddString($"Processed {processedLocations.Count} locations:");
				foreach (string item in processedLocations)
				{
					args.Context.AddString("  - " + item);
				}
			}

			internal void <AddCustomCommands>b__1_8(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2 || !Enum.TryParse<RaiderRole>(args[1], ignoreCase: true, out var result) || !Enum.IsDefined(typeof(RaiderRole), result))
				{
					args.Context.AddString("Usage: fehuwarbands_spawnrole <Warrior|Pillager|Chieftain> [Biome]");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 3 && Enum.TryParse<Biome>(args[2], ignoreCase: true, out Biome result2))
				{
					val = result2;
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
				Humanoid val3 = RaiderAI.SpawnRaider(new RaiderAI.RaiderSpawnRequest(val2, val, result));
				args.Context.AddString(((Object)val3 != (Object)null) ? $"Spawned {result} with {val} loadout at {val2}" : "Failed to spawn raider");
			}

			internal List<string> <AddCustomCommands>b__1_9()
			{
				return new List<string> { "Warrior", "Pillager", "Chieftain" };
			}

			internal void <AddCustomCommands>b__1_10(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Expected O, but got Unknown
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Expected O, but got Unknown
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: fehuwarbands_spawngarrison <tower|village> [radius]");
					return;
				}
				string text = args[1].ToLowerInvariant();
				float num = 20f;
				if (args.Length >= 3 && float.TryParse(args[2], out var result))
				{
					num = Mathf.Clamp(result, 5f, 50f);
				}
				GameObject val = new GameObject("FehuWarbands_GarrisonRoot");
				val.transform.position = ((Component)Player.m_localPlayer).transform.position;
				if (text == "tower")
				{
					RaiderTowerOverwrites.SpawnTowerRaiders(val);
					args.Context.AddString($"Spawned tower garrison at {val.transform.position} (radius {num})");
				}
				else if (text == "village")
				{
					RaiderTowerOverwrites.SpawnVillageRaiders(val);
					args.Context.AddString($"Spawned village garrison at {val.transform.position} (radius {num})");
				}
				else
				{
					args.Context.AddString("Invalid garrison type. Use 'tower' or 'village'.");
				}
				Object.Destroy((Object)val);
			}

			internal List<string> <AddCustomCommands>b__1_11()
			{
				return new List<string> { "tower", "village" };
			}

			internal void <AddCustomCommands>b__1_12(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2 || !int.TryParse(args[1], out var result))
				{
					args.Context.AddString("Usage: fehuwarbands_wave <waveNumber>");
					return;
				}
				if (!RaiderEvents.IsRaidActive())
				{
					RaiderEvents.StartRaidManually();
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(RaiderEvents), "SpawnWave", (Type[])null, (Type[])null);
				for (int i = 0; i < result; i++)
				{
					methodInfo.Invoke(null, null);
				}
				args.Context.AddString($"Spawned raid wave {result}");
			}

			internal void <AddCustomCommands>b__1_13(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				Biome val = (Biome)1;
				if (args.Length >= 2 && Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
				{
					val = result;
				}
				Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f;
				RaiderLoot.DropRegularLoot(val2, val);
				args.Context.AddString($"Spawned regular loot for {val} biome at {val2}");
			}

			internal void <AddCustomCommands>b__1_14(ConsoleEventArgs args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Expected O, but got Unknown
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)Player.m_localPlayer != (Object)null))
				{
					args.Context.AddString("No local player found");
					return;
				}
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: fehuwarbands_location_add <prefabName>");
					args.Context.AddString("Available locations:");
					args.Context.AddString("  - CombatRuin01 (Meadows, 5W+1C)");
					args.Context.AddString("  - WoodHouse3 (Meadows, 5W+1C)");
					args.Context.AddString("  - Mistlands_Excavation3 (Mistlands, 7W+1C)");
					args.Context.AddString("  - Ruin3 (Plains, 5W+1C)");
					args.Context.AddString("  - StoneTowerRuins05 (Mountain, 5W+1C)");
					args.Context.AddString("  - Runestone_Greydwarfs (BlackForest, 4W+1C)");
					return;
				}
				string text = args[1];
				if (!RaiderLocationManager.IsRaiderLocation(text))
				{
					args.Context.AddString("Unknown raider location: " + text);
					return;
				}
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				GameObject clonedLocationPrefab = RaiderLocationManager.GetClonedLocationPrefab(text);
				if ((Object)clonedLocationPrefab == (Object)null)
				{
					args.Context.AddString("Failed to get prefab for " + text);
				}
				else if ((Object)Object.Instantiate<GameObject>(clonedLocationPrefab, position, Quaternion.identity) != (Object)null)
				{
					RaiderLocationManager.LocationDefinition locationDefinition = RaiderLocationManager.GetLocationDefinition(text);
					args.Context.AddString($"Spawned {text} at {position} ({locationDefinition.WarriorCount}W + {locationDefinition.ChieftainCount}C)");
					FehuWarbandsPlugin.LogDebug($"Dev command spawned raider location: {text} at {position}");
				}
				else
				{
					args.Context.AddString("Failed to spawn location " + text);
				}
			}

			internal List<string> <AddCustomCommands>b__1_15()
			{
				return new List<string> { "CombatRuin01", "WoodHouse3", "Mistlands_Excavation3", "Ruin3", "StoneTowerRuins05", "Runestone_Greydwarfs" };
			}

			internal void <AddCustomCommands>b__1_16(ConsoleEventArgs args)
			{
				args.Context.AddString("Populating world with raider locations...");
				args.Context.AddString("This requires the upgrade_world mod to be installed.");
				args.Context.AddString("");
				args.Context.AddString("Execute these commands in the upgrade_world console:");
				args.Context.AddString("  locations_add FW_CombatRuin01 quantity=10");
				args.Context.AddString("  locations_add FW_WoodHouse3 quantity=10");
				args.Context.AddString("  locations_add FW_Mistlands_Excavation3 quantity=10");
				args.Context.AddString("  locations_add FW_Ruin3 quantity=10");
				args.Context.AddString("  locations_add FW_StoneTowerRuins05 quantity=10");
				args.Context.AddString("  locations_add FW_Runestone_Greydwarfs quantity=10");
				args.Context.AddString("");
				args.Context.AddString("This will add 10 of each raider location to both explored and unexplored areas:");
				args.Context.AddString("  - FW_CombatRuin01 (Meadows, 5W+1C)");
				args.Context.AddString("  - FW_WoodHouse3 (Meadows, 5W+1C)");
				args.Context.AddString("  - FW_Mistlands_Excavation3 (Mistlands, 7W+1C)");
				args.Context.AddString("  - FW_Ruin3 (Plains, 5W+1C)");
				args.Context.AddString("  - FW_StoneTowerRuins05 (Mountain, 5W+1C)");
				args.Context.AddString("  - FW_Runestone_Greydwarfs (BlackForest, 4W+1C)");
				FehuWarbandsPlugin.LogDebug("Dev command displayed raider location population instructions");
			}
		}

		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		[HarmonyPostfix]
		private static void AddCustomCommands()
		{
			//IL_001b: 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_0026: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0048: 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_0053: Expected O, but got Unknown
			//IL_00be: 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)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_031b: Expected O, but got Unknown
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Expected O, but got Unknown
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Expected O, but got Unknown
			//IL_03a6: Expected O, but got Unknown
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Expected O, but got Unknown
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Expected O, but got Unknown
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Expected O, but got Unknown
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Expected O, but got Unknown
			//IL_04d7: Expected O, but got Unknown
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Expected O, but got Unknown
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Expected O, but got Unknown
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Expected O, but got Unknown
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Expected O, but got Unknown
			if (_003C_003Ec._003C_003E9__0_0 == null)
			{
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						//IL_0088: Unknown result type (might be due to invalid IL or missing references)
						//IL_0097: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ac: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c0: Expected O, but got Unknown
						//IL_003f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0040: Unknown result type (might be due to invalid IL or missing references)
						//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
						//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
						//IL_0103: Unknown result type (might be due to invalid IL or missing references)
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else
						{
							Biome val21 = (Biome)1;
							if (args.Length >= 2)
							{
								if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
								{
									val21 = result;
								}
								else
								{
									args.Context.AddString("Invalid biome: " + args[1] + ". Using Meadows.");
								}
							}
							bool result2 = false;
							if (args.Length >= 3)
							{
								bool.TryParse(args[2], out result2);
							}
							Vector3 val22 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
							if ((Object)RaiderAI.SpawnRaider(val22, val21, result2) != (Object)null)
							{
								args.Context.AddString(string.Format("Spawned {0} for biome {1} at {2}", result2 ? "Chieftain" : "Raider", val21, val22));
								FehuWarbandsPlugin.LogDebug($"Dev command spawned raider: Biome={val21}, Chieftain={result2}, Pos={val22}");
							}
							else
							{
								args.Context.AddString("Failed to spawn raider - check logs");
							}
						}
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				_003C_003Ec._003C_003E9__0_0 = (ConsoleEvent)obj;
			}
			if (_003C_003Ec._003C_003E9__0_1 == null)
			{
				object obj2 = <>c.<>9__1_1;
				if (obj2 == null)
				{
					ConsoleOptionsFetcher val2 = () => new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
					<>c.<>9__1_1 = val2;
					obj2 = (object)val2;
				}
				_003C_003Ec._003C_003E9__0_1 = (ConsoleOptionsFetcher)obj2;
			}
			object obj3 = <>O.<0>__SpawnCommand;
			if (obj3 == null)
			{
				ConsoleEvent val3 = AdminTestCommands.SpawnCommand;
				<>O.<0>__SpawnCommand = val3;
				obj3 = (object)val3;
			}
			new ConsoleCommand("fehuwarbands_spawn", "<role> <clanId> - Admin-only server-authoritative NPC test", (ConsoleEvent)obj3, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj4 = <>O.<1>__TestClansCommand;
			if (obj4 == null)
			{
				ConsoleEvent val4 = AdminTestCommands.TestClansCommand;
				<>O.<1>__TestClansCommand = val4;
				obj4 = (object)val4;
			}
			new ConsoleCommand("fehuwarbands_testclans", "- Admin-only RED vs BLUE combat test", (ConsoleEvent)obj4, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj5 = _003C_003Ec._003C_003E9__0_2;
			if (obj5 == null)
			{
				object obj6 = <>c.<>9__1_2;
				if (obj6 == null)
				{
					ConsoleEvent val5 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_003d: Unknown result type (might be due to invalid IL or missing references)
						//IL_004e: 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)
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else if (args.Length >= 2)
						{
							if (Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
							{
								RaiderEvents.StartRaidManually(result);
								args.Context.AddString($"Raider clan raid event started for {result}!");
								FehuWarbandsPlugin.LogDebug($"Dev command started raid event for biome {result}");
							}
							else
							{
								args.Context.AddString("Invalid biome '" + args[1] + "'.");
							}
						}
						else
						{
							RaiderEvents.StartRaidManually();
							args.Context.AddString("Raider clan raid event started!");
							FehuWarbandsPlugin.LogDebug("Dev command started raid event");
						}
					};
					<>c.<>9__1_2 = val5;
					obj6 = (object)val5;
				}
				_003C_003Ec._003C_003E9__0_2 = (ConsoleEvent)obj6;
				obj5 = obj6;
			}
			ConsoleEvent val6 = (ConsoleEvent)obj5;
			object obj7 = _003C_003Ec._003C_003E9__0_3;
			if (obj7 == null)
			{
				object obj8 = <>c.<>9__1_3;
				if (obj8 == null)
				{
					ConsoleOptionsFetcher val7 = () => new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
					<>c.<>9__1_3 = val7;
					obj8 = (object)val7;
				}
				_003C_003Ec._003C_003E9__0_3 = (ConsoleOptionsFetcher)obj8;
				obj7 = obj8;
			}
			new ConsoleCommand("fehuwarbands_startraid", "[biome] - Start a raider clan raid event (optional biome override)", val6, true, false, false, false, false, false, (ConsoleOptionsFetcher)obj7, false, false, false);
			object obj9 = _003C_003Ec._003C_003E9__0_4;
			if (obj9 == null)
			{
				object obj10 = <>c.<>9__1_4;
				if (obj10 == null)
				{
					ConsoleOptionsFetcher val8 = () => new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands" };
					<>c.<>9__1_4 = val8;
					obj10 = (object)val8;
				}
				_003C_003Ec._003C_003E9__0_4 = (ConsoleOptionsFetcher)obj10;
				obj9 = obj10;
			}
			new ConsoleCommand("fehuwarbands_startraid_alias", "[biome] - Alias for fehuwarbands_startraid", val6, true, false, false, false, false, false, (ConsoleOptionsFetcher)obj9, false, false, false);
			object obj11 = _003C_003Ec._003C_003E9__0_5;
			if (obj11 == null)
			{
				object obj12 = <>c.<>9__1_5;
				if (obj12 == null)
				{
					ConsoleEvent val9 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_002d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0058: Unknown result type (might be due to invalid IL or missing references)
						//IL_0068: 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)
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else
						{
							Vector2s zone = ZoneSystem.GetZone(((Component)Player.m_localPlayer).transform.position);
							args.Context.AddString($"Processing zone {zone}...");
							FehuWarbandsPlugin.LogDebug($"Dev command processing zone: {zone}");
							int num = RaiderTowerOverwrites.ProcessZoneLocations(zone);
							args.Context.AddString($"Processed {num} locations in zone {zone}");
						}
					};
					<>c.<>9__1_5 = val9;
					obj12 = (object)val9;
				}
				_003C_003Ec._003C_003E9__0_5 = (ConsoleEvent)obj12;
				obj11 = obj12;
			}
			new ConsoleCommand("fehuwarbands_processzone", "- Force process locations in current zone", (ConsoleEvent)obj11, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj13 = _003C_003Ec._003C_003E9__0_6;
			if (obj13 == null)
			{
				object obj14 = <>c.<>9__1_6;
				if (obj14 == null)
				{
					ConsoleEvent val10 = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 2)
						{
							if (args[1].ToLower() == "on")
							{
								FehuWarbandsPlugin.EnableDebugLogging.Value = true;
								args.Context.AddString("Debug logging enabled");
							}
							else if (args[1].ToLower() == "off")
							{
								FehuWarbandsPlugin.EnableDebugLogging.Value = false;
								args.Context.AddString("Debug logging disabled");
							}
						}
						else
						{
							args.Context.AddString("Debug logging is currently " + (FehuWarbandsPlugin.EnableDebugLogging.Value ? "enabled" : "disabled"));
						}
					};
					<>c.<>9__1_6 = val10;
					obj14 = (object)val10;
				}
				_003C_003Ec._003C_003E9__0_6 = (ConsoleEvent)obj14;
				obj13 = obj14;
			}
			new ConsoleCommand("fehuwarbands_debug", "[on/off] - Toggle debug logging", (ConsoleEvent)obj13, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj15 = _003C_003Ec._003C_003E9__0_7;
			if (obj15 == null)
			{
				object obj16 = <>c.<>9__1_7;
				if (obj16 == null)
				{
					ConsoleEvent val11 = delegate(ConsoleEventArgs args)
					{
						HashSet<string> processedLocations = RaiderTowerOverwrites.GetProcessedLocations();
						args.Context.AddString($"Processed {processedLocations.Count} locations:");
						foreach (string item in processedLocations)
						{
							args.Context.AddString("  - " + item);
						}
					};
					<>c.<>9__1_7 = val11;
					obj16 = (object)val11;
				}
				_003C_003Ec._003C_003E9__0_7 = (ConsoleEvent)obj16;
				obj15 = obj16;
			}
			new ConsoleCommand("fehuwarbands_listlocations", "- List all processed locations", (ConsoleEvent)obj15, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj17 = _003C_003Ec._003C_003E9__0_8;
			if (obj17 == null)
			{
				object obj18 = <>c.<>9__1_8;
				if (obj18 == null)
				{
					ConsoleEvent val12 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_0066: Unknown result type (might be due to invalid IL or missing references)
						//IL_008d: Unknown result type (might be due to invalid IL or missing references)
						//IL_009c: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
						//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
						//IL_00d6: Expected O, but got Unknown
						//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
						//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
						//IL_0081: Unknown result type (might be due to invalid IL or missing references)
						//IL_0082: Unknown result type (might be due to invalid IL or missing references)
						RaiderRole result;
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else if (args.Length < 2 || !Enum.TryParse<RaiderRole>(args[1], ignoreCase: true, out result) || !Enum.IsDefined(typeof(RaiderRole), result))
						{
							args.Context.AddString("Usage: fehuwarbands_spawnrole <Warrior|Pillager|Chieftain> [Biome]");
						}
						else
						{
							Biome val21 = (Biome)1;
							if (args.Length >= 3 && Enum.TryParse<Biome>(args[2], ignoreCase: true, out Biome result2))
							{
								val21 = result2;
							}
							Vector3 val22 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f;
							Humanoid val23 = RaiderAI.SpawnRaider(new RaiderAI.RaiderSpawnRequest(val22, val21, result));
							args.Context.AddString(((Object)val23 != (Object)null) ? $"Spawned {result} with {val21} loadout at {val22}" : "Failed to spawn raider");
						}
					};
					<>c.<>9__1_8 = val12;
					obj18 = (object)val12;
				}
				_003C_003Ec._003C_003E9__0_8 = (ConsoleEvent)obj18;
				obj17 = obj18;
			}
			object obj19 = _003C_003Ec._003C_003E9__0_9;
			if (obj19 == null)
			{
				object obj20 = <>c.<>9__1_9;
				if (obj20 == null)
				{
					ConsoleOptionsFetcher val13 = () => new List<string> { "Warrior", "Pillager", "Chieftain" };
					<>c.<>9__1_9 = val13;
					obj20 = (object)val13;
				}
				_003C_003Ec._003C_003E9__0_9 = (ConsoleOptionsFetcher)obj20;
				obj19 = obj20;
			}
			new ConsoleCommand("fehuwarbands_spawnrole", "<role> [biome] - Spawn a specific raider role with biome gear", (ConsoleEvent)obj17, true, false, false, false, false, false, (ConsoleOptionsFetcher)obj19, false, false, false);
			object obj21 = _003C_003Ec._003C_003E9__0_10;
			if (obj21 == null)
			{
				object obj22 = <>c.<>9__1_10;
				if (obj22 == null)
				{
					ConsoleEvent val14 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_007f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0085: Expected O, but got Unknown
						//IL_0095: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
						//IL_0103: Unknown result type (might be due to invalid IL or missing references)
						//IL_0130: Unknown result type (might be due to invalid IL or missing references)
						//IL_013a: Expected O, but got Unknown
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else if (args.Length < 2)
						{
							args.Context.AddString("Usage: fehuwarbands_spawngarrison <tower|village> [radius]");
						}
						else
						{
							string text = args[1].ToLowerInvariant();
							float num = 20f;
							if (args.Length >= 3 && float.TryParse(args[2], out var result))
							{
								num = Mathf.Clamp(result, 5f, 50f);
							}
							GameObject val21 = new GameObject("FehuWarbands_GarrisonRoot");
							val21.transform.position = ((Component)Player.m_localPlayer).transform.position;
							if (text == "tower")
							{
								RaiderTowerOverwrites.SpawnTowerRaiders(val21);
								args.Context.AddString($"Spawned tower garrison at {val21.transform.position} (radius {num})");
							}
							else if (text == "village")
							{
								RaiderTowerOverwrites.SpawnVillageRaiders(val21);
								args.Context.AddString($"Spawned village garrison at {val21.transform.position} (radius {num})");
							}
							else
							{
								args.Context.AddString("Invalid garrison type. Use 'tower' or 'village'.");
							}
							Object.Destroy((Object)val21);
						}
					};
					<>c.<>9__1_10 = val14;
					obj22 = (object)val14;
				}
				_003C_003Ec._003C_003E9__0_10 = (ConsoleEvent)obj22;
				obj21 = obj22;
			}
			object obj23 = _003C_003Ec._003C_003E9__0_11;
			if (obj23 == null)
			{
				object obj24 = <>c.<>9__1_11;
				if (obj24 == null)
				{
					ConsoleOptionsFetcher val15 = () => new List<string> { "tower", "village" };
					<>c.<>9__1_11 = val15;
					obj24 = (object)val15;
				}
				_003C_003Ec._003C_003E9__0_11 = (ConsoleOptionsFetcher)obj24;
				obj23 = obj24;
			}
			new ConsoleCommand("fehuwarbands_spawngarrison", "<tower|village> [radius] - Spawn a raider garrison using tower/village rules", (ConsoleEvent)obj21, true, false, false, false, false, false, (ConsoleOptionsFetcher)obj23, false, false, false);
			object obj25 = _003C_003Ec._003C_003E9__0_12;
			if (obj25 == null)
			{
				object obj26 = <>c.<>9__1_12;
				if (obj26 == null)
				{
					ConsoleEvent val16 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						int result;
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else if (args.Length < 2 || !int.TryParse(args[1], out result))
						{
							args.Context.AddString("Usage: fehuwarbands_wave <waveNumber>");
						}
						else
						{
							if (!RaiderEvents.IsRaidActive())
							{
								RaiderEvents.StartRaidManually();
							}
							MethodInfo methodInfo = AccessTools.Method(typeof(RaiderEvents), "SpawnWave", (Type[])null, (Type[])null);
							for (int i = 0; i < result; i++)
							{
								methodInfo.Invoke(null, null);
							}
							args.Context.AddString($"Spawned raid wave {result}");
						}
					};
					<>c.<>9__1_12 = val16;
					obj26 = (object)val16;
				}
				_003C_003Ec._003C_003E9__0_12 = (ConsoleEvent)obj26;
				obj25 = obj26;
			}
			new ConsoleCommand("fehuwarbands_wave", "<waveNumber> - Force-spawn a raid wave", (ConsoleEvent)obj25, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj27 = _003C_003Ec._003C_003E9__0_13;
			if (obj27 == null)
			{
				object obj28 = <>c.<>9__1_13;
				if (obj28 == null)
				{
					ConsoleEvent val17 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						//IL_004b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
						//IL_0069: Unknown result type (might be due to invalid IL or missing references)
						//IL_006e: Unknown result type (might be due to invalid IL or missing references)
						//IL_006f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0070: Unknown result type (might be due to invalid IL or missing references)
						//IL_0081: Unknown result type (might be due to invalid IL or missing references)
						//IL_0087: Unknown result type (might be due to invalid IL or missing references)
						//IL_003f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0040: Unknown result type (might be due to invalid IL or missing references)
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else
						{
							Biome val21 = (Biome)1;
							if (args.Length >= 2 && Enum.TryParse<Biome>(args[1], ignoreCase: true, out Biome result))
							{
								val21 = result;
							}
							Vector3 val22 = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f;
							RaiderLoot.DropRegularLoot(val22, val21);
							args.Context.AddString($"Spawned regular loot for {val21} biome at {val22}");
						}
					};
					<>c.<>9__1_13 = val17;
					obj28 = (object)val17;
				}
				_003C_003Ec._003C_003E9__0_13 = (ConsoleEvent)obj28;
				obj27 = obj28;
			}
			new ConsoleCommand("fehuwarbands_spawnloot", "[biome] - Spawn infused loot item", (ConsoleEvent)obj27, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj29 = _003C_003Ec._003C_003E9__0_14;
			if (obj29 == null)
			{
				object obj30 = <>c.<>9__1_14;
				if (obj30 == null)
				{
					ConsoleEvent val18 = delegate(ConsoleEventArgs args)
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_0010: Expected O, but got Unknown
						//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
						//IL_00fa: Expected O, but got Unknown
						//IL_0114: Unknown result type (might be due to invalid IL or missing references)
						//IL_0115: Unknown result type (might be due to invalid IL or missing references)
						//IL_011f: Unknown result type (might be due to invalid IL or missing references)
						//IL_012a: Expected O, but got Unknown
						//IL_014a: Unknown result type (might be due to invalid IL or missing references)
						//IL_017d: Unknown result type (might be due to invalid IL or missing references)
						if (!((Object)Player.m_localPlayer != (Object)null))
						{
							args.Context.AddString("No local player found");
						}
						else if (args.Length < 2)
						{
							args.Context.AddString("Usage: fehuwarbands_location_add <prefabName>");
							args.Context.AddString("Available locations:");
							args.Context.AddString("  - CombatRuin01 (Meadows, 5W+1C)");
							args.Context.AddString("  - WoodHouse3 (Meadows, 5W+1C)");
							args.Context.AddString("  - Mistlands_Excavation3 (Mistlands, 7W+1C)");
							args.Context.AddString("  - Ruin3 (Plains, 5W+1C)");
							args.Context.AddString("  - StoneTowerRuins05 (Mountain, 5W+1C)");
							args.Context.AddString("  - Runestone_Greydwarfs (BlackForest, 4W+1C)");
						}
						else
						{
							string text = args[1];
							if (!RaiderLocationManager.IsRaiderLocation(text))
							{
								args.Context.AddString("Unknown raider location: " + text);
							}
							else
							{
								Vector3 position = ((Component)Player.m_localPlayer).transform.position;
								GameObject clonedLocationPrefab = RaiderLocationManager.GetClonedLocationPrefab(text);
								if ((Object)clonedLocationPrefab == (Object)null)
								{
									args.Context.AddString("Failed to get prefab for " + text);
								}
								else if ((Object)Object.Instantiate<GameObject>(clonedLocationPrefab, position, Quaternion.identity) != (Object)null)
								{
									RaiderLocationManager.LocationDefinition locationDefinition = RaiderLocationManager.GetLocationDefinition(text);
									args.Context.AddString($"Spawned {text} at {position} ({locationDefinition.WarriorCount}W + {locationDefinition.ChieftainCount}C)");
									FehuWarbandsPlugin.LogDebug($"Dev command spawned raider location: {text} at {position}");
								}
								else
								{
									args.Context.AddString("Failed to spawn location " + text);
								}
							}
						}
					};
					<>c.<>9__1_14 = val18;
					obj30 = (object)val18;
				}
				_003C_003Ec._003C_003E9__0_14 = (ConsoleEvent)obj30;
				obj29 = obj30;
			}
			object obj31 = _003C_003Ec._003C_003E9__0_15;
			if (obj31 == null)
			{
				object obj32 = <>c.<>9__1_15;
				if (obj32 == null)
				{
					ConsoleOptionsFetcher val19 = () => new List<string> { "CombatRuin01", "WoodHouse3", "Mistlands_Excavation3", "Ruin3", "StoneTowerRuins05", "Runestone_Greydwarfs" };
					<>c.<>9__1_15 = val19;
					obj32 = (object)val19;
				}
				_003C_003Ec._003C_003E9__0_15 = (ConsoleOptionsFetcher)obj32;
				obj31 = obj32;
			}
			new ConsoleCommand("fehuwarbands_location_add", "<prefabName> - Add a raider location at player position (compatible with upgrade_world)", (ConsoleEvent)obj29, true, false, false, false, false, false, (ConsoleOptionsFetcher)obj31, false, false, false);
			object obj33 = _003C_003Ec._003C_003E9__0_16;
			if (obj33 == null)
			{
				object obj34 = <>c.<>9__1_16;
				if (obj34 == null)
				{
					ConsoleEvent val20 = delegate(ConsoleEventArgs args)
					{
						args.Context.AddString("Populating world with raider locations...");
						args.Context.AddString("This requires the upgrade_world mod to be installed.");
						args.Context.AddString("");
						args.Context.AddString("Execute these commands in the upgrade_world console:");
						args.Context.AddString("  locations_add FW_CombatRuin01 quantity=10");
						args.Context.AddString("  locations_add FW_WoodHouse3 quantity=10");
						args.Context.AddString("  locations_add FW_Mistlands_Excavation3 quantity=10");
						args.Context.AddString("  locations_add FW_Ruin3 quantity=10");
						args.Context.AddString("  locations_add FW_StoneTowerRuins05 quantity=10");
						args.Context.AddString("  locations_add FW_Runestone_Greydwarfs quantity=10");
						args.Context.AddString("");
						args.Context.AddString("This will add 10 of each raider location to both explored and unexplored areas:");
						args.Context.AddString("  - FW_CombatRuin01 (Meadows, 5W+1C)");
						args.Context.AddString("  - FW_WoodHouse3 (Meadows, 5W+1C)");
						args.Context.AddString("  - FW_Mistlands_Excavation3 (Mistlands, 7W+1C)");
						args.Context.AddString("  - FW_Ruin3 (Plains, 5W+1C)");
						args.Context.AddString("  - FW_StoneTowerRuins05 (Mountain, 5W+1C)");
						args.Context.AddString("  - FW_Runestone_Greydwarfs (BlackForest, 4W+1C)");
						FehuWarbandsPlugin.LogDebug("Dev command displayed raider location population instructions");
					};
					<>c.<>9__1_16 = val20;
					obj34 = (object)val20;
				}
				_003C_003Ec._003C_003E9__0_16 = (ConsoleEvent)obj34;
				obj33 = obj34;
			}
			new ConsoleCommand("fehuwarbands_populate_world", "- Populate world with raider locations (requires upgrade_world mod)", (ConsoleEvent)obj33, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			FehuWarbandsPlugin.LogDebug("FehuWarbands dev commands registered");
		}
	}
	[BepInPlugin("com.fehu.fehuwarbands", "FehuWarbands", "420.101.4")]
	[BepInDependency("com.jotunn.jotunn", "2.30.2")]
	internal class FehuWarbandsPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.fehu.fehuwarbands";

		public const string PluginName = "FehuWarbands";

		public const string PluginVersion = "420.101.4";

		internal static ManualLogSource Logger;

		public static ConfigEntry<string> RaidFrequency;

		public static ConfigEntry<float> RaidCheckTimeOfDay;

		public static ConfigEntry<bool> EnableTowerOverwrites;

		public static ConfigEntry<bool> EnableRaidEvents;

		public static ConfigEntry<bool> EnableDebugLogging;

		public static ConfigEntry<string> Wave1Composition;

		public static ConfigEntry<string> Wave2Composition;

		public static ConfigEntry<string> Wave3Composition;

		public static ConfigEntry<string> Wave4Composition;

		public static ConfigEntry<string>[] LevelWaveCompositions = new ConfigEntry<string>[32];

		public static ConfigEntry<bool> EnableRegularLoot;

		public static ConfigEntry<bool> ChieftainDropInfusedItem;

		public static ConfigEntry<float> InfusedDamageBonus;

		public static ConfigEntry<float> InfusedArmorBonus;

		internal static FehuWarbandsPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			InitializeConfig();
			new Harmony("com.fehu.fehuwarbands").PatchAll(Assembly.GetExecutingAssembly());
			RaiderAI.Initialize();
			RaiderLocationManager.Initialize();
			RaiderTowerOverwrites.Initialize();
			UpgradeWorldCommands.AddUpgradeWorldCommands();
			((MonoBehaviour)this).StartCoroutine(DelayedInitialization());
			Logger.LogInfo((object)"FehuWarbands loaded.");
		}

		private void OnDestroy()
		{
			RaiderTowerOverwrites.SaveProcessedLocations();
		}

		private void InitializeConfig()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_009d: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Expected O, but got Unknown
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Expected O, but got Unknown
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Expected O, but got Unknown
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Expected O, but got Unknown
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Expected O, but got Unknown
			RaidFrequency = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Events", "RaidFrequency", "Normal", new ConfigDescription("Controls how often FehuWarbands may launch automatic attacks. Manual raids are unaffected.", (AcceptableValueBase)(object)new AcceptableValueList<string>(RaidFrequencySettings.Choices), new object[1] { (object)new ConfigurationManagerAttributes
			{
				DispName = "Automatic Raid Frequency",
				IsAdminOnly = true
			} }));
			RaidCheckTimeOfDay = ((BaseUnityPlugin)this).Config.Bind<float>("Raid Events", "RaidCheckTimeOfDay", 0.6f, new ConfigDescription("Legacy daily check time. Automatic Raid Frequency controls the chance internally.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false,
				IsAdminOnly = true
			} }));
			EnableTowerOverwrites = ((BaseUnityPlugin)this).Config.Bind<bool>("Tower Overwrites", "EnableTowerOverwrites", true, new ConfigDescription("Enable Mistlands Dvergr tower overwrites with raiders", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableRaidEvents = ((BaseUnityPlugin)this).Config.Bind<bool>("Raid Events", "EnableRaidEvents", true, new ConfigDescription("Legacy automatic raid switch. Manual raids are unaffected. Use Automatic Raid Frequency instead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false,
				IsAdminOnly = true
			} }));
			EnableDebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLogging", false, new ConfigDescription("Enable verbose debug logging for troubleshooting", (AcceptableValueBase)null, Array.Empty<object>()));
			Wave1Composition = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Waves - Legacy", "Wave1", "", "DEPRECATED: Use Level0_Wave1 through Level7_Wave4 instead. Leave empty to use defaults.");
			Wave2Composition = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Waves - Legacy", "Wave2", "", "DEPRECATED: Use Level0_Wave1 through Level7_Wave4 instead. Leave empty to use defaults.");
			Wave3Composition = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Waves - Legacy", "Wave3", "", "DEPRECATED: Use Level0_Wave1 through Level7_Wave4 instead. Leave empty to use defaults.");
			Wave4Composition = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Waves - Legacy", "Wave4", "", "DEPRECATED: Use Level0_Wave1 through Level7_Wave4 instead. Leave empty to use defaults.");
			string[] array = new string[8] { "Level0", "Level1", "Level2", "Level3", "Level4", "Level5", "Level6", "Level7" };
			string[] array2 = new string[32]
			{
				"Warrior:1", "Pillager:1", "Warrior:2", "Chieftain:1", "Warrior:2", "Pillager:1", "Warrior:3", "Chieftain:1", "Warrior:3", "Pillager:1",
				"Warrior:4", "Chieftain:1", "Warrior:3", "Warrior:2,Pillager:2", "Warrior:5", "Chieftain:1", "Warrior:4", "Warrior:2,Pillager:2", "Warrior:6", "Chieftain:1",
				"Warrior:5", "Warrior:3,Pillager:3", "Warrior:7", "Chieftain:1", "Warrior:6", "Warrior:3,Pillager:3", "Warrior:7", "Chieftain:1", "Warrior:7", "Warrior:4,Pillager:4",
				"Warrior:8", "Chieftain:1"
			};
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					int num = i * 4 + j;
					string text = (j + 1).ToString();
					LevelWaveCompositions[num] = ((BaseUnityPlugin)this).Config.Bind<string>("Raid Waves", array[i] + "_Wave" + text, array2[num], "Comma-separated Role:Count entries for " + array[i] + " wave " + text + " (e.g., Warrior:3,Pillager:1)");
				}
			}
			for (int k = 0; k < LevelWaveCompositions.Length; k++)
			{
				LevelWaveCompositions[k].SettingChanged += OnWaveConfigChanged;
			}
			ReloadWaveConfigFromSettings();
			EnableRegularLoot = ((BaseUnityPlugin)this).Config.Bind<bool>("Loot - Regular Raiders", "EnableLoot", true, new ConfigDescription("Enable loot drops for regular raiders", (AcceptableValueBase)null, Array.Empty<object>()));
			ChieftainDropInfusedItem = ((BaseUnityPlugin)this).Config.Bind<bool>("Loot - Chieftains", "DropInfusedItem", true, new ConfigDescription("Whether chieftains drop infused items", (AcceptableValueBase)null, Array.Empty<object>()));
			InfusedDamageBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Loot - Chieftains", "InfusedDamageBonus", 1.2f, new ConfigDescription("Damage bonus multiplier for infused items (e.g., 1.2 = +20% damage)", (AcceptableValueBase)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>()));
			InfusedArmorBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Loot - Chieftains", "InfusedArmorBonus", 1.2f, new ConfigDescription("Armor bonus multiplier for infused items (e.g., 1.2 = +20% armor)", (AcceptableValueBase)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>()));
			void OnWaveConfigChanged(object _, EventArgs __)
			{
				ReloadWaveConfigFromSettings();
			}
		}

		private IEnumerator DelayedInitialization()
		{
			while ((Object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0)
			{
				yield return null;
			}
			RaiderLoot.Initialize();
			LogDebug("Raider systems initialized; prefabs register when ZNetScene loads.");
		}

		public static void LogDebug(string message)
		{
			if (EnableDebugLogging.Value)
			{
				Logger.LogInfo((object)("[DEBUG] " + message));
			}
		}

		private void ReloadWaveConfigFromSettings()
		{
			string[] array = new string[32];
			for (int i = 0; i < LevelWaveCompositions.Length; i++)
			{
				array[i] = LevelWaveCompositions[i]?.Value ?? "";
			}
			RaiderEvents.ConfigureWaves(array);
		}
	}
	internal static class GameApiAccess
	{
		private delegate bool HavePathDelegate(BaseAI ai, Vector3 target);

		private delegate bool MoveToDelegate(BaseAI ai, float dt, Vector3 point, float distance, bool run);

		private delegate bool FleeDelegate(BaseAI ai, float dt, Vector3 from);

		private static readonly FieldRef<Attack, Humanoid> AttackCharacter = AccessTools.FieldRefAccess<Attack, Humanoid>("m_character");

		private static readonly FieldRef<Character, ZNetView> CharacterNView = AccessTools.FieldRefAccess<Character, ZNetView>("m_nview");

		private static readonly FieldRef<MonsterAI, Character> MonsterTarget = AccessTools.FieldRefAccess<MonsterAI, Character>("m_targetCreature");

		private static readonly FieldRef<WearNTear, ZNetView> WearNView = AccessTools.FieldRefAccess<WearNTear, ZNetView>("m_nview");

		private static readonly FieldRef<CharacterDrop, bool> DropsEnabled = AccessTools.FieldRefAccess<CharacterDrop, bool>("m_dropsEnabled");

		private static readonly FieldRef<Humanoid, ItemData> HelmetItem = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_helmetItem");

		private static readonly FieldRef<Humanoid, ItemData> ChestItem = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_chestItem");

		private static readonly FieldRef<Humanoid, ItemData> LegItem = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_legItem");

		private static Humanoid s_equipmentTraceTarget;

		private static bool s_equipmentTraceUsed;

		private static readonly HavePathDelegate HavePathCall = AccessTools.MethodDelegate<HavePathDelegate>(AccessTools.Method(typeof(BaseAI), "HavePath", new Type[1] { typeof(Vector3) }, (Type[])null), (object)null, true);

		private static readonly MoveToDelegate MoveToCall = AccessTools.MethodDelegate<MoveToDelegate>(AccessTools.Method(typeof(BaseAI), "MoveTo", new Type[4]
		{
			typeof(float),
			typeof(Vector3),
			typeof(float),
			typeof(bool)
		}, (Type[])null), (object)null, true);

		private static readonly FleeDelegate FleeCall = AccessTools.MethodDelegate<FleeDelegate>(AccessTools.Method(typeof(BaseAI), "Flee", new Type[2]
		{
			typeof(float),
			typeof(Vector3)
		}, (Type[])null), (object)null, true);

		internal static Humanoid GetAttackCharacter(Attack attack)
		{
			if (attack != null)
			{
				return AttackCharacter.Invoke(attack);
			}
			return null;
		}

		internal static ZNetView GetNView(Character character)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if (!((Object)character == (Object)null))
			{
				return CharacterNView.Invoke(character);
			}
			return null;
		}

		internal static ZNetView GetNView(WearNTear wear)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if (!((Object)wear == (Object)null))
			{
				return WearNView.Invoke(wear);
			}
			return null;
		}

		internal static ZDO GetZDO(Character character)
		{
			ZNetView nView = GetNView(character);
			if (nView == null)
			{
				return null;
			}
			return nView.GetZDO();
		}

		internal static Character GetTargetCreature(MonsterAI ai)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if (!((Object)ai == (Object)null))
			{
				return MonsterTarget.Invoke(ai);
			}
			return null;
		}

		internal static bool HavePath(BaseAI ai, Vector3 target)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return HavePathCall(ai, target);
		}

		internal static bool MoveTo(BaseAI ai, float dt, Vector3 point, float distance, bool run)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return MoveToCall(ai, dt, point, distance, run);
		}

		internal static bool Flee(BaseAI ai, float dt, Vector3 from)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return FleeCall(ai, dt, from);
		}

		internal static bool BeginEquipmentTrace(Humanoid humanoid)
		{
			if (!FehuWarbandsPlugin.EnableDebugLogging.Value || s_equipmentTraceUsed)
			{
				return false;
			}
			s_equipmentTraceUsed = true;
			s_equipmentTraceTarget = humanoid;
			ZNetView nView = GetNView((Character)(object)humanoid);
			FehuWarbandsPlugin.LogDebug("[FehuWarbands] Raider equipment init: " + ((Object)((Component)humanoid).gameObject).name + "/" + ((Character)humanoid).m_name);
			FehuWarbandsPlugin.LogDebug($"[FehuWarbands] Inventory ready: {humanoid.GetInventory() != null}");
			FehuWarbandsPlugin.LogDebug($"[FehuWarbands] VisEquipment ready: {(Object)(object)humanoid.GetVisEquipment() != (Object)null}; ZNetView ready: {(Object)(object)nView != (Object)null && nView.GetZDO() != null}");
			return true;
		}

		internal static void EndEquipmentTrace(Humanoid humanoid)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Invalid comparison between Unknown and I4
			if ((Object)(object)s_equipmentTraceTarget != (Object)(object)humanoid)
			{
				return;
			}
			ItemData item = ((humanoid.RightItem != null && humanoid.RightItem.IsWeapon()) ? humanoid.RightItem : ((humanoid.LeftItem != null && humanoid.LeftItem.IsWeapon()) ? humanoid.LeftItem : null));
			FehuWarbandsPlugin.LogDebug("[FehuWarbands] Active weapon: " + EquippedName(item));
			FehuWarbandsPlugin.LogDebug("[FehuWarbands] Equipped helmet: " + EquippedName(HelmetItem.Invoke(humanoid)));
			FehuWarb