Decompiled source of PrisonerExchange v1.0.3

PrisonerExchange.dll

Decompiled a week ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Timers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using PrisonerExchange.Data;
using PrisonerExchange.Extensions;
using PrisonerExchange.Models;
using PrisonerExchange.Services;
using PrisonerExchange.Services.Chat;
using PrisonerExchange.Utility;
using ProjectM;
using ProjectM.Behaviours;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PrisonerExchange")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A plugin to swap and sell prisoners.")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e.8782b2b39b5707920cb4c14fcc87e6667cd5c939")]
[assembly: AssemblyProduct("PrisonerExchange")]
[assembly: AssemblyTitle("PrisonerExchange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class Core
{
	private static bool hasInitialized;

	public static World Server { get; } = GetWorld() ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");


	public static EntityManager EntityManager { get; } = Server.EntityManager;


	public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();


	public static DebugEventsSystem DebugEventsSystem { get; internal set; }

	public static ServerScriptMapper ServerScriptMapper { get; internal set; }

	public static void Initialize()
	{
		if (!hasInitialized)
		{
			DebugEventsSystem = Server.GetExistingSystemManaged<DebugEventsSystem>();
			ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
			hasInitialized = true;
		}
	}

	private static World GetWorld()
	{
		Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
		while (enumerator.MoveNext())
		{
			World current = enumerator.Current;
			if (current.Name == "Server")
			{
				return current;
			}
		}
		return null;
	}
}
namespace PrisonerExchange
{
	internal class Configuration
	{
		internal static bool SellingEnabled { get; private set; }

		internal static bool SwappingEnabled { get; private set; }

		internal static bool AnnounceExchange { get; private set; }

		internal static string CurrencyPrefab { get; private set; }

		internal static string CurrencyName { get; private set; }

		internal static int MinimumSalePrice { get; private set; }

		internal static int MaximumSalePrice { get; private set; }

		internal static bool ClanLeaderOnly { get; private set; }

		internal static int CommandCoolDownPeriod { get; private set; }

		internal static int ExpireExchangeAfter { get; private set; }

		internal static void Initialize(ConfigFile config)
		{
			SellingEnabled = config.Bind<bool>("General", "SellingEnabled", true, "Enable or disable the ability to sell prisoners.").Value;
			SwappingEnabled = config.Bind<bool>("General", "SwappingEnabled", true, "Enable or disable the ability to swap prisoners.").Value;
			AnnounceExchange = config.Bind<bool>("General", "AnnounceExchange", true, "Announce completed sales in global chat.").Value;
			CurrencyPrefab = config.Bind<string>("General", "CurrencyPrefab", "-257494203", "Prefab GUID for the currency. (Crystals by default)").Value;
			CurrencyName = config.Bind<string>("General", "CurrencyName", "Crystals", "Name of currency.").Value;
			MinimumSalePrice = config.Bind<int>("General", "MinimumSalePrice", 100, "Set the minimum amount of currency required for a sale.").Value;
			MaximumSalePrice = config.Bind<int>("General", "MaximumSalePrice", 5000, "Set the maximum amount of currency allowed for a sale.").Value;
			ClanLeaderOnly = config.Bind<bool>("General", "ClanLeaderOnly", false, "Only allow clan leader to sell prisoners.").Value;
			CommandCoolDownPeriod = config.Bind<int>("General", "CommandCoolDownPeriod", 5, "Adds a fixed cooldown period for selling/swapping prisoners (minutes).").Value;
			ExpireExchangeAfter = config.Bind<int>("General", "ExpireExchangeAfter", 60, "Automatically expire sales and swap requests. (seconds)").Value;
		}
	}
	internal static class Markup
	{
		public const string HighlightColor = "#def";

		public const string SecondaryColor = "#dda";

		public static string Prefix = Format.Bold(Format.Color("[PE] ", "#ed1"));

		public static string Highlight(int i)
		{
			return Highlight(i.ToString());
		}

		public static string Highlight(string s)
		{
			return Format.Color(Format.Bold(s), "#def");
		}

		public static string Secondary(int i)
		{
			return Secondary(i.ToString());
		}

		public static string Secondary(string s)
		{
			return Format.Color(Format.Bold(s), "#dda");
		}
	}
	[BepInPlugin("PrisonerExchange", "PrisonerExchange", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public static ManualLogSource Logger;

		private static Harmony _harmony;

		public static Harmony Harmony => _harmony;

		internal static Plugin Instance { get; private set; }

		public override void Load()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Instance = this;
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PrisonerExchange");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.3");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			_harmony = new Harmony("PrisonerExchange");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Configuration.Initialize(((BasePlugin)this).Config);
			CommandRegistry.RegisterAll();
		}

		public void OnGameInitialized()
		{
			if (!WorldUtility.IsServerWorld(Core.Server))
			{
				Logger.Error("EntryPoint", "Plugin is not running on a server world!");
			}
			else
			{
				Core.Initialize();
			}
		}

		public override bool Unload()
		{
			CommandRegistry.UnregisterAssembly();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PrisonerExchange";

		public const string PLUGIN_NAME = "PrisonerExchange";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace PrisonerExchange.Utility
{
	public class BuffUtil
	{
		public static EntityManager EM = Core.EntityManager;

		public static PrefabGUID ELECTRIC_BUFF = new PrefabGUID(1237097606);

		public const int NO_DURATION = 0;

		public const int DEFAULT_DURATION = -1;

		public static bool BuffNPC(Entity character, Entity user, PrefabGUID buff, int duration = -1)
		{
			//IL_0018: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0042: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (Core.DebugEventsSystem == null)
			{
				Core.DebugEventsSystem = Core.Server.GetExistingSystemManaged<DebugEventsSystem>();
			}
			ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
			val.BuffPrefabGUID = buff;
			ApplyBuffDebugEvent val2 = val;
			FromCharacter val3 = default(FromCharacter);
			val3.User = user;
			val3.Character = character;
			FromCharacter val4 = val3;
			Entity entity = default(Entity);
			if (!BuffUtility.TryGetBuff<EntityManager>(EM, character, PrefabIdentifier.op_Implicit(buff), ref entity))
			{
				Core.DebugEventsSystem.ApplyBuff(val4, val2);
				if (!BuffUtility.TryGetBuff<EntityManager>(EM, character, PrefabIdentifier.op_Implicit(buff), ref entity))
				{
					Plugin.Logger.Info("BuffUtil", $"Failed to apply buff {((PrefabGUID)(ref buff)).GuidHash} to entity {character.Index}.");
					return false;
				}
				entity.TryRemoveComponent<CreateGameplayEventsOnSpawn>();
				entity.TryRemoveComponent<GameplayEventListeners>();
				if (duration > 0 && duration != -1)
				{
					if (entity.Has<LifeTime>())
					{
						LifeTime data = entity.Read<LifeTime>();
						data.Duration = duration;
						entity.Write<LifeTime>(data);
					}
				}
				else if (duration == 0)
				{
					if (entity.Has<LifeTime>())
					{
						LifeTime data2 = entity.Read<LifeTime>();
						data2.Duration = -1f;
						data2.EndAction = (LifeTimeEndAction)0;
						entity.Write<LifeTime>(data2);
					}
					entity.TryRemoveComponent<RemoveBuffOnGameplayEvent>();
					entity.TryRemoveComponent<RemoveBuffOnGameplayEventEntry>();
				}
				Plugin.Logger.Info("BuffUtil", $"Successfully applied buff {((PrefabGUID)(ref buff)).GuidHash} to entity {character.Index}.");
				return true;
			}
			Plugin.Logger.Info("BuffUtil", $"Buff {((PrefabGUID)(ref buff)).GuidHash} is already present on entity {character.Index}.");
			return false;
		}

		public static bool RemoveBuff(Entity Character, PrefabGUID Buff)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff<EntityManager>(EM, Character, PrefabIdentifier.op_Implicit(Buff), ref val))
			{
				DestroyUtility.Destroy(EM, val, (DestroyDebugReason)13, (string)null, 0);
				Plugin.Logger.Info("BuffUtil", $"Successfully removed buff {((PrefabGUID)(ref Buff)).GuidHash} from entity {Character.Index}.");
				return true;
			}
			Plugin.Logger.Info("BuffUtil", $"Successfully removed buff {((PrefabGUID)(ref Buff)).GuidHash} from entity {Character.Index}.");
			return false;
		}
	}
	public static class DebugUtils
	{
		public static void ExploreEntity(Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder val = new StringBuilder();
			EntityDebuggingUtility.DumpEntity(Core.Server, entity, true, val);
			Plugin.Logger.LogInfo((object)((Object)val).ToString());
		}
	}
	public class EntityUtil
	{
		public static Entity FindClosestInRadius<T>(Entity player, float radius)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_007e: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			float3 val = float3.zero;
			if (player.TryGetComponent<LocalToWorld>(out LocalToWorld component))
			{
				val = ((LocalToWorld)(ref component)).Position;
			}
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<T>(),
				ComponentType.ReadOnly<LocalToWorld>()
			});
			NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Entity result = Entity.Null;
			float num = radius * radius;
			try
			{
				Enumerator<Entity> enumerator = val3.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					entityManager = Core.EntityManager;
					LocalToWorld componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(current);
					float3 position = ((LocalToWorld)(ref componentData)).Position;
					float num2 = math.distancesq(val, position);
					if (num2 < num)
					{
						num = num2;
						result = current;
					}
				}
				return result;
			}
			finally
			{
				val3.Dispose();
			}
		}

		public static NativeArray<Entity> GetEntitiesByComponentType<T1>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007d: 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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions val = (EntityQueryOptions)0;
			if (includeAll)
			{
				val = (EntityQueryOptions)(val | 0xC3);
			}
			if (includeDisabled)
			{
				val = (EntityQueryOptions)(val | 2);
			}
			if (includeSpawn)
			{
				val = (EntityQueryOptions)(val | 0x40);
			}
			if (includePrefab)
			{
				val = (EntityQueryOptions)(val | 1);
			}
			if (includeDestroyed)
			{
				val = (EntityQueryOptions)(val | 0x80);
			}
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
			});
			val2.Options = val;
			EntityQueryDesc val3 = val2;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
			return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions val = (EntityQueryOptions)0;
			if (includeAll)
			{
				val = (EntityQueryOptions)(val | 0xC3);
			}
			if (includeDisabled)
			{
				val = (EntityQueryOptions)(val | 2);
			}
			if (includeSpawn)
			{
				val = (EntityQueryOptions)(val | 0x40);
			}
			if (includePrefab)
			{
				val = (EntityQueryOptions)(val | 1);
			}
			if (includeDestroyed)
			{
				val = (EntityQueryOptions)(val | 0x80);
			}
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0)
			});
			val2.Options = val;
			EntityQueryDesc val3 = val2;
			EntityManager entityManager = Core.EntityManager;
			EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
			return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}
	}
	public class UserUtil
	{
		public static UserModel[] All
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				EntityManager entityManager = Core.EntityManager;
				EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
				NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				List<UserModel> list = new List<UserModel>(val2.Length);
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					entityManager = Core.EntityManager;
					User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current);
					UserModel item = new UserModel(current, componentData);
					list.Add(item);
				}
				val2.Dispose();
				return list.ToArray();
			}
		}

		public static UserModel GetCurrentUser(ChatCommandContext ctx)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetUserByPlatformId(ctx.User.PlatformId);
		}

		public static UserModel ToUserModel(Entity userEntity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Core.EntityManager;
			User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
			return new UserModel(userEntity, componentData);
		}

		public static UserModel GetUserByPlatformId(ulong platformId)
		{
			return All.FirstOrDefault((UserModel u) => u.PlatformId == platformId);
		}

		public static UserModel GetUserByCharacterName(string characterName)
		{
			if (string.IsNullOrEmpty(characterName))
			{
				return null;
			}
			return All.FirstOrDefault((UserModel u) => u.CharacterName.Equals(characterName, StringComparison.OrdinalIgnoreCase));
		}
	}
}
namespace PrisonerExchange.Patches
{
	[HarmonyPatch(typeof(ChatMessageSystem), "OnUpdate")]
	[HarmonyPriority(400)]
	public static class ChatSystemPromptPatch
	{
		public static bool Prefix(ChatMessageSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
			EntityQuery _query_661171423_ = __instance.__query_661171423_0;
			NativeArray<Entity> val = ((EntityQuery)(ref _query_661171423_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val.GetEnumerator();
				FixedString512Bytes val3 = default(FixedString512Bytes);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					FromCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<FromCharacter>(current);
					ChatMessageEvent componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<ChatMessageEvent>(current);
					User val2 = componentData.User.Read<User>();
					ulong platformId = val2.PlatformId;
					string text = ((object)(FixedString512Bytes)(ref componentData2.MessageText)).ToString().Trim();
					if (PromptManager.IsWaiting(platformId))
					{
						if (text.Equals("!s", StringComparison.OrdinalIgnoreCase))
						{
							PromptManager.CancelPrompt(platformId);
							((FixedString512Bytes)(ref val3))..ctor("Prompt cancelled!");
							ServerChatUtils.SendSystemMessageToClient(entityManager, val2, ref val3);
						}
						else
						{
							PromptManager.TryHandleInput(platformId, text);
						}
						((EntityManager)(ref entityManager)).DestroyEntity(current);
						return false;
					}
				}
			}
			finally
			{
				val.Dispose();
			}
			return true;
		}
	}
}
namespace PrisonerExchange.Services
{
	public class PendingSwap
	{
		public UserModel Seller { get; }

		public UserModel Buyer { get; }

		public PrisonerModel PrisonerA { get; }

		public PrisonerModel PrisonerB { get; }

		public DateTime CreatedAt { get; }

		public double LifetimeSeconds { get; }

		public PendingSwap(UserModel seller, UserModel buyer, PrisonerModel prisonera, PrisonerModel prisonerb, double lifetimeSeconds = 120.0)
		{
			Seller = seller;
			Buyer = buyer;
			PrisonerA = prisonera;
			PrisonerB = prisonerb;
			CreatedAt = DateTime.UtcNow;
			LifetimeSeconds = lifetimeSeconds;
		}
	}
	public class InventoryService
	{
		public static PrefabGUID currencyPrefab = new PrefabGUID(int.Parse(Configuration.CurrencyPrefab));

		public static AddItemResponse TryAddUserInventoryItem(Entity CharacterEntity, PrefabGUID itemGuid, int stacks)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (Core.ServerScriptMapper == null)
			{
				Core.ServerScriptMapper = Core.Server.GetExistingSystemManaged<ServerScriptMapper>();
			}
			ServerGameManager serverGameManager = Core.ServerScriptMapper.GetServerGameManager();
			return ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(CharacterEntity, itemGuid, stacks);
		}

		public static bool AddCurrencyToInventory(UserModel user, int amount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			AddItemResponse val = TryAddUserInventoryItem(user.User.LocalCharacter._Entity, currencyPrefab, amount);
			if (((AddItemResponse)(ref val)).Success)
			{
				return true;
			}
			if (val.RemainingAmount > 0)
			{
				Plugin.Logger.Error("InventoryService", $"{user.CharacterName} only had space for {amount - val.RemainingAmount} {Configuration.CurrencyName}.");
			}
			return false;
		}

		public static bool RemoveCurrencyFromInventory(UserModel user, int amount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Entity entity = user.User.LocalCharacter._Entity;
			if (InventoryUtilitiesServer.TryRemoveItem(Core.EntityManager, entity, currencyPrefab, amount))
			{
				return true;
			}
			return false;
		}

		public static bool CanAfford(UserModel user, int price)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Entity entity = user.User.LocalCharacter._Entity;
			int itemAmount = InventoryUtilities.GetItemAmount<EntityManager>(Core.EntityManager, entity, currencyPrefab, default(Nullable_Unboxed<int>));
			Plugin.Logger.Info("InventoryService", $"Currency in inventory: {itemAmount}");
			if (itemAmount >= price)
			{
				return true;
			}
			return false;
		}
	}
	public static class SalesService
	{
		private static readonly List<PendingSale> SalesList;

		private static Timer CleanupTimer;

		static SalesService()
		{
			SalesList = new List<PendingSale>();
			CleanupTimer = new Timer(5000.0);
			CleanupTimer.Elapsed += delegate
			{
				RemoveExpiredSales();
			};
			CleanupTimer.AutoReset = true;
			CleanupTimer.Enabled = true;
		}

		public static void AddSale(PendingSale sale)
		{
			SalesList.Add(sale);
			Plugin.Logger.Info("SalesService", $"Prisoner exchange created : Seller={sale.Seller.CharacterName}, Buyer={sale.Buyer.CharacterName}, Price={sale.Price}");
		}

		public static List<PendingSale> GetAll()
		{
			return SalesList;
		}

		public static PendingSale GetSaleBySeller(UserModel seller)
		{
			return SalesList.FirstOrDefault((PendingSale s) => s.Seller.PlatformId == seller.PlatformId);
		}

		public static PendingSale GetSaleByBuyer(UserModel buyer)
		{
			return SalesList.FirstOrDefault((PendingSale s) => s.Buyer.PlatformId == buyer.PlatformId);
		}

		public static void RemoveSale(UserModel seller)
		{
			lock (SalesList)
			{
				PendingSale saleBySeller = GetSaleBySeller(seller);
				if (saleBySeller != null)
				{
					SalesList.Remove(saleBySeller);
					Plugin.Logger.Info("SalesService", "Prisoner exchange removed : Seller=" + saleBySeller.Seller.CharacterName + ", Buyer=" + saleBySeller.Buyer.CharacterName);
				}
			}
		}

		public static void ClearAll()
		{
			lock (SalesList)
			{
				SalesList.Clear();
			}
		}

		public static bool SaleExists(UserModel user)
		{
			lock (SalesList)
			{
				return GetAll().Any((PendingSale sale) => sale.Seller.PlatformId == user.PlatformId);
			}
		}

		public static void RemoveExpiredSales()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			lock (SalesList)
			{
				FixedString512Bytes val = default(FixedString512Bytes);
				FixedString512Bytes val2 = default(FixedString512Bytes);
				foreach (PendingSale item in SalesList.Where((PendingSale sale) => (DateTime.UtcNow - sale.CreatedAt).TotalSeconds >= sale.LifetimeSeconds).ToList())
				{
					((FixedString512Bytes)(ref val))..ctor(Markup.Prefix + "Your prisoner exchange request to " + item.Buyer.CharacterName + " has expired.");
					((FixedString512Bytes)(ref val2))..ctor(Markup.Prefix + "The prisoner exchange request from " + item.Seller.CharacterName + " has expired.");
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Seller.User, ref val);
					ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Buyer.User, ref val2);
					SalesList.Remove(item);
				}
			}
		}
	}
	public static class SwapService
	{
		private static readonly List<PendingSwap> SwapsList;

		private static readonly Timer CleanupTimer;

		static SwapService()
		{
			SwapsList = new List<PendingSwap>();
			CleanupTimer = new Timer(5000.0);
			CleanupTimer.Elapsed += delegate
			{
				RemoveExpiredSwaps();
			};
			CleanupTimer.AutoReset = true;
			CleanupTimer.Enabled = true;
		}

		public static void AddSwap(PendingSwap swap)
		{
			SwapsList.Add(swap);
			Plugin.Logger.Info("SwapService", "Created prisoner swap. Initiator=" + swap.Seller.CharacterName + ", Target=" + swap.Buyer.CharacterName);
		}

		public static List<PendingSwap> GetAll()
		{
			return SwapsList;
		}

		public static PendingSwap GetActiveSwap(UserModel user)
		{
			return SwapsList.FirstOrDefault((PendingSwap s) => s.Seller.PlatformId == user.PlatformId || s.Buyer.PlatformId == user.PlatformId);
		}

		public static bool SwapExists(UserModel user)
		{
			lock (SwapsList)
			{
				return SwapsList.Any((PendingSwap s) => s.Seller.PlatformId == user.PlatformId || s.Buyer.PlatformId == user.PlatformId);
			}
		}

		public static void RemoveSwap(UserModel seller)
		{
			lock (SwapsList)
			{
				PendingSwap activeSwap = GetActiveSwap(seller);
				if (activeSwap != null)
				{
					SwapsList.Remove(activeSwap);
					Plugin.Logger.Info("SwapService", "Removed prisoner swap from initiator=" + seller.CharacterName);
				}
			}
		}

		public static void ClearAll()
		{
			lock (SwapsList)
			{
				SwapsList.Clear();
			}
		}

		private static void RemoveExpiredSwaps()
		{
			//IL_0063: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_00e4: 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)
			lock (SwapsList)
			{
				FixedString512Bytes val = default(FixedString512Bytes);
				FixedString512Bytes val2 = default(FixedString512Bytes);
				foreach (PendingSwap item in SwapsList.Where((PendingSwap s) => (DateTime.UtcNow - s.CreatedAt).TotalSeconds >= s.LifetimeSeconds).ToList())
				{
					SwapsList.Remove(item);
					if (item.Seller.User.IsConnected)
					{
						((FixedString512Bytes)(ref val))..ctor(Markup.Prefix + "Your prisoner swap request with " + item.Buyer.CharacterName + " has expired.");
						ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Seller.User, ref val);
					}
					if (item.Buyer.User.IsConnected)
					{
						((FixedString512Bytes)(ref val2))..ctor(Markup.Prefix + "A prisoner swap request from " + item.Seller.CharacterName + " has expired.");
						ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, item.Buyer.User, ref val2);
					}
					BuffUtil.RemoveBuff(item.PrisonerA.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
					BuffUtil.RemoveBuff(item.PrisonerB.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
				}
			}
		}
	}
	internal class UnitSpawnerService
	{
		[HarmonyPatch(typeof(UnitSpawnerReactSystem), "OnUpdate")]
		public static class UnitSpawnerReactSystem_Patch
		{
			public static bool Enabled { get; set; }

			public static void Prefix(UnitSpawnerReactSystem __instance)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//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_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_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: 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_004e: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: 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_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				if (!Enabled)
				{
					return;
				}
				EntityQuery _query_2099432189_ = __instance.__query_2099432189_0;
				Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_2099432189_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					EntityManager entityManager = Core.EntityManager;
					if (!((EntityManager)(ref entityManager)).HasComponent<LifeTime>(current))
					{
						break;
					}
					entityManager = Core.EntityManager;
					long num = (long)Mathf.Round(((EntityManager)(ref entityManager)).GetComponentData<LifeTime>(current).Duration);
					if (PostActions.TryGetValue(num, out (float, Action<Entity>) value))
					{
						Plugin.Logger.Info("UnitSpawnerService", $"Spawn callback triggered for entity={current}, key={num}");
						var (num2, action) = value;
						PostActions.Remove(num);
						LifeTimeEndAction endAction = (LifeTimeEndAction)((!(num2 < 0f)) ? 2 : 0);
						LifeTime val = new LifeTime
						{
							Duration = num2,
							EndAction = endAction
						};
						entityManager = Core.EntityManager;
						((EntityManager)(ref entityManager)).SetComponentData<LifeTime>(current, val);
						action(current);
					}
				}
			}
		}

		private static Entity empty_entity = default(Entity);

		internal const int DEFAULT_MINRANGE = 0;

		internal const int DEFAULT_MAXRANGE = 0;

		internal static Dictionary<long, (float actualDuration, Action<Entity> Actions)> PostActions = new Dictionary<long, (float, Action<Entity>)>();

		public static Entity SpawnWithCallback(Entity user, PrefabGUID unit, float2 position, float duration, Action<Entity> postActions, float yPosition = -1f)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (yPosition == -1f)
			{
				EntityManager entityManager = Core.EntityManager;
				yPosition = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(user).Value.y;
			}
			float3 val = default(float3);
			((float3)(ref val))..ctor(position.x, yPosition, position.y);
			UnitSpawnerUpdateSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<UnitSpawnerUpdateSystem>();
			UnitSpawnerReactSystem_Patch.Enabled = true;
			long num = NextKey();
			existingSystemManaged.SpawnUnit(empty_entity, unit, val, 1, 0f, 0f, (float)num);
			PostActions.Add(num, (duration, postActions));
			return empty_entity;
		}

		internal static long NextKey()
		{
			Random random = new Random();
			int num = 5;
			long num2;
			do
			{
				num2 = random.NextInt64(10000L) * 3;
				num--;
				if (num < 0)
				{
					throw new Exception("Failed to generate a unique key for UnitSpawnerService");
				}
			}
			while (PostActions.ContainsKey(num2));
			return num2;
		}
	}
}
namespace PrisonerExchange.Services.Chat
{
	public static class CooldownTracker
	{
		private static ConcurrentDictionary<(ulong platFormId, string CommandName), DateTime> cooldowns = new ConcurrentDictionary<(ulong, string), DateTime>();

		public static bool IsOnCooldown(ulong platFormId, string commandName)
		{
			if (cooldowns.TryGetValue((platFormId, commandName), out var value))
			{
				return DateTime.UtcNow < value;
			}
			return false;
		}

		public static double GetRemainingSeconds(ulong platFormId, string commandName)
		{
			if (cooldowns.TryGetValue((platFormId, commandName), out var value))
			{
				TimeSpan timeSpan = value - DateTime.UtcNow;
				if (!(timeSpan.TotalSeconds > 0.0))
				{
					return 0.0;
				}
				return timeSpan.TotalSeconds;
			}
			return 0.0;
		}

		public static void SetCooldown(ulong platFormId, string commandName)
		{
			DateTime value = DateTime.UtcNow.Add(TimeSpan.FromMinutes(Configuration.CommandCoolDownPeriod));
			cooldowns[(platFormId, commandName)] = value;
		}

		public static void ClearAllCooldowns(ulong platFormId)
		{
			foreach (var key in cooldowns.Keys)
			{
				if (key.platFormId == platFormId)
				{
					cooldowns.TryRemove(key, out var _);
				}
			}
		}
	}
	public static class PromptHelper
	{
		public static void UserInput(ChatCommandContext ctx, Action<string> onInput, string instruction = "Please enter a value:", int timeout = 30)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			ulong platformId = ctx.Event.User.PlatformId;
			if (instruction != null)
			{
				ctx.Reply(instruction);
			}
			PromptManager.RequestInput(platformId, delegate(string response)
			{
				onInput(response);
			}, delegate
			{
				ctx.Reply("Selection has timed out.");
			}, timeout);
		}
	}
	public static class PromptManager
	{
		private class PromptData
		{
			public Action<string> OnInput;

			public Action OnTimeout;

			public Timer Timeout;
		}

		private static readonly Dictionary<ulong, PromptData> storedPrompts = new Dictionary<ulong, PromptData>();

		public static void RequestInput(ulong userId, Action<string> onInput, Action onTimeout, int timeoutSeconds = 30)
		{
			CancelPrompt(userId);
			Timer timer = new Timer(timeoutSeconds * 1000);
			timer.Elapsed += delegate
			{
				CancelPrompt(userId);
				onTimeout?.Invoke();
			};
			timer.AutoReset = false;
			timer.Start();
			storedPrompts[userId] = new PromptData
			{
				OnInput = onInput,
				OnTimeout = onTimeout,
				Timeout = timer
			};
		}

		public static bool TryHandleInput(ulong userId, string message)
		{
			if (!storedPrompts.TryGetValue(userId, out var value))
			{
				return false;
			}
			value.Timeout.Stop();
			storedPrompts.Remove(userId);
			value.OnInput?.Invoke(message);
			return true;
		}

		public static void CancelPrompt(ulong userId)
		{
			if (storedPrompts.TryGetValue(userId, out var value))
			{
				value.Timeout.Stop();
				storedPrompts.Remove(userId);
			}
		}

		public static bool IsWaiting(ulong userId)
		{
			return storedPrompts.ContainsKey(userId);
		}
	}
	public class StringBuilders
	{
		public static void AnnounceSale(PendingSale sale)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			PrisonerModel.PrisonerInformation getPrisonerInformation = sale.GetPrisonerInformation;
			FixedString512Bytes val = default(FixedString512Bytes);
			((FixedString512Bytes)(ref val))..ctor($"{Markup.Prefix}{sale.Buyer.CharacterName} has purchased {getPrisonerInformation.UnitType} with {getPrisonerInformation.BloodQuality}%{getPrisonerInformation.BloodType} from {sale.Seller.CharacterName}!");
			ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val);
		}

		public static string SalesInfoMessage(PendingSale sale)
		{
			PrisonerModel.PrisonerInformation getPrisonerInformation = sale.GetPrisonerInformation;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("<size=15><color=yellow>Prisoner sale request</color></size>");
			StringBuilder stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder3 = stringBuilder2;
			StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(11, 1, stringBuilder2);
			handler.AppendLiteral("From user: ");
			handler.AppendFormatted(Markup.Highlight(sale.Seller.CharacterName));
			stringBuilder3.AppendLine(ref handler);
			stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder4 = stringBuilder2;
			handler = new StringBuilder.AppendInterpolatedStringHandler(8, 2, stringBuilder2);
			handler.AppendLiteral("Price: ");
			handler.AppendFormatted(Markup.Highlight(sale.Price));
			handler.AppendLiteral(" ");
			handler.AppendFormatted(Configuration.CurrencyName);
			stringBuilder4.AppendLine(ref handler);
			stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder5 = stringBuilder2;
			handler = new StringBuilder.AppendInterpolatedStringHandler(15, 1, stringBuilder2);
			handler.AppendLiteral("Prisoner type: ");
			handler.AppendFormatted(getPrisonerInformation.UnitType);
			stringBuilder5.AppendLine(ref handler);
			stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder6 = stringBuilder2;
			handler = new StringBuilder.AppendInterpolatedStringHandler(16, 1, stringBuilder2);
			handler.AppendLiteral("Prisoner blood: ");
			handler.AppendFormatted(Markup.Highlight(getPrisonerInformation.BloodQuality + "% " + getPrisonerInformation.BloodType));
			stringBuilder6.AppendLine(ref handler);
			stringBuilder.AppendLine();
			stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder7 = stringBuilder2;
			handler = new StringBuilder.AppendInterpolatedStringHandler(50, 1, stringBuilder2);
			handler.AppendLiteral("Type ");
			handler.AppendFormatted(Markup.Highlight(".pe acceptsale"));
			handler.AppendLiteral(" while standing next to an empty prison cell.");
			stringBuilder7.AppendLine(ref handler);
			return stringBuilder.ToString();
		}

		public static string SwapInfoMessage(PendingSwap swap)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("<size=15><color=yellow>Prisoner swap request</color></size>");
			StringBuilder stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder3 = stringBuilder2;
			StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(11, 1, stringBuilder2);
			handler.AppendLiteral("From user: ");
			handler.AppendFormatted(Markup.Highlight(swap.Seller.CharacterName));
			stringBuilder3.AppendLine(ref handler);
			stringBuilder.AppendLine("Offering: " + Markup.Highlight(swap.PrisonerB.Info.UnitType ?? "") + " " + Markup.Secondary(swap.PrisonerB.Info.BloodQuality + "% " + swap.PrisonerB.Info.BloodType));
			stringBuilder.AppendLine("For your: " + Markup.Highlight(swap.PrisonerA.Info.UnitType ?? "") + " " + Markup.Secondary(swap.PrisonerA.Info.BloodQuality + "% " + swap.PrisonerA.Info.BloodType));
			stringBuilder.AppendLine();
			stringBuilder2 = stringBuilder;
			StringBuilder stringBuilder4 = stringBuilder2;
			handler = new StringBuilder.AppendInterpolatedStringHandler(27, 1, stringBuilder2);
			handler.AppendLiteral("Type ");
			handler.AppendFormatted(Markup.Highlight(".pe acceptswap"));
			handler.AppendLiteral(" to complete the swap.");
			stringBuilder4.AppendLine(ref handler);
			return stringBuilder.ToString();
		}

		public static void SendPrisonerList(ChatCommandContext ctx, List<PrisonerModel> list)
		{
			StringBuilder sb = new StringBuilder();
			int currentBytes = 0;
			bool isFirstBatch = true;
			sb.AppendLine();
			currentBytes += Encoding.UTF8.GetByteCount("\n");
			for (int i = 0; i < list.Count; i++)
			{
				PrisonerModel.PrisonerInformation info = list[i].Info;
				string s = info.BloodQuality + "% " + info.BloodType;
				string text = $"[{Markup.Secondary(i + 1)}] {Markup.Highlight(info.UnitType)} {Markup.Secondary(s)}";
				int byteCount = Encoding.UTF8.GetByteCount(text + "\n");
				if (currentBytes + byteCount >= 512)
				{
					Flush();
					if (!isFirstBatch)
					{
						sb.AppendLine();
						currentBytes += Encoding.UTF8.GetByteCount("\n");
					}
				}
				sb.AppendLine(text);
				currentBytes += byteCount;
			}
			string text2 = $"{Markup.Secondary("Select")}{Markup.Highlight(" a prisoner by typing a number in chat")} ({Markup.Secondary("!s to cancel")})";
			int byteCount2 = Encoding.UTF8.GetByteCount(text2 + "\n");
			if (currentBytes + byteCount2 >= 512)
			{
				Flush();
			}
			sb.AppendLine();
			sb.AppendLine(text2);
			Flush();
			void Flush()
			{
				if (sb.Length > 0)
				{
					ctx.Reply(sb.ToString());
					sb.Clear();
					currentBytes = 0;
					isFirstBatch = false;
				}
			}
		}
	}
}
namespace PrisonerExchange.Models
{
	public class PendingSale
	{
		public UserModel Seller { get; }

		public UserModel Buyer { get; }

		public Entity PrisonerEntity { get; }

		public int Price { get; }

		public DateTime CreatedAt { get; }

		public double LifetimeSeconds { get; }

		public PrisonerModel.PrisonerInformation GetPrisonerInformation => new PrisonerModel(PrisonerEntity).Info;

		public PendingSale(UserModel seller, Entity prisonerEntity, UserModel buyer, int price, double lifetimeSeconds = 120.0)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Seller = seller;
			Buyer = buyer;
			PrisonerEntity = prisonerEntity;
			Price = price;
			CreatedAt = DateTime.UtcNow;
			LifetimeSeconds = lifetimeSeconds;
		}
	}
	public class PrisonerModel
	{
		public class PrisonerInformation
		{
			public PrefabGUID PrefabGUID { get; init; }

			public BloodConsumeSource BloodInfo { get; init; }

			public string UnitType { get; init; }

			public string BloodType { get; init; }

			public string BloodQuality { get; init; }
		}

		private readonly EntityManager EM = Core.EntityManager;

		private readonly Entity entity;

		public Entity PrisonerEntity => entity;

		public PrisonerInformation Info
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				if (!entity.Exists())
				{
					return null;
				}
				PrefabGUID val = PrefabGUID.Empty;
				BloodConsumeSource val2 = default(BloodConsumeSource);
				string unitType = "Unknown";
				string bloodType = "Unknown";
				string bloodQuality = "Unknown";
				if (entity.Has<PrefabGUID>())
				{
					val = entity.Read<PrefabGUID>();
					unitType = (Prefabs.UnitTypes.TryGetValue(val, out var value) ? value : "Unknown");
				}
				if (entity.Has<BloodConsumeSource>())
				{
					val2 = entity.Read<BloodConsumeSource>();
					bloodType = (Prefabs.BloodTypes.TryGetValue(ModifiablePrefabGUID.op_Implicit(val2.UnitBloodType), out var value2) ? value2 : "Unknown");
					bloodQuality = val2.BloodQuality.ToString("F0");
				}
				return new PrisonerInformation
				{
					PrefabGUID = val,
					BloodInfo = val2,
					UnitType = unitType,
					BloodType = bloodType,
					BloodQuality = bloodQuality
				};
			}
		}

		public PrisonerModel(Entity prisoner)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			entity = prisoner;
		}
	}
	public class UserModel
	{
		public Entity Entity { get; }

		public User User { get; }

		public ulong PlatformId { get; }

		public string CharacterName { get; }

		public bool IsAdmin { get; }

		public bool IsClanLeader
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Invalid comparison between Unknown and I4
				if (Entity.TryGetComponent<ClanRole>(out ClanRole component) && (int)component.Value == 2)
				{
					return true;
				}
				return false;
			}
		}

		public UserModel(Entity entity, User userData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Entity = entity;
			User = userData;
			PlatformId = userData.PlatformId;
			CharacterName = ((object)(FixedString64Bytes)(ref userData.CharacterName)).ToString();
			IsAdmin = userData.IsAdmin;
		}

		public override bool Equals(object obj)
		{
			if (obj is UserModel userModel)
			{
				return PlatformId == userModel.PlatformId;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return PlatformId.GetHashCode();
		}
	}
}
namespace PrisonerExchange.Extensions
{
	internal static class Ecs
	{
		public delegate void WithRefHandler<T>(ref T item);

		private static EntityManager EM => Core.EntityManager;

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (entity != Entity.Null)
			{
				EntityManager eM = EM;
				return ((EntityManager)(ref eM)).Exists(entity);
			}
			return false;
		}

		public static bool HasValue(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return entity != Entity.Null;
		}

		public static bool Has<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).HasComponent<T>(entity);
		}

		public static bool TryGetComponent<T>(this Entity entity, out T component) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			if (((EntityManager)(ref eM)).HasComponent<T>(entity))
			{
				component = entity.Read<T>();
				return true;
			}
			component = default(T);
			return false;
		}

		public static T Read<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			return ((EntityManager)(ref eM)).GetComponentData<T>(entity);
		}

		public static void Write<T>(this Entity entity, T data) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EntityManager eM = EM;
			((EntityManager)(ref eM)).SetComponentData<T>(entity, data);
		}

		public unsafe static void WriteRaw<T>(this Entity entity, T data) where T : struct
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(data);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager eM = EM;
				((EntityManager)(ref eM)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		private static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			try
			{
				Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
				Marshal.Copy(intPtr, array, 0, num);
				return array;
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}

		public static void Add<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!entity.Has<T>())
			{
				EntityManager eM = EM;
				((EntityManager)(ref eM)).AddComponent<T>(entity);
			}
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = Core.EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static bool TryRemoveComponent<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Has<T>())
			{
				EntityManager eM = EM;
				((EntityManager)(ref eM)).RemoveComponent<T>(entity);
				return true;
			}
			return false;
		}

		public static void With<T>(this Entity entity, WithRefHandler<T> action) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Exists())
			{
				T item = entity.Read<T>();
				action(ref item);
				entity.Write(item);
			}
		}

		public static void AddWith<T>(this Entity entity, WithRefHandler<T> action) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			entity.Add<T>();
			entity.With(action);
		}

		public static bool SameTeam(this Entity entityA, Entity entityB)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!entityA.Exists() || !entityB.Exists())
			{
				return false;
			}
			if (!entityA.Has<Team>() || !entityB.Has<Team>())
			{
				return false;
			}
			Team val = entityA.Read<Team>();
			Team val2 = entityB.Read<Team>();
			return val.Value == val2.Value;
		}
	}
	public static class Log
	{
		public static void Info(this ManualLogSource logger, string context, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(3, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(context);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
			}
			logger.LogInfo(val);
		}

		public static void Message(this ManualLogSource logger, string context, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(3, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(context);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
			}
			logger.LogMessage(val);
		}

		public static void Warning(this ManualLogSource logger, string context, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(3, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(context);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
			}
			logger.LogWarning(val);
		}

		public static void Error(this ManualLogSource logger, string context, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(3, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(context);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
			}
			logger.LogError(val);
		}
	}
}
namespace PrisonerExchange.Data
{
	public class Prefabs
	{
		public static Dictionary<PrefabGUID, string> BloodTypes = new Dictionary<PrefabGUID, string>
		{
			{
				new PrefabGUID(804798592),
				"Brute"
			},
			{
				new PrefabGUID(524822543),
				"Creature"
			},
			{
				new PrefabGUID(1328126535),
				"Draculin"
			},
			{
				new PrefabGUID(910644396),
				"GateBoss"
			},
			{
				new PrefabGUID(1821108694),
				"Mutant"
			},
			{
				new PrefabGUID(-1620185637),
				"Rogue"
			},
			{
				new PrefabGUID(1476452791),
				"Scholar"
			},
			{
				new PrefabGUID(-338774148),
				"VBlood"
			},
			{
				new PrefabGUID(-516976528),
				"Warrior"
			},
			{
				new PrefabGUID(-1776904174),
				"Worker"
			},
			{
				new PrefabGUID(-1382693416),
				"Corrupted"
			}
		};

		public static Dictionary<PrefabGUID, string> UnitTypes = new Dictionary<PrefabGUID, string>
		{
			{
				new PrefabGUID(-2080231735),
				"Bloodprophet"
			},
			{
				new PrefabGUID(-2072914343),
				"Rat"
			},
			{
				new PrefabGUID(-2046268156),
				"Nightlurker"
			},
			{
				new PrefabGUID(-2018710724),
				"Zapper"
			},
			{
				new PrefabGUID(-1875351031),
				"Slave"
			},
			{
				new PrefabGUID(-1750347680),
				"Scarecrow"
			},
			{
				new PrefabGUID(-1733829912),
				"Lurker"
			},
			{
				new PrefabGUID(-1722278689),
				"Giant rat"
			},
			{
				new PrefabGUID(-1719333743),
				"Militia Rider"
			},
			{
				new PrefabGUID(-1697944553),
				"Corrupted Bear"
			},
			{
				new PrefabGUID(-1562098554),
				"Peon"
			},
			{
				new PrefabGUID(-1508046438),
				"Woodcarver"
			},
			{
				new PrefabGUID(-1356006948),
				"Pig"
			},
			{
				new PrefabGUID(-1353870145),
				"Villager"
			},
			{
				new PrefabGUID(-1342764880),
				"Farmer"
			},
			{
				new PrefabGUID(-1266036232),
				"Highlord"
			},
			{
				new PrefabGUID(-1200074387),
				"Shadowkin"
			},
			{
				new PrefabGUID(-1082044089),
				"Sentryturret"
			},
			{
				new PrefabGUID(-1072754152),
				"Miner"
			},
			{
				new PrefabGUID(-1055380229),
				"Batswarm"
			},
			{
				new PrefabGUID(-1009917656),
				"Nightmare"
			},
			{
				new PrefabGUID(-981051151),
				"Nightmare"
			},
			{
				new PrefabGUID(-893091615),
				"Woodcutter"
			},
			{
				new PrefabGUID(-884401089),
				"Gattler"
			},
			{
				new PrefabGUID(-831097925),
				"Forest Moose"
			},
			{
				new PrefabGUID(-825299465),
				"Gloomrot Technician Labworker"
			},
			{
				new PrefabGUID(-799718518),
				"Carriagehorse Banditanimal"
			},
			{
				new PrefabGUID(-779632831),
				"Winter Moose"
			},
			{
				new PrefabGUID(-764515001),
				"Spider"
			},
			{
				new PrefabGUID(-744966291),
				"Cursed Mosquito"
			},
			{
				new PrefabGUID(-699233841),
				"Peon Miner"
			},
			{
				new PrefabGUID(-669027288),
				"Dracula minion"
			},
			{
				new PrefabGUID(-653348998),
				"Vargulf"
			},
			{
				new PrefabGUID(-581295882),
				"Spider"
			},
			{
				new PrefabGUID(-575831311),
				"Mutated Deer"
			},
			{
				new PrefabGUID(-559819989),
				"Cursed Bear"
			},
			{
				new PrefabGUID(-375581934),
				"Mutant Rathorror"
			},
			{
				new PrefabGUID(-372256748),
				"Rat"
			},
			{
				new PrefabGUID(-322293503),
				"Pyro"
			},
			{
				new PrefabGUID(-249647316),
				"Militia Hound"
			},
			{
				new PrefabGUID(-240536861),
				"Sentry"
			},
			{
				new PrefabGUID(-235172198),
				"Militia Horseman"
			},
			{
				new PrefabGUID(-218175217),
				"Cursed Wolf"
			},
			{
				new PrefabGUID(-81727312),
				"Villager"
			},
			{
				new PrefabGUID(-65981941),
				"Gargoyle"
			},
			{
				new PrefabGUID(-56441915),
				"Cursed Witch"
			},
			{
				new PrefabGUID(-54072010),
				"Cursed Witch"
			},
			{
				new PrefabGUID(-38041784),
				"Cursed Monstertoad"
			},
			{
				new PrefabGUID(37713289),
				"Militia Torchbearer"
			},
			{
				new PrefabGUID(134039094),
				"Winter Wolf"
			},
			{
				new PrefabGUID(218843465),
				"Rathorror Mutant"
			},
			{
				new PrefabGUID(326501064),
				"Alchemist"
			},
			{
				new PrefabGUID(342127250),
				"Spider Broodmother"
			},
			{
				new PrefabGUID(426583055),
				"Archer"
			},
			{
				new PrefabGUID(470753758),
				"Ocean Piranha"
			},
			{
				new PrefabGUID(572729167),
				"Mutant Wolf"
			},
			{
				new PrefabGUID(574276383),
				"Spider Forestling"
			},
			{
				new PrefabGUID(575918722),
				"Cursed Toad"
			},
			{
				new PrefabGUID(593505050),
				"Batswarm"
			},
			{
				new PrefabGUID(616274140),
				"Corrupted Wolf"
			},
			{
				new PrefabGUID(721166952),
				"Cow"
			},
			{
				new PrefabGUID(891705701),
				"Enforcer"
			},
			{
				new PrefabGUID(924132254),
				"Miner"
			},
			{
				new PrefabGUID(947731555),
				"Ram"
			},
			{
				new PrefabGUID(1012307512),
				"Sheep"
			},
			{
				new PrefabGUID(1043643344),
				"Bear"
			},
			{
				new PrefabGUID(1092792896),
				"Mutant Spitter"
			},
			{
				new PrefabGUID(1209580976),
				"Dartflinger"
			},
			{
				new PrefabGUID(1401026468),
				"Sentry Officer"
			},
			{
				new PrefabGUID(1434914085),
				"Pixie"
			},
			{
				new PrefabGUID(1439742793),
				"Valyrcauldron"
			},
			{
				new PrefabGUID(1478790879),
				"Cursed Toadspitter"
			},
			{
				new PrefabGUID(1531777139),
				"Sentinel"
			},
			{
				new PrefabGUID(1570140219),
				"Mutated Moose"
			},
			{
				new PrefabGUID(1626314708),
				"Railgun Sergeant"
			},
			{
				new PrefabGUID(1696014952),
				"Deer"
			},
			{
				new PrefabGUID(1745498602),
				"Cardinal aide"
			},
			{
				new PrefabGUID(1780171587),
				"Corrupted Deer"
			},
			{
				new PrefabGUID(1786690263),
				"Ocean Blowfish"
			},
			{
				new PrefabGUID(1807491570),
				"Cultist Slicer"
			},
			{
				new PrefabGUID(1887807944),
				"Villager"
			},
			{
				new PrefabGUID(1897056612),
				"Deer"
			},
			{
				new PrefabGUID(1912966420),
				"Blood Prophet"
			},
			{
				new PrefabGUID(1938756250),
				"Mutant Bear"
			},
			{
				new PrefabGUID(1980594081),
				"Shadowkin"
			},
			{
				new PrefabGUID(2005508157),
				"Militia Heavy"
			},
			{
				new PrefabGUID(2041915372),
				"Winter Bear"
			},
			{
				new PrefabGUID(2055824593),
				"Pyromancer"
			},
			{
				new PrefabGUID(2097040330),
				"Moose"
			},
			{
				new PrefabGUID(2136899683),
				"Spider"
			},
			{
				new PrefabGUID(-2039670689),
				"Bandit Worker"
			},
			{
				new PrefabGUID(-1925881340),
				"Cultist"
			},
			{
				new PrefabGUID(-1707267769),
				"Batoon"
			},
			{
				new PrefabGUID(-1670130821),
				"BellRinger"
			},
			{
				new PrefabGUID(-1610391169),
				"Cultist"
			},
			{
				new PrefabGUID(-1464869978),
				"Cleric"
			},
			{
				new PrefabGUID(-1301144178),
				"Bandit Hunter"
			},
			{
				new PrefabGUID(-1194643220),
				"Bandit Rascal"
			},
			{
				new PrefabGUID(-1128238456),
				"Bandit Bomber"
			},
			{
				new PrefabGUID(-1076780215),
				"Legion Assassin"
			},
			{
				new PrefabGUID(-1030822544),
				"Bandit Deadeye"
			},
			{
				new PrefabGUID(-930333806),
				"Knight 2H"
			},
			{
				new PrefabGUID(-864975423),
				"Farmlands"
			},
			{
				new PrefabGUID(-700632469),
				"Militia Nun"
			},
			{
				new PrefabGUID(-589412777),
				"Bandit Trapper"
			},
			{
				new PrefabGUID(-494298686),
				"Night Maiden"
			},
			{
				new PrefabGUID(-309264723),
				"Bandit Stalker"
			},
			{
				new PrefabGUID(-301730941),
				"Bandit Thug"
			},
			{
				new PrefabGUID(-293507834),
				"Tractor Beamer"
			},
			{
				new PrefabGUID(-164116132),
				"Villager"
			},
			{
				new PrefabGUID(-63435588),
				"Militia Light"
			},
			{
				new PrefabGUID(-19416663),
				"Cultist"
			},
			{
				new PrefabGUID(57255106),
				"Cultist"
			},
			{
				new PrefabGUID(203103783),
				"Militia Longbowman"
			},
			{
				new PrefabGUID(286320185),
				"Bandit Prisoner"
			},
			{
				new PrefabGUID(407967118),
				"Cultist"
			},
			{
				new PrefabGUID(525027204),
				"Villager"
			},
			{
				new PrefabGUID(674807351),
				"Tazer"
			},
			{
				new PrefabGUID(729746981),
				"Villager"
			},
			{
				new PrefabGUID(794228023),
				"Shield Knight"
			},
			{
				new PrefabGUID(820492683),
				"Technician"
			},
			{
				new PrefabGUID(847893333),
				"Militia Bomber"
			},
			{
				new PrefabGUID(923140362),
				"Bandit Thief"
			},
			{
				new PrefabGUID(956965183),
				"Militia Crossbowman"
			},
			{
				new PrefabGUID(1069072707),
				"Bandit Prisoner"
			},
			{
				new PrefabGUID(1148936156),
				"Rifleman"
			},
			{
				new PrefabGUID(1185952775),
				"Lightweaver"
			},
			{
				new PrefabGUID(1220569089),
				"Bandit Scout"
			},
			{
				new PrefabGUID(1309418594),
				"Bandit Worker"
			},
			{
				new PrefabGUID(1406393857),
				"Priest"
			},
			{
				new PrefabGUID(1576267559),
				"Villager"
			},
			{
				new PrefabGUID(1660801216),
				"Militia Devoted"
			},
			{
				new PrefabGUID(1728773109),
				"Paladin"
			},
			{
				new PrefabGUID(1730498275),
				"Militia Guard"
			},
			{
				new PrefabGUID(1732477970),
				"Railgunner"
			},
			{
				new PrefabGUID(1772642154),
				"Knight"
			},
			{
				new PrefabGUID(2018586909),
				"Cultist"
			},
			{
				new PrefabGUID(2111003460),
				"Villager"
			},
			{
				new PrefabGUID(2128996433),
				"Villager"
			},
			{
				new PrefabGUID(2057508774),
				"Villager"
			},
			{
				new PrefabGUID(343676339),
				"Bandit Hunter"
			},
			{
				new PrefabGUID(-198252716),
				"Bandit Thug"
			},
			{
				new PrefabGUID(1743532914),
				"Bandit Worker"
			},
			{
				new PrefabGUID(1216169364),
				"Villager"
			},
			{
				new PrefabGUID(-732208863),
				"Villager"
			},
			{
				new PrefabGUID(1756241788),
				"Incinerator"
			},
			{
				new PrefabGUID(-951976780),
				"Werewolf"
			},
			{
				new PrefabGUID(-436956599),
				"Viper"
			},
			{
				new PrefabGUID(761646020),
				"Striker"
			},
			{
				new PrefabGUID(1451256919),
				"Peon"
			},
			{
				new PrefabGUID(1864177126),
				"Venomblade"
			}
		};
	}
}
namespace PrisonerExchange.Commands
{
	internal class AdminCommands
	{
		[Command("pe remove", null, null, "Remove a specific user’s pending prisoner sale or swap.", null, true)]
		public void RemoveExchange(ChatCommandContext ctx, string username)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			UserModel user = UserUtil.GetUserByCharacterName(username);
			if (user == null)
			{
				ctx.Reply(Markup.Prefix + "No user found: " + Markup.Highlight(username) + ".");
				return;
			}
			PendingSale pendingSale = SalesService.GetAll().FirstOrDefault((PendingSale s) => s.Seller.PlatformId == user.PlatformId || s.Buyer.PlatformId == user.PlatformId);
			if (pendingSale != null)
			{
				BuffUtil.RemoveBuff(pendingSale.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
				SalesService.RemoveSale(pendingSale.Seller);
				ctx.Reply(Markup.Prefix + "Removed sale request involving " + user.CharacterName + ".");
				return;
			}
			PendingSwap pendingSwap = SwapService.GetAll().FirstOrDefault((PendingSwap s) => s.Seller.PlatformId == user.PlatformId || s.Buyer.PlatformId == user.PlatformId);
			if (pendingSwap != null)
			{
				BuffUtil.RemoveBuff(pendingSwap.PrisonerA.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
				BuffUtil.RemoveBuff(pendingSwap.PrisonerB.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
				SwapService.RemoveSwap(pendingSwap.Seller);
				ctx.Reply(Markup.Prefix + "Removed swap request involving " + user.CharacterName + ".");
			}
			else
			{
				ctx.Reply(Markup.Prefix + "No active sale or swap found for user: " + Markup.Highlight(username) + ".");
			}
		}

		[Command("pe clear", null, null, "Clear all active prisoner exchanges (both sales and swaps).", null, true)]
		public void ClearExchanges(ChatCommandContext ctx)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			foreach (PendingSale item in SalesService.GetAll())
			{
				BuffUtil.RemoveBuff(item.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
			}
			SalesService.ClearAll();
			foreach (PendingSwap item2 in SwapService.GetAll())
			{
				BuffUtil.RemoveBuff(item2.PrisonerA.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
				BuffUtil.RemoveBuff(item2.PrisonerB.PrisonerEntity, BuffUtil.ELECTRIC_BUFF);
			}
			SwapService.ClearAll();
			ctx.Reply(Markup.Prefix + "Cleared all active prisoner sales and swaps!");
		}

		[Command("pe removecooldown", "Removes command cooldowns for a user", null, null, null, false)]
		public static void RemoveCooldownCommand(ChatCommandContext ctx, string username)
		{
			UserModel userByCharacterName = UserUtil.GetUserByCharacterName(username);
			if (userByCharacterName == null)
			{
				ctx.Reply(Markup.Prefix + "Could not find user " + username + ".");
				return;
			}
			ctx.Reply(Markup.Prefix + "Removed all cooldowns for user " + username + ".");
			CooldownTracker.ClearAllCooldowns(userByCharacterName.PlatformId);
		}
	}
	[CommandGroup("pe", "prisonerexchange")]
	internal class SaleCommands
	{
		[Command("sell", null, null, "Sell a prisoner for a price.", null, false)]
		public static void ExchangeCommand(ChatCommandContext ctx, string username, int price)
		{
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			UserModel currentUser = UserUtil.GetCurrentUser(ctx);
			UserModel userByCharacterName = UserUtil.GetUserByCharacterName(username);
			if (userByCharacterName == null)
			{
				ctx.Reply(Markup.Prefix + "Could not find user with the name " + Markup.Highlight(username) + ".");
				return;
			}
			if (SalesService.SaleExists(userByCharacterName) || SwapService.SwapExists(userByCharacterName))
			{
				ctx.Reply(Markup.Prefix + "Target already have a pending exchange offer!");
				return;
			}
			if (SalesService.SaleExists(currentUser))
			{
				ctx.Reply(Markup.Prefix + "You already have a pending exchange offer!");
				return;
			}
			if (!currentUser.IsAdmin)
			{
				if (!Configuration.SellingEnabled)
				{
					ctx.Reply(Markup.Prefix + "Selling prisoners is not enabled!");
					return;
				}
				if (CooldownTracker.IsOnCooldown(currentUser.PlatformId, "sell"))
				{
					double remainingSeconds = CooldownTracker.GetRemainingSeconds(currentUser.PlatformId, "sell");
					ctx.Reply($"{Markup.Prefix}You must wait another {(int)remainingSeconds} seconds before using /swap accept again!");
					return;
				}
				if (currentUser.Equals(userByCharacterName))
				{
					ctx.Reply(Markup.Prefix + "Cannot sell a prisoner to yourself!");
					return;
				}
				if (currentUser.Entity.SameTeam(userByCharacterName.Entity))
				{
					ctx.Reply(Markup.Prefix + "Cannot sell a prisoner to your own teammate!");
					return;
				}
				if (price < Configuration.MinimumSalePrice)
				{
					ctx.Reply($"{Markup.Prefix}You can only sell a prisoner for {Configuration.MinimumSalePrice} {Configuration.CurrencyName} or more!");
					return;
				}
				if (price > Configuration.MaximumSalePrice)
				{
					ctx.Reply($"{Markup.Prefix}Sale cannot exceed {Configuration.MaximumSalePrice} {Configuration.CurrencyName}!");
					return;
				}
				if (Configuration.ClanLeaderOnly && !currentUser.IsClanLeader)
				{
					ctx.Reply(Markup.Prefix + "Only clan leaders are allowed to sell prisoners!");
					return;
				}
			}
			Entity val = EntityUtil.FindClosestInRadius<PrisonCell>(currentUser.Entity, 5f);
			if (val == Entity.Null)
			{
				ctx.Reply(Markup.Prefix + "No suitable prison cell within range.");
				return;
			}
			if (!currentUser.Entity.SameTeam(val))
			{
				ctx.Reply(Markup.Prefix + "You cannot sell another clans prisoner!");
				return;
			}
			EntityManager entityManager = Core.EntityManager;
			PrisonCell val2 = default(PrisonCell);
			if (!((EntityManager)(ref entityManager)).TryGetComponentData<PrisonCell>(val, ref val2))
			{
				Plugin.Logger.Error("UserCommands", "Could not retrieve prison cell data.");
				ctx.Reply("Could not retrieve prison cell data.");
				return;
			}
			if (!PrisonerService.HasPrisoner(val))
			{
				ctx.Reply(Markup.Prefix + "The prison cell does not have a prisoner to sell!");
				return;
			}
			Entity entity = val2.ImprisonedEntity._Entity;
			PendingSale sale = new PendingSale(currentUser, entity, userByCharacterName, price, Configuration.ExpireExchangeAfter);
			SalesService.AddSale(sale);
			Plugin.Logger.Info("UserCommands", $"User '{currentUser.CharacterName}' initiated prisoner sale to '{userByCharacterName.CharacterName}' for {price} {Configuration.CurrencyName}.");
			BuffUtil.BuffNPC(entity, currentUser.Entity, BuffUtil.ELECTRIC_BUFF, Configuration.ExpireExchangeAfter);
			FixedString512Bytes val3 = default(FixedString512Bytes);
			((FixedString512Bytes)(ref val3))..ctor(StringBuilders.SalesInfoMessage(sale));
			ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, userByCharacterName.User, ref val3);
			FixedString512Bytes val4 = default(FixedString512Bytes);
			((FixedString512Bytes)(ref val4))..ctor(Markup.Prefix + "Request sent to user " + userByCharacterName.CharacterName);
			ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, currentUser.User, ref val4);
			CooldownTracker.SetCooldown(currentUser.PlatformId, "sell");
		}

		[Command("cancelsale", null, null, "Cancel your outgoing exchange request.", null, false)]
		public static void CancelCommand(ChatCommandContext ctx)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			UserModel currentUser = UserUtil.GetCurrentUser(ctx);
			PendingSale saleBySeller = SalesService.GetSaleBySeller(currentUser);
			if (saleBySeller == null)
			{
				ctx.Reply(Markup.Prefix + "No active exchange request found.");
				return;
			}
			if (!BuffUtil.RemoveBuff(saleBySeller.PrisonerEntity, BuffUtil.ELECTRIC_BUFF))
			{
				Plugin.Logger.Error("UserCommands", $"Failed to apply buff to {saleBySeller.PrisonerEntity}.");
			}
			SalesService.RemoveSale(currentUser);
			ctx.Reply(Markup.Prefix + "Your exchange request has been canceled.");
			Plugin.Logger.Info("UserCommands", "User '" + currentUser.CharacterName + "' cancelled their prisoner sale.");
		}

		[Command("acceptsale", null, null, "Accept incoming prisoner exchange request.", null, false)]
		public static void AcceptExchange(ChatCommandContext ctx)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_009e: 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_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			UserModel currentUser = UserUtil.GetCurrentUser(ctx);
			PendingSale saleByBuyer = SalesService.GetSaleByBuyer(currentUser);
			if (saleByBuyer == null)
			{
				ctx.Reply(Markup.Prefix + "There is no exchange request to accept.");
				return;
			}
			UserModel seller = saleByBuyer.Seller;
			PrisonerModel prisoner = new PrisonerModel(saleByBuyer.PrisonerEntity);
			int price = saleByBuyer.Price;
			if (seller == null || !seller.User.IsConnected)
			{
				ctx.Reply(Markup.Prefix + "Seller cannot be found or is offline.");
				return;
			}
			Entity val = EntityUtil.FindClosestInRadius<PrisonCell>(currentUser.Entity, 3f);