Decompiled source of RaidForge v3.2.2

RaidForge.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using HookDOTS.API;
using HookDOTS.API.Attributes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Gameplay.Clan;
using ProjectM.Gameplay.Scripting;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using RaidForge.Config;
using RaidForge.Core;
using RaidForge.Data;
using RaidForge.Patches;
using RaidForge.Services;
using RaidForge.Systems;
using RaidForge.Utils;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
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("RaidForge")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows for flexible control over raid mechanics.")]
[assembly: AssemblyFileVersion("3.2.2.0")]
[assembly: AssemblyInformationalVersion("3.2.2")]
[assembly: AssemblyProduct("RaidForge")]
[assembly: AssemblyTitle("RaidForge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RaidForge
{
	[BepInPlugin("raidforge", "RaidForge", "3.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		private HookDOTS _hookDOTS;

		private static ConfigFile _raidScheduleConfigFile;

		private static ConfigFile _golemSettingsConfigFile;

		private static ConfigFile _offlineProtectionConfigFile;

		private static ConfigFile _raidInterferenceConfigFile;

		private static ConfigFile _troubleshootingConfigFile;

		private static ConfigFile _optInRaidingConfigFile;

		private static ConfigFile _optInScheduleConfigFile;

		private static ConfigFile _weaponRaidingConfigFile;

		private static ConfigFile _tntRaidingConfigFile;

		private static ConfigFile _commandSettingsConfigFile;

		private static ConfigFile _shardConfigFile;

		private static ConfigFile _mapIconsConfigFile;

		private static ConfigFile _purchasedOrpConfigFile;

		private static ConfigFile _servantLimitsConfigFile;

		private static bool _onBootShardScanHasRun = false;

		public static Plugin Instance { get; private set; }

		public static ManualLogSource Logger { get; private set; }

		public static bool SystemsInitialized { get; private set; } = false;

		public static bool ServerHasJustBooted { get; private set; } = true;

		public static bool IsAutoRaidCurrentlyActive => RaidSchedulingSystem.IsAutoRaidActive;

		public static List<RaidScheduleEntry> GetSchedule()
		{
			if (RaidConfig.Schedule != null)
			{
				return new List<RaidScheduleEntry>(RaidConfig.Schedule);
			}
			return new List<RaidScheduleEntry>();
		}

		public override void Load()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			Instance = this;
			ServerHasJustBooted = true;
			SystemsInitialized = false;
			_onBootShardScanHasRun = false;
			Logger = ((BasePlugin)this).Log;
			LoggingHelper.Initialize(Logger);
			ResetRuntimeStateForFreshLoad();
			LoadConfigs();
			bool flag = default(bool);
			try
			{
				_harmony = new Harmony("raidforge");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
				RaidForgeScheduler.Initialize();
				_hookDOTS = new HookDOTS("raidforge", Logger);
				_hookDOTS.RegisterAnnotatedHooks();
				Logger.LogInfo((object)"[RaidForge] HookDOTS registered. Damage policy hook active.");
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] Patching failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
			}
			RaidInterferenceService.Initialize();
			try
			{
				CommandRegistry.RegisterAll();
				CommandRegistryCustomizationService.ApplyStartupConfiguration();
			}
			catch (Exception ex2)
			{
				ManualLogSource logger2 = Logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] Failed to register commands: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex2);
				}
				logger2.LogError(val);
			}
			Logger.LogInfo((object)"[RaidForge] Loaded. Waiting for server world update to initialize systems...");
		}

		public static void AttemptInitializeCoreSystems()
		{
			//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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!SystemsInitialized && VWorld.IsServerWorldReady())
			{
				Logger.LogInfo((object)"[RaidForge] Server world detected. Initializing systems...");
				EntityManager entityManager = VWorld.EntityManager;
				PrefabGuidResolver.ValidateKnownPrefabs();
				ServantLimitService.ReloadConfiguredLimits(entityManager);
				SystemsInitialized = true;
				bool value = OfflineRaidProtectionConfig.EnableOfflineRaidProtection.Value;
				bool num = OptInRaidingConfig.EnableOptInRaiding.Value && !value;
				bool flag = PurchasedOrpConfig.IsPurchasedOrpActive();
				if (value)
				{
					OfflineGraceService.LoadOfflineStatesFromDisk(entityManager);
				}
				if (num)
				{
					OptInRaidService.LoadStateFromDisk();
				}
				if (flag)
				{
					PurchasedOrpService.LoadStateFromDisk();
				}
				if (value)
				{
					ShardVulnerabilityService.LoadStateFromDisk();
				}
				int num2 = OwnershipCacheService.InitializeHeartOwnershipCache(entityManager);
				int num3 = OwnershipCacheService.InitializeUserToClanCache(entityManager);
				ManualLogSource logger = Logger;
				bool flag2 = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 2, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] World Scan Complete: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Hearts, ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num3);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Users.");
				}
				logger.LogInfo(val);
				RaidMapIconService.ClearAllRaidForgeIconEntities(entityManager);
				RunOnBootShardScanIfNeeded();
				if (ServerHasJustBooted)
				{
					OfflineGraceService.EstablishInitialGracePeriodsOnBoot(entityManager);
					ServerHasJustBooted = false;
				}
				PlayerRegistryService.RefreshFromWorld(entityManager);
				RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true);
				GolemAutomationSystem.CheckAutomation();
				RegisterRecurringTask("raid schedule check", delegate
				{
					RaidSchedulingSystem.CheckScheduleAndToggleRaids();
				}, 30.0);
				RegisterRecurringTask("Golem automation check", delegate
				{
					GolemAutomationSystem.CheckAutomation();
				}, 3600.0);
				RegisterRecurringTask("raid interference check", RaidInterferenceService.ProcessInterference, 2.0);
				RegisterRecurringTask("raid map icon cleanup", RaidMapIconService.ProcessCleanup, 5.0);
				RegisterRecurringTask("opt-in cooldown check", ProcessOptInCooldowns, 300.0);
				RegisterRecurringTask("purchased ORP raid-day accounting", PurchasedOrpService.ProcessDueRaidDayConsumption, 300.0);
				Logger.LogInfo((object)"[RaidForge] Initialization Complete. Mod is Active.");
			}
		}

		private static void RegisterRecurringTask(string taskName, Action action, double intervalSeconds)
		{
			RaidForgeScheduler.RunEvery(delegate
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				try
				{
					action();
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Logger;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] Error in scheduled ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(taskName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val);
				}
			}, intervalSeconds);
		}

		private static void ProcessOptInCooldowns()
		{
			if (OptInRaidingConfig.EnableOptInRaiding.Value && !OfflineRaidProtectionConfig.EnableOfflineRaidProtection.Value && OptInRaidingConfig.AutoOptOutAfterCooldown.Value)
			{
				OptInRaidService.ProcessAutoOptOut(OptInRaidingConfig.OptInLockDurationHours.Value);
			}
		}

		public static void RunOnBootShardScanIfNeeded()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!_onBootShardScanHasRun && SystemsInitialized)
			{
				if (!OfflineRaidProtectionConfig.EnableOfflineRaidProtection.Value || !ShardConfig.DisableOrpForShardHolders.Value)
				{
					_onBootShardScanHasRun = true;
				}
				else if (!_onBootShardScanHasRun)
				{
					PerformOnBootShardVulnerabilityScan(VWorld.EntityManager);
					_onBootShardScanHasRun = true;
				}
			}
		}

		private static void PerformOnBootShardVulnerabilityScan(EntityManager em)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001d: 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_0027: 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_0035: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0118: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			HashSet<string> hashSet = new HashSet<string>();
			try
			{
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				bool flag = default(bool);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!OwnerIdentityHelper.TryResolveFromUserEntity(em, current, out var owner, out var error))
					{
						ManualLogSource logger = Logger;
						if (logger != null)
						{
							BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[RaidForge] Skipping on-boot shard scan owner resolution: ");
								((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(error);
							}
							logger.LogWarning(val3);
						}
						continue;
					}
					HashSet<PrefabGUID> hashSet2 = new HashSet<PrefabGUID>();
					Entity entity = owner.UserData.LocalCharacter._Entity;
					if (entity.Exists() && UserHelper.TryGetSoulShardsOnPerson(em, entity, out var foundShards, out var locationSummary))
					{
						foreach (PrefabGUID item in foundShards)
						{
							hashSet2.Add(item);
						}
					}
					if (!string.IsNullOrEmpty(owner.PersistentKey) && hashSet.Add(owner.PersistentKey) && UserHelper.TryGetSoulShardsInOwnedPedestals(em, current, out var foundShards2, out locationSummary))
					{
						foreach (PrefabGUID item2 in foundShards2)
						{
							hashSet2.Add(item2);
						}
					}
					if (hashSet2.Count == 0)
					{
						continue;
					}
					int maxCopiesForThisShard = ShardConfig.MaxAllowedShardsPerType?.Value ?? 1;
					foreach (PrefabGUID item3 in hashSet2)
					{
						PrefabGUID current4 = item3;
						ShardVulnerabilityService.SetVulnerable(owner.PersistentKey, ((PrefabGUID)(ref current4)).GuidHash, owner.UserKey, owner.ContextualName, maxCopiesForThisShard, deferSave: true);
					}
				}
				ShardVulnerabilityService.Flush();
			}
			catch (Exception ex)
			{
				LoggingHelper.Error("Error during on-boot shard scan", ex);
			}
			finally
			{
				if (val2.IsCreated)
				{
					val2.Dispose();
				}
				((EntityQuery)(ref val)).Dispose();
			}
		}

		private void OnConfigSettingChanged(object sender, SettingChangedEventArgs e)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if (sender == _raidScheduleConfigFile)
			{
				RaidConfig.ParseSchedule();
				PurchasedOrpService.ProcessDueRaidDayConsumption(force: true);
				if (SystemsInitialized)
				{
					RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true);
					RaidMapIconService.MarkPersistentStateIconsDirty();
				}
			}
			else if (sender == _golemSettingsConfigFile)
			{
				GolemAutomationConfig.ReloadAndParseAll();
				if (SystemsInitialized)
				{
					GolemAutomationSystem.ResetAutomationState();
					GolemAutomationSystem.CheckAutomation();
				}
			}
			else if (sender == _mapIconsConfigFile)
			{
				if (SystemsInitialized)
				{
					RaidMapIconService.MarkPersistentStateIconsDirty();
					RaidMapIconService.ClearAllRaidForgeIconEntities(VWorld.EntityManager);
					RaidMapIconService.ProcessCleanup();
				}
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"[RaidForge] MapIcons.cfg changed. New values will be used by map icon services.");
				}
			}
			else if (sender == _optInRaidingConfigFile)
			{
				if (SystemsInitialized)
				{
					OptInRaidService.ReloadStateFromDisk();
					PurchasedOrpService.ReloadStateFromDisk();
					RaidMapIconService.MarkPersistentStateIconsDirty();
					RaidMapIconService.ClearAllRaidForgeIconEntities(VWorld.EntityManager);
					RaidMapIconService.ProcessCleanup();
				}
				ManualLogSource logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"[RaidForge] OptInRaiding.cfg changed. Opt-in mode and map icons were refreshed.");
				}
			}
			else if (sender == _purchasedOrpConfigFile)
			{
				if (SystemsInitialized)
				{
					PurchasedOrpService.ReloadStateFromDisk();
					RaidMapIconService.MarkPersistentStateIconsDirty();
					RaidMapIconService.ClearAllRaidForgeIconEntities(VWorld.EntityManager);
					RaidMapIconService.ProcessCleanup();
				}
				ManualLogSource logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogInfo((object)"[RaidForge] PurchasedORP.cfg changed. Purchased ORP state and map icons were refreshed.");
				}
			}
			else if (sender == _raidInterferenceConfigFile)
			{
				RaidInterferenceService.ResetRuntimeState();
				RaidInterferenceService.Initialize();
				ManualLogSource logger4 = Logger;
				if (logger4 != null)
				{
					logger4.LogInfo((object)"[RaidForge] RaidInterference.cfg changed. Runtime raid interference state was refreshed.");
				}
			}
			else if (sender == _servantLimitsConfigFile)
			{
				if (SystemsInitialized)
				{
					ServantLimitService.ReloadConfiguredLimits(VWorld.EntityManager);
				}
				ManualLogSource logger5 = Logger;
				if (logger5 != null)
				{
					logger5.LogInfo((object)"[RaidForge] ServantLimits.cfg changed. Servant prefab limits were refreshed.");
				}
			}
			else if (sender == _weaponRaidingConfigFile)
			{
				ManualLogSource logger6 = Logger;
				if (logger6 != null)
				{
					logger6.LogInfo((object)"[RaidForge] WeaponRaiding.cfg changed. New weapon structure damage settings are active.");
				}
			}
			else if (sender == _tntRaidingConfigFile)
			{
				ManualLogSource logger7 = Logger;
				if (logger7 != null)
				{
					logger7.LogInfo((object)"[RaidForge] TntDamageAndRaiding.cfg changed. New TNT damage settings are active.");
				}
			}
		}

		public static void ReloadAllConfigsAndRefreshSystems()
		{
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_013e: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			try
			{
				if (_troubleshootingConfigFile != null)
				{
					_troubleshootingConfigFile.Reload();
				}
				if (_raidScheduleConfigFile != null)
				{
					_raidScheduleConfigFile.Reload();
				}
				if (_golemSettingsConfigFile != null)
				{
					_golemSettingsConfigFile.Reload();
				}
				if (_offlineProtectionConfigFile != null)
				{
					_offlineProtectionConfigFile.Reload();
				}
				if (_raidInterferenceConfigFile != null)
				{
					_raidInterferenceConfigFile.Reload();
				}
				if (_optInRaidingConfigFile != null)
				{
					_optInRaidingConfigFile.Reload();
				}
				if (_optInScheduleConfigFile != null)
				{
					_optInScheduleConfigFile.Reload();
				}
				if (_weaponRaidingConfigFile != null)
				{
					_weaponRaidingConfigFile.Reload();
				}
				if (_tntRaidingConfigFile != null)
				{
					_tntRaidingConfigFile.Reload();
				}
				if (_shardConfigFile != null)
				{
					_shardConfigFile.Reload();
				}
				if (_mapIconsConfigFile != null)
				{
					_mapIconsConfigFile.Reload();
				}
				if (_purchasedOrpConfigFile != null)
				{
					_purchasedOrpConfigFile.Reload();
				}
				if (_servantLimitsConfigFile != null)
				{
					_servantLimitsConfigFile.Reload();
				}
				RaidConfig.ParseSchedule();
				PurchasedOrpService.ProcessDueRaidDayConsumption(force: true);
				GolemAutomationConfig.ReloadAndParseAll();
				if (SystemsInitialized)
				{
					OfflineGraceService.ReloadOfflineStatesFromDisk(VWorld.EntityManager);
					ShardVulnerabilityService.ReloadStateFromDisk();
					OptInRaidService.ReloadStateFromDisk();
					PurchasedOrpService.ReloadStateFromDisk();
					ServantLimitService.ReloadConfiguredLimits(VWorld.EntityManager);
					EntityManager entityManager = VWorld.EntityManager;
					int num = OwnershipCacheService.InitializeHeartOwnershipCache(entityManager);
					int num2 = OwnershipCacheService.InitializeUserToClanCache(entityManager);
					ManualLogSource logger = Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Reload] Cache refreshed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Hearts, ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Users.");
					}
					logger.LogInfo(val);
					PlayerRegistryService.RefreshFromWorld(entityManager);
					RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true);
					GolemAutomationSystem.ResetAutomationState();
					GolemAutomationSystem.CheckAutomation();
					RaidMapIconService.MarkPersistentStateIconsDirty();
					RaidMapIconService.ClearAllRaidForgeIconEntities(entityManager);
					RaidMapIconService.ProcessCleanup();
					RaidInterferenceService.ResetRuntimeState();
					RaidInterferenceService.Initialize();
				}
				ManualLogSource logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"[RaidForge] All config files were reloaded.");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger3 = Logger;
				if (logger3 != null)
				{
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[RaidForge] Error reloading configs: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					logger3.LogError(val2);
				}
			}
		}

		public static void TriggerReloadFromCommand()
		{
			ReloadAllConfigsAndRefreshSystems();
		}

		private static void ResetRuntimeStateForFreshLoad()
		{
			ServerWorldReadyPatch.ResetRuntimeState();
			DamageInterceptorPatch.ResetRuntimeState();
			OfflineGraceService.ResetRuntimeState();
			OptInRaidService.ResetRuntimeState();
			PurchasedOrpService.ResetRuntimeState();
			ShardVulnerabilityService.ResetRuntimeState();
			RaidInterferenceService.ResetRuntimeState();
			RaidMapIconService.ResetRuntimeState();
			PlayerRegistryService.ResetRuntimeState();
			ServantLimitService.ResetRuntimeState();
			OwnershipCacheService.ClearAllCaches();
			RaidSchedulingSystem.ResetRuntimeState();
			GolemAutomationSystem.ResetRuntimeState();
		}

		public static void TriggerGolemAutomationResetFromCommand()
		{
			if (SystemsInitialized)
			{
				GolemAutomationSystem.ResetAutomationState();
			}
		}

		private void LoadConfigs()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "RaidForge");
			Directory.CreateDirectory(text);
			string text2 = Path.Combine(text, "TntDamageAndRaiding.cfg");
			bool tntConfigExistedBeforeLoad = File.Exists(text2);
			_troubleshootingConfigFile = new ConfigFile(Path.Combine(text, "Troubleshooting.cfg"), true);
			_raidScheduleConfigFile = new ConfigFile(Path.Combine(text, "RaidScheduleAndGeneral.cfg"), true);
			_golemSettingsConfigFile = new ConfigFile(Path.Combine(text, "GolemSettings.cfg"), true);
			_offlineProtectionConfigFile = new ConfigFile(Path.Combine(text, "OfflineProtection.cfg"), true);
			_raidInterferenceConfigFile = new ConfigFile(Path.Combine(text, "RaidInterference.cfg"), true);
			_optInRaidingConfigFile = new ConfigFile(Path.Combine(text, "OptInRaiding.cfg"), true);
			_optInScheduleConfigFile = new ConfigFile(Path.Combine(text, "OptInSchedule.cfg"), true);
			_weaponRaidingConfigFile = new ConfigFile(Path.Combine(text, "WeaponRaiding.cfg"), true);
			_tntRaidingConfigFile = new ConfigFile(text2, true);
			_commandSettingsConfigFile = new ConfigFile(Path.Combine(text, "CommandSettings.cfg"), true);
			_shardConfigFile = new ConfigFile(Path.Combine(text, "SoulShards.cfg"), true);
			_mapIconsConfigFile = new ConfigFile(Path.Combine(text, "MapIcons.cfg"), true);
			_purchasedOrpConfigFile = new ConfigFile(Path.Combine(text, "PurchasedORP.cfg"), true);
			_servantLimitsConfigFile = new ConfigFile(Path.Combine(text, "ServantLimits.cfg"), true);
			TroubleshootingConfig.Initialize(_troubleshootingConfigFile);
			RaidConfig.Initialize(_raidScheduleConfigFile, Logger);
			GolemAutomationConfig.Initialize(_golemSettingsConfigFile, Logger);
			OfflineRaidProtectionConfig.Initialize(_offlineProtectionConfigFile);
			RaidInterferenceConfig.Initialize(_raidInterferenceConfigFile);
			OptInRaidingConfig.Initialize(_optInRaidingConfigFile);
			OptInScheduleConfig.Initialize(_optInScheduleConfigFile);
			WeaponRaidingConfig.Initialize(_weaponRaidingConfigFile, Logger);
			TntRaidingConfig.Initialize(_tntRaidingConfigFile, Logger);
			TntRaidingConfig.MigrateLegacySettingsIfNeeded(_weaponRaidingConfigFile, tntConfigExistedBeforeLoad, Logger);
			CommandSettingsConfig.Initialize(_commandSettingsConfigFile, Logger);
			ShardConfig.Initialize(_shardConfigFile);
			MapIconsConfig.Initialize(_mapIconsConfigFile);
			PurchasedOrpConfig.Initialize(_purchasedOrpConfigFile);
			ServantLimitsConfig.Initialize(_servantLimitsConfigFile);
			RaidConfig.ParseSchedule();
			GolemAutomationConfig.ReloadAndParseAll();
			_troubleshootingConfigFile.SettingChanged += OnConfigSettingChanged;
			_raidScheduleConfigFile.SettingChanged += OnConfigSettingChanged;
			_golemSettingsConfigFile.SettingChanged += OnConfigSettingChanged;
			_offlineProtectionConfigFile.SettingChanged += OnConfigSettingChanged;
			_raidInterferenceConfigFile.SettingChanged += OnConfigSettingChanged;
			_optInRaidingConfigFile.SettingChanged += OnConfigSettingChanged;
			_optInScheduleConfigFile.SettingChanged += OnConfigSettingChanged;
			_weaponRaidingConfigFile.SettingChanged += OnConfigSettingChanged;
			_tntRaidingConfigFile.SettingChanged += OnConfigSettingChanged;
			_shardConfigFile.SettingChanged += OnConfigSettingChanged;
			_mapIconsConfigFile.SettingChanged += OnConfigSettingChanged;
			_purchasedOrpConfigFile.SettingChanged += OnConfigSettingChanged;
			_servantLimitsConfigFile.SettingChanged += OnConfigSettingChanged;
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)"[RaidForge] Config files loaded, including CommandSettings.cfg and separate weapon/TNT raiding files.");
			}
		}

		public override bool Unload()
		{
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (_troubleshootingConfigFile != null)
				{
					_troubleshootingConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_raidScheduleConfigFile != null)
				{
					_raidScheduleConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_golemSettingsConfigFile != null)
				{
					_golemSettingsConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_offlineProtectionConfigFile != null)
				{
					_offlineProtectionConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_raidInterferenceConfigFile != null)
				{
					_raidInterferenceConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_optInRaidingConfigFile != null)
				{
					_optInRaidingConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_optInScheduleConfigFile != null)
				{
					_optInScheduleConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_weaponRaidingConfigFile != null)
				{
					_weaponRaidingConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_tntRaidingConfigFile != null)
				{
					_tntRaidingConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_shardConfigFile != null)
				{
					_shardConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_mapIconsConfigFile != null)
				{
					_mapIconsConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_purchasedOrpConfigFile != null)
				{
					_purchasedOrpConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				if (_servantLimitsConfigFile != null)
				{
					_servantLimitsConfigFile.SettingChanged -= OnConfigSettingChanged;
				}
				RaidForgeScheduler.Dispose();
				HookDOTS hookDOTS = _hookDOTS;
				if (hookDOTS != null)
				{
					hookDOTS.Dispose();
				}
				try
				{
					CommandRegistry.UnregisterAssembly();
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Logger;
					if (logger != null)
					{
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] Failed to unregister commands: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						logger.LogError(val);
					}
				}
				RaidInterferenceService.StopService();
				SharedFileIO.FlushPendingWrites();
				RaidMapIconService.ResetRuntimeState();
				DamageInterceptorPatch.ResetRuntimeState();
				ServerWorldReadyPatch.ResetRuntimeState();
				OfflineGraceService.ResetRuntimeState();
				OptInRaidService.ResetRuntimeState();
				PurchasedOrpService.ResetRuntimeState();
				ShardVulnerabilityService.ResetRuntimeState();
				RaidSchedulingSystem.ResetRuntimeState();
				GolemAutomationSystem.ResetRuntimeState();
				OwnershipCacheService.ClearAllCaches();
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				SystemsInitialized = false;
				ServerHasJustBooted = true;
				_onBootShardScanHasRun = false;
				ManualLogSource logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"[RaidForge] Unloaded.");
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] Error during unload: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex2);
					}
					logger.LogError(val);
				}
				return false;
			}
			return true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RaidForge";

		public const string PLUGIN_NAME = "RaidForge";

		public const string PLUGIN_VERSION = "3.2.2";
	}
}
namespace RaidForge.Utils
{
	public static class ChatColors
	{
		public const string Error = "#FF4136";

		public const string Success = "#2ECC40";

		public const string Info = "#FFFFFF";

		public const string Warning = "#F00534";

		public const string Highlight = "#7FDBFF";

		public const string Accent = "#FFDC00";

		public const string Muted = "#AAAAAA";

		public static string Format(string message, string colorHex)
		{
			if (string.IsNullOrEmpty(colorHex))
			{
				return message;
			}
			return $"<color={colorHex}>{message}</color>";
		}

		public static string ErrorText(string message)
		{
			return Format(message, "#FF4136");
		}

		public static string SuccessText(string message)
		{
			return Format(message, "#2ECC40");
		}

		public static string InfoText(string message)
		{
			return Format(message, "#FFFFFF");
		}

		public static string WarningText(string message)
		{
			return Format(message, "#F00534");
		}

		public static string HighlightText(string message)
		{
			return Format(message, "#7FDBFF");
		}

		public static string AccentText(string message)
		{
			return Format(message, "#FFDC00");
		}

		public static string MutedText(string message)
		{
			return Format(message, "#AAAAAA");
		}
	}
	internal static class DelimitedText
	{
		public static string Escape(string value, char delimiter)
		{
			if (string.IsNullOrEmpty(value))
			{
				return string.Empty;
			}
			if (value.IndexOf(delimiter) < 0 && value.IndexOf('"') < 0 && value.IndexOf('\r') < 0 && value.IndexOf('\n') < 0)
			{
				return value;
			}
			return "\"" + value.Replace("\"", "\"\"") + "\"";
		}

		public static string[] ParseLine(string line, char delimiter)
		{
			List<string> list = new List<string>();
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = false;
			for (int i = 0; i < line.Length; i++)
			{
				char c = line[i];
				if (c == '"')
				{
					if (flag && i + 1 < line.Length && line[i + 1] == '"')
					{
						stringBuilder.Append('"');
						i++;
					}
					else
					{
						flag = !flag;
					}
				}
				else if (c == delimiter && !flag)
				{
					list.Add(stringBuilder.ToString());
					stringBuilder.Clear();
				}
				else
				{
					stringBuilder.Append(c);
				}
			}
			list.Add(stringBuilder.ToString());
			return list.ToArray();
		}
	}
	internal static class EntityExtensions
	{
		private static EntityManager Em => VWorld.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 class LoggingHelper
	{
		private static ManualLogSource _logger;

		private static bool IsVerboseLoggingGloballyEnabled => TroubleshootingConfig.EnableVerboseLogging?.Value ?? false;

		public static void Initialize(ManualLogSource logger)
		{
			_logger = logger;
			if (_logger == null)
			{
				Console.WriteLine("[RaidForge.LoggingHelper] CRITICAL: Logger passed to Initialize is null!");
			}
		}

		public static void Info(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogInfo((object)message);
			}
		}

		public static void Warning(string message, Exception ex = null)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (_logger == null)
			{
				return;
			}
			if (ex != null)
			{
				ManualLogSource logger = _logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(14, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | Exception: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString());
				}
				logger.LogWarning(val);
			}
			else
			{
				_logger.LogWarning((object)message);
			}
		}

		public static void Error(string message, Exception ex = null)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (_logger == null)
			{
				Console.WriteLine("[RaidForge.LoggingHelper ERROR (logger not init)]: " + message + " " + ((ex != null) ? ex.ToString() : ""));
			}
			else if (ex != null)
			{
				ManualLogSource logger = _logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | Exception: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString());
				}
				logger.LogError(val);
			}
			else
			{
				_logger.LogError((object)message);
			}
		}

		public static void Debug(string message)
		{
			if (IsVerboseLoggingGloballyEnabled && _logger != null)
			{
				_logger.LogDebug((object)message);
			}
		}
	}
	public readonly struct OwnerIdentity
	{
		public readonly Entity UserEntity;

		public readonly Entity ClanEntity;

		public readonly User UserData;

		public readonly string PersistentKey;

		public readonly string UserKey;

		public readonly string ContextualName;

		public readonly string CharacterName;

		public readonly string ClanName;

		public readonly ulong PlatformId;

		public readonly bool IsClan;

		public OwnerIdentity(Entity userEntity, Entity clanEntity, User userData, string persistentKey, string userKey, string contextualName, string characterName, string clanName, ulong platformId, bool isClan)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_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)
			UserEntity = userEntity;
			ClanEntity = clanEntity;
			UserData = userData;
			PersistentKey = persistentKey;
			UserKey = userKey;
			ContextualName = contextualName;
			CharacterName = characterName;
			ClanName = clanName;
			PlatformId = platformId;
			IsClan = isClan;
		}

		public string GetDisplayNameWithOwnerType()
		{
			if (!IsClan)
			{
				return ContextualName;
			}
			return ContextualName + " (Clan)";
		}
	}
	public static class OwnerIdentityHelper
	{
		public static bool TryResolveFromUserEntity(EntityManager em, Entity userEntity, out OwnerIdentity owner, out string error)
		{
			//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_0017: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			owner = default(OwnerIdentity);
			error = string.Empty;
			try
			{
				if (em == default(EntityManager))
				{
					error = "EntityManager is not available.";
					return false;
				}
				if (userEntity == Entity.Null || !((EntityManager)(ref em)).Exists(userEntity))
				{
					error = "User entity does not exist.";
					return false;
				}
				if (!((EntityManager)(ref em)).HasComponent<User>(userEntity))
				{
					error = "Entity does not have a User component.";
					return false;
				}
				User componentData = ((EntityManager)(ref em)).GetComponentData<User>(userEntity);
				return TryResolveFromUserData(em, userEntity, componentData, null, out owner, out error);
			}
			catch (Exception ex)
			{
				error = "Failed to resolve owner identity from user entity: " + ex.Message;
				return false;
			}
		}

		public unsafe static bool TryResolveFromUserData(EntityManager em, Entity userEntity, User userData, string fallbackCharacterName, out OwnerIdentity owner, out string error)
		{
			//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005f: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
			owner = default(OwnerIdentity);
			error = string.Empty;
			try
			{
				string text = ((!string.IsNullOrWhiteSpace(fallbackCharacterName)) ? fallbackCharacterName : SafeFixedStringToString(((object)(*(FixedString64Bytes*)(&userData.CharacterName))/*cast due to .constrained prefix*/).ToString(), "Unknown Player"));
				ulong platformId = userData.PlatformId;
				string userKey = PersistentKeyHelper.GetUserKey(platformId);
				Entity entity = userData.ClanEntity._Entity;
				if (entity != Entity.Null && entity.Exists() && ((EntityManager)(ref em)).Exists(entity) && ((EntityManager)(ref em)).HasComponent<ClanTeam>(entity))
				{
					ClanTeam componentData = ((EntityManager)(ref em)).GetComponentData<ClanTeam>(entity);
					string text2 = SafeFixedStringToString(((object)(*(FixedString64Bytes*)(&componentData.Name))/*cast due to .constrained prefix*/).ToString(), "Unknown Clan");
					string clanKey = PersistentKeyHelper.GetClanKey(em, entity);
					owner = new OwnerIdentity(userEntity, entity, userData, clanKey, userKey, text2, text, text2, platformId, isClan: true);
					return true;
				}
				owner = new OwnerIdentity(userEntity, Entity.Null, userData, userKey, userKey, text, text, string.Empty, platformId, isClan: false);
				return true;
			}
			catch (Exception ex)
			{
				error = "Failed to resolve owner identity from user data: " + ex.Message;
				return false;
			}
		}

		public static bool TryResolveFromPlayerName(EntityManager em, string playerName, out OwnerIdentity owner, out string error)
		{
			//IL_0021: 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_0047: 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)
			owner = default(OwnerIdentity);
			error = string.Empty;
			try
			{
				if (string.IsNullOrWhiteSpace(playerName))
				{
					error = "Player name cannot be empty.";
					return false;
				}
				if (!UserHelper.FindUserEntity(em, playerName, out var userEntity, out var userData, out var characterName))
				{
					error = "Player '" + playerName + "' not found.";
					return false;
				}
				return TryResolveFromUserData(em, userEntity, userData, characterName, out owner, out error);
			}
			catch (Exception ex)
			{
				error = "Failed to resolve owner identity for player '" + playerName + "': " + ex.Message;
				return false;
			}
		}

		public static bool TryResolveFromCommandSender(EntityManager em, Entity senderUserEntity, out OwnerIdentity owner, out string error)
		{
			//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 TryResolveFromUserEntity(em, senderUserEntity, out owner, out error);
		}

		private static string SafeFixedStringToString(string value, string fallback)
		{
			if (string.IsNullOrWhiteSpace(value))
			{
				return fallback;
			}
			return value.Trim();
		}
	}
	public static class OwnerIdentityQueries
	{
		public static List<OwnerIdentity> GetUniqueOwners(EntityManager em, string logContext)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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_0038: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_004f: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, OwnerIdentity> dictionary = new Dictionary<string, OwnerIdentity>();
			EntityQuery val = default(EntityQuery);
			NativeArray<Entity> val2 = default(NativeArray<Entity>);
			try
			{
				val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
				val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (((EntityManager)(ref em)).Exists(current) && OwnerIdentityHelper.TryResolveFromUserEntity(em, current, out var owner, out var _) && !string.IsNullOrWhiteSpace(owner.PersistentKey) && !dictionary.ContainsKey(owner.PersistentKey))
					{
						dictionary[owner.PersistentKey] = owner;
					}
				}
			}
			catch (Exception ex)
			{
				LoggingHelper.Error("[" + logContext + "] Error building unique owner list.", ex);
			}
			finally
			{
				if (val2.IsCreated)
				{
					val2.Dispose();
				}
				if (val != default(EntityQuery))
				{
					((EntityQuery)(ref val)).Dispose();
				}
			}
			return new List<OwnerIdentity>(dictionary.Values);
		}
	}
	public static class PrefabGuidResolver
	{
		private delegate bool TryResolveDelegate(string prefabNameOrHash, out PrefabGUID prefabGuid, out string resolvedName);

		public static bool TryResolve(string prefabNameOrHash, out PrefabGUID prefabGuid)
		{
			string resolvedName;
			return TryResolve(prefabNameOrHash, out prefabGuid, out resolvedName);
		}

		public static bool TryResolve(string prefabNameOrHash, out PrefabGUID prefabGuid, out string resolvedName)
		{
			//IL_0001: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			prefabGuid = default(PrefabGUID);
			resolvedName = null;
			if (string.IsNullOrWhiteSpace(prefabNameOrHash))
			{
				return false;
			}
			string text = prefabNameOrHash.Trim();
			if (int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				prefabGuid = new PrefabGUID(result);
				if (!TryGetPrefabName(prefabGuid, out resolvedName))
				{
					prefabGuid = default(PrefabGUID);
					return false;
				}
				return true;
			}
			if (!TryGetPrefabGuidByName(text, out prefabGuid))
			{
				return false;
			}
			resolvedName = (TryGetPrefabName(prefabGuid, out var prefabName) ? prefabName : text);
			return true;
		}

		public static bool TryResolveMapIcon(string prefabNameOrHash, out PrefabGUID prefabGuid)
		{
			string resolvedName;
			return TryResolveMapIcon(prefabNameOrHash, out prefabGuid, out resolvedName);
		}

		public static bool TryResolveMapIcon(string prefabNameOrHash, out PrefabGUID prefabGuid, out string resolvedName)
		{
			//IL_0001: 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)
			prefabGuid = default(PrefabGUID);
			resolvedName = null;
			if (MapIconPrefabCatalog.TryResolve(prefabNameOrHash, out prefabGuid, out resolvedName))
			{
				return true;
			}
			if (!TryResolve(prefabNameOrHash, out prefabGuid, out resolvedName) || string.IsNullOrWhiteSpace(resolvedName) || !resolvedName.StartsWith("MapIcon_", StringComparison.OrdinalIgnoreCase) || ((PrefabGUID)(ref prefabGuid)).GuidHash == MapIconPrefabCatalog.MapIconProxyPrefab.GuidHash)
			{
				prefabGuid = default(PrefabGUID);
				resolvedName = null;
				return false;
			}
			return true;
		}

		public static PrefabGUID ResolveMapIconOrDefault(string prefabNameOrHash, PrefabRef fallbackPrefab, string context)
		{
			//IL_000a: 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)
			return ResolveOrDefault(prefabNameOrHash, fallbackPrefab.Name, fallbackPrefab.Guid, context, TryResolveMapIcon);
		}

		public static bool TryGetPrefabGuidByName(string prefabName, out PrefabGUID prefabGuid)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			prefabGuid = default(PrefabGUID);
			if (string.IsNullOrWhiteSpace(prefabName))
			{
				return false;
			}
			string text = prefabName.Trim();
			if (TryGetPrefabLookup(out var prefabLookup) && ((PrefabLookupMap)(ref prefabLookup)).TryGetPrefabGuidWithName(text, ref prefabGuid, true))
			{
				return true;
			}
			if (TryGetKnownPrefabByName(text, out var prefab))
			{
				prefabGuid = prefab.Guid;
				return true;
			}
			return false;
		}

		public static bool TryGetPrefabName(PrefabGUID prefabGuid, out string prefabName)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			prefabName = null;
			if (TryGetPrefabLookup(out var prefabLookup) && ((PrefabLookupMap)(ref prefabLookup)).TryGetName(prefabGuid, ref prefabName) && !string.IsNullOrWhiteSpace(prefabName))
			{
				return true;
			}
			if (TryGetKnownPrefabByHash(((PrefabGUID)(ref prefabGuid)).GuidHash, out var prefab))
			{
				prefabName = prefab.Name;
				return true;
			}
			return false;
		}

		public static int ValidateKnownPrefabs()
		{
			try
			{
				return ValidateKnownPrefabsCore();
			}
			catch (Exception ex)
			{
				LoggingHelper.Warning("[PrefabCatalog] Runtime name/hash validation failed unexpectedly.", ex);
				return -1;
			}
		}

		private static int ValidateKnownPrefabsCore()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPrefabLookup(out var prefabLookup))
			{
				LoggingHelper.Warning("[PrefabCatalog] V Rising PrefabLookupMap is unavailable; runtime name/hash validation was skipped.");
				return -1;
			}
			HashSet<int> seenHashes = new HashSet<int>();
			int validated = 0;
			int mismatches = 0;
			foreach (PrefabRef item in PrefabData.All)
			{
				ValidateKnownPrefab(prefabLookup, item, seenHashes, ref validated, ref mismatches);
			}
			foreach (PrefabRef knownPrefab in MapIconPrefabCatalog.KnownPrefabs)
			{
				ValidateKnownPrefab(prefabLookup, knownPrefab, seenHashes, ref validated, ref mismatches);
			}
			if (mismatches == 0)
			{
				LoggingHelper.Info($"[PrefabCatalog] Validated {validated} unique prefab name/hash pair(s) against V Rising.");
			}
			else
			{
				LoggingHelper.Error($"[PrefabCatalog] Found {mismatches} invalid prefab definition(s) while validating {validated} unique pair(s).");
			}
			return mismatches;
		}

		private static PrefabGUID ResolveOrDefault(string prefabNameOrHash, string defaultPrefabName, PrefabGUID fallbackPrefabGuid, string context, TryResolveDelegate tryResolve)
		{
			//IL_000e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			if (tryResolve(prefabNameOrHash, out var prefabGuid, out var resolvedName))
			{
				return prefabGuid;
			}
			if (tryResolve(defaultPrefabName, out prefabGuid, out resolvedName))
			{
				LogInvalidConfig(prefabNameOrHash, defaultPrefabName, context);
				return prefabGuid;
			}
			LogInvalidConfig(prefabNameOrHash, $"{defaultPrefabName} ({((PrefabGUID)(ref fallbackPrefabGuid)).GuidHash})", context);
			return fallbackPrefabGuid;
		}

		private static void ValidateKnownPrefab(PrefabLookupMap prefabLookup, PrefabRef prefab, HashSet<int> seenHashes, ref int validated, ref int mismatches)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (seenHashes.Add(prefab.GuidHash))
			{
				validated++;
				string text = default(string);
				bool num = ((PrefabLookupMap)(ref prefabLookup)).TryGetName(prefab.Guid, ref text) && string.Equals(text, prefab.Name, StringComparison.Ordinal);
				PrefabGUID val = default(PrefabGUID);
				bool flag = ((PrefabLookupMap)(ref prefabLookup)).TryGetPrefabGuidWithName(prefab.Name, ref val, false) && ((PrefabGUID)(ref val)).GuidHash == prefab.GuidHash;
				if (!(num && flag))
				{
					mismatches++;
					LoggingHelper.Error($"[PrefabCatalog] Invalid definition {prefab}. Hash resolved to '{text ?? "<missing>"}'; name resolved to {((PrefabGUID)(ref val)).GuidHash}.");
				}
			}
		}

		private static bool TryGetPrefabLookup(out PrefabLookupMap prefabLookup)
		{
			//IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			prefabLookup = default(PrefabLookupMap);
			if (!TryGetPrefabCollectionSystem(out var prefabCollection))
			{
				return false;
			}
			prefabLookup = prefabCollection._PrefabLookupMap;
			return ((PrefabLookupMap)(ref prefabLookup)).IsCreated;
		}

		private static bool TryGetPrefabCollectionSystem(out PrefabCollectionSystem prefabCollection)
		{
			prefabCollection = null;
			if (VWorld.Server == null || !VWorld.Server.IsCreated)
			{
				return false;
			}
			prefabCollection = VWorld.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			return prefabCollection != null;
		}

		private static bool TryGetKnownPrefabByName(string name, out PrefabRef prefab)
		{
			if (PrefabData.TryGetByName(name, out prefab))
			{
				return true;
			}
			foreach (PrefabRef knownPrefab in MapIconPrefabCatalog.KnownPrefabs)
			{
				if (string.Equals(knownPrefab.Name, name, StringComparison.OrdinalIgnoreCase))
				{
					prefab = knownPrefab;
					return true;
				}
			}
			prefab = default(PrefabRef);
			return false;
		}

		private static bool TryGetKnownPrefabByHash(int guidHash, out PrefabRef prefab)
		{
			if (!PrefabData.TryGetByHash(guidHash, out prefab))
			{
				return MapIconPrefabCatalog.TryGetByHash(guidHash, out prefab);
			}
			return true;
		}

		private static void LogInvalidConfig(string configuredValue, string fallbackValue, string context)
		{
			ConfigEntry<bool> enableVerboseLogging = TroubleshootingConfig.EnableVerboseLogging;
			if (enableVerboseLogging != null && enableVerboseLogging.Value)
			{
				string value = (string.IsNullOrWhiteSpace(configuredValue) ? "<empty>" : configuredValue.Trim());
				LoggingHelper.Warning($"[PrefabGuidResolver] Could not resolve '{value}' for {context}. Using {fallbackValue}.");
			}
		}
	}
	public static class ShapeshiftHelper
	{
		public static bool IsInBearForm(EntityManager em, Entity characterEntity)
		{
			//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_0007: 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_0018: 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_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)
			if (!BuffUtility.HasBuff<EntityManager>(em, characterEntity, PrefabIdentifier.op_Implicit(PrefabData.BearBuff.Guid)))
			{
				return BuffUtility.HasBuff<EntityManager>(em, characterEntity, PrefabIdentifier.op_Implicit(PrefabData.BearSkinBuff.Guid));
			}
			return true;
		}
	}
	public static class SharedFileIO
	{
		private const int DefaultAttempts = 5;

		private const int DefaultDelayMilliseconds = 75;

		private static readonly object PendingWritesLock = new object();

		private static readonly Dictionary<string, string> PendingWritesByPath = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private static Thread _writerThread;

		private static bool _isWriting;

		public static string[] ReadAllLinesShared(string path)
		{
			if (!File.Exists(path))
			{
				return Array.Empty<string>();
			}
			Exception ex = null;
			for (int i = 1; i <= 5; i++)
			{
				try
				{
					using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
					using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true);
					List<string> list = new List<string>();
					while (!streamReader.EndOfStream)
					{
						list.Add(streamReader.ReadLine());
					}
					return list.ToArray();
				}
				catch (IOException ex2)
				{
					ex = ex2;
					Thread.Sleep(75 * i);
				}
			}
			throw ex ?? new IOException("Failed to read '" + path + "'.");
		}

		public static void WriteAllTextWithRetry(string path, string content)
		{
			string directoryName = Path.GetDirectoryName(path);
			if (!string.IsNullOrEmpty(directoryName))
			{
				Directory.CreateDirectory(directoryName);
			}
			Exception ex = null;
			for (int i = 1; i <= 5; i++)
			{
				try
				{
					using FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
					using StreamWriter streamWriter = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
					streamWriter.Write(content);
					return;
				}
				catch (IOException ex2)
				{
					ex = ex2;
					Thread.Sleep(75 * i);
				}
			}
			throw ex ?? new IOException("Failed to write '" + path + "'.");
		}

		public static void QueueWriteAllTextWithRetry(string path, string content)
		{
			if (string.IsNullOrWhiteSpace(path))
			{
				return;
			}
			lock (PendingWritesLock)
			{
				PendingWritesByPath[path] = content ?? string.Empty;
				EnsureWriterThreadStarted();
				Monitor.PulseAll(PendingWritesLock);
			}
		}

		public static void FlushPendingWrites()
		{
			while (true)
			{
				Dictionary<string, string> batch;
				lock (PendingWritesLock)
				{
					while (_isWriting)
					{
						Monitor.Wait(PendingWritesLock, 50);
					}
					if (PendingWritesByPath.Count == 0)
					{
						break;
					}
					batch = TakePendingWritesForCurrentThread();
				}
				WriteBatch(batch);
			}
		}

		private static void EnsureWriterThreadStarted()
		{
			if (_writerThread == null || !_writerThread.IsAlive)
			{
				_writerThread = new Thread(BackgroundWriterLoop)
				{
					IsBackground = true,
					Name = "RaidForge CSV Writer"
				};
				_writerThread.Start();
			}
		}

		private static void BackgroundWriterLoop()
		{
			while (true)
			{
				Dictionary<string, string> batch;
				lock (PendingWritesLock)
				{
					while (PendingWritesByPath.Count == 0 || _isWriting)
					{
						Monitor.Wait(PendingWritesLock);
					}
					batch = TakePendingWritesForCurrentThread();
				}
				WriteBatch(batch);
			}
		}

		private static Dictionary<string, string> TakePendingWritesForCurrentThread()
		{
			Dictionary<string, string> result = new Dictionary<string, string>(PendingWritesByPath, StringComparer.OrdinalIgnoreCase);
			PendingWritesByPath.Clear();
			_isWriting = true;
			return result;
		}

		private static void WriteBatch(Dictionary<string, string> batch)
		{
			try
			{
				foreach (KeyValuePair<string, string> item in batch)
				{
					try
					{
						WriteAllTextWithRetry(item.Key, item.Value);
					}
					catch (Exception ex)
					{
						LoggingHelper.Error("[SharedFileIO] CSV write failed for '" + item.Key + "'.", ex);
					}
				}
			}
			finally
			{
				lock (PendingWritesLock)
				{
					_isWriting = false;
					Monitor.PulseAll(PendingWritesLock);
				}
			}
		}
	}
	public static class UserHelper
	{
		private const int MaxSourceOwnerDepth = 6;

		public static bool TryGetShardPrefabsForUserOrClan(EntityManager em, Entity userEntity, out HashSet<PrefabGUID> foundShards, out string reason)
		{
			//IL_000f: 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_002c: 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_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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			foundShards = new HashSet<PrefabGUID>();
			List<string> list = new List<string>();
			User val = default(User);
			if (!((EntityManager)(ref em)).Exists(userEntity) || !((EntityManager)(ref em)).TryGetComponentData<User>(userEntity, ref val))
			{
				reason = "Invalid User Entity";
				return false;
			}
			Entity entity = val.LocalCharacter._Entity;
			if (entity.Exists() && TryGetSoulShardsOnPerson(em, entity, out var foundShards2, out var locationSummary))
			{
				foreach (PrefabGUID item in foundShards2)
				{
					foundShards.Add(item);
				}
				list.Add("shard(s) found in " + locationSummary);
			}
			if (TryGetSoulShardsInOwnedPedestals(em, userEntity, out var foundShards3, out var reason2))
			{
				foreach (PrefabGUID item2 in foundShards3)
				{
					foundShards.Add(item2);
				}
				list.Add(reason2);
			}
			if (foundShards.Count > 0)
			{
				reason = string.Join(" | ", list);
				return true;
			}
			reason = "No shards found.";
			return false;
		}

		public static bool TryGetSoulShardsOnPerson(EntityManager em, Entity characterEntity, out HashSet<PrefabGUID> foundShards, out string locationSummary)
		{
			//IL_000d: 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_001c: 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_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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_007f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			foundShards = new HashSet<PrefabGUID>();
			List<string> list = new List<string>();
			if (characterEntity == Entity.Null || !((EntityManager)(ref em)).Exists(characterEntity))
			{
				locationSummary = "none";
				return false;
			}
			NativeList<Entity> val = default(NativeList<Entity>);
			val..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				if (InventoryUtilities.TryGetInventoryEntities<EntityManager>(em, characterEntity, ref val))
				{
					PrefabGUID item = default(PrefabGUID);
					for (int i = 0; i < val.Length; i++)
					{
						Entity val2 = val[i];
						if (!((EntityManager)(ref em)).Exists(val2) || !((EntityManager)(ref em)).HasBuffer<InventoryBuffer>(val2))
						{
							continue;
						}
						Enumerator<InventoryBuffer> enumerator = ((EntityManager)(ref em)).GetBuffer<InventoryBuffer>(val2, false).GetEnumerator();
						while (enumerator.MoveNext())
						{
							InventoryBuffer current = enumerator.Current;
							if (PrefabData.SoulShardPrefabGUIDs.Contains(current.ItemType))
							{
								foundShards.Add(current.ItemType);
								if (!list.Contains("inventory"))
								{
									list.Add("inventory");
								}
							}
							else if (((EntityManager)(ref em)).Exists(current.ItemEntity._Entity) && ((EntityManager)(ref em)).TryGetComponentData<PrefabGUID>(current.ItemEntity._Entity, ref item) && PrefabData.SoulShardPrefabGUIDs.Contains(item))
							{
								foundShards.Add(item);
								if (!list.Contains("inventory"))
								{
									list.Add("inventory");
								}
							}
						}
					}
				}
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
			Equipment val3 = default(Equipment);
			if (((EntityManager)(ref em)).TryGetComponentData<Equipment>(characterEntity, ref val3))
			{
				Entity entity = val3.GrimoireSlot.SlotEntity._Entity;
				PrefabGUID item2 = default(PrefabGUID);
				if (entity.Exists() && ((EntityManager)(ref em)).TryGetComponentData<PrefabGUID>(entity, ref item2) && PrefabData.SoulShardPrefabGUIDs.Contains(item2))
				{
					foundShards.Add(item2);
					if (!list.Contains("equipped Grimoire"))
					{
						list.Add("equipped Grimoire");
					}
				}
			}
			locationSummary = ((list.Count > 0) ? string.Join(" and ", list) : "none");
			return foundShards.Count > 0;
		}

		public static bool TryGetSoulShardsInOwnedPedestals(EntityManager em, Entity userEntity, out HashSet<PrefabGUID> foundShards, out string reason)
		{
			//IL_0010: 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_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_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_0053: 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_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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_00a0: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			foundShards = new HashSet<PrefabGUID>();
			reason = string.Empty;
			User val = default(User);
			if (!((EntityManager)(ref em)).Exists(userEntity) || !((EntityManager)(ref em)).TryGetComponentData<User>(userEntity, ref val))
			{
				return false;
			}
			Entity entity = val.ClanEntity._Entity;
			HashSet<Entity> hashSet = new HashSet<Entity>();
			foreach (KeyValuePair<Entity, Entity> item in OwnershipCacheService.GetHeartToOwnerCacheView())
			{
				if (((EntityManager)(ref em)).Exists(item.Key) && ((EntityManager)(ref em)).Exists(item.Value))
				{
					bool flag = false;
					if (item.Value == userEntity)
					{
						flag = true;
					}
					if (!flag && entity.Exists() && OwnershipCacheService.TryGetUserClan(item.Value, out var clanEntity) && clanEntity == entity)
					{
						flag = true;
					}
					if (flag)
					{
						hashSet.Add(item.Key);
					}
				}
			}
			if (!hashSet.Any())
			{
				return false;
			}
			HashSet<PrefabGUID> soulShardPedestalPrefabGUIDs = PrefabData.SoulShardPedestalPrefabGUIDs;
			EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<CastleHeartConnection>(),
				ComponentType.ReadOnly<PrefabGUID>()
			});
			NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator2 = val3.GetEnumerator();
				DynamicBuffer<AttachedBuffer> val4 = default(DynamicBuffer<AttachedBuffer>);
				PrefabGUID val5 = default(PrefabGUID);
				DynamicBuffer<InventoryBuffer> val6 = default(DynamicBuffer<InventoryBuffer>);
				while (enumerator2.MoveNext())
				{
					Entity current2 = enumerator2.Current;
					if (!hashSet.Contains(((EntityManager)(ref em)).GetComponentData<CastleHeartConnection>(current2).CastleHeartEntity._Entity) || !soulShardPedestalPrefabGUIDs.Contains(((EntityManager)(ref em)).GetComponentData<PrefabGUID>(current2)) || !((EntityManager)(ref em)).TryGetBuffer<AttachedBuffer>(current2, ref val4))
					{
						continue;
					}
					Enumerator<AttachedBuffer> enumerator3 = val4.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						Entity entity2 = enumerator3.Current.Entity;
						if (!entity2.Exists() || !((EntityManager)(ref em)).TryGetComponentData<PrefabGUID>(entity2, ref val5) || !(val5 == PrefabData.ExternalInventoryPrefab.Guid) || !((EntityManager)(ref em)).TryGetBuffer<InventoryBuffer>(entity2, ref val6))
						{
							continue;
						}
						Enumerator<InventoryBuffer> enumerator4 = val6.GetEnumerator();
						while (enumerator4.MoveNext())
						{
							InventoryBuffer current3 = enumerator4.Current;
							if (PrefabData.SoulShardPrefabGUIDs.Contains(current3.ItemType))
							{
								foundShards.Add(current3.ItemType);
							}
						}
					}
				}
			}
			finally
			{
				if (val3.IsCreated)
				{
					val3.Dispose();
				}
				((EntityQuery)(ref val2)).Dispose();
			}
			if (foundShards.Count > 0)
			{
				reason = $"Found {foundShards.Count} unique shard type(s) inside pedestal inventories.";
				return true;
			}
			return false;
		}

		public unsafe static bool FindUserEntity(EntityManager em, string identifier, out Entity userEntity, out User userData, out string characterName)
		{
			//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_000c: 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_002e: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_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_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_007e: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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)
			userEntity = Entity.Null;
			userData = default(User);
			characterName = string.Empty;
			if (string.IsNullOrWhiteSpace(identifier))
			{
				return false;
			}
			EntityQuery val = default(EntityQuery);
			NativeArray<Entity> val2 = default(NativeArray<Entity>);
			try
			{
				val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
				val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				ulong result;
				bool flag = ulong.TryParse(identifier, out result);
				Enumerator<Entity> enumerator = val2.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!((EntityManager)(ref em)).Exists(current) || !((EntityManager)(ref em)).HasComponent<User>(current))
					{
						continue;
					}
					User componentData = ((EntityManager)(ref em)).GetComponentData<User>(current);
					if (flag)
					{
						if (componentData.PlatformId == result)
						{
							userEntity = current;
							userData = componentData;
							characterName = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString();
							return true;
						}
						continue;
					}
					string text = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString();
					if (text.Equals(identifier, StringComparison.OrdinalIgnoreCase))
					{
						userEntity = current;
						userData = componentData;
						characterName = text;
						return true;
					}
				}
			}
			finally
			{
				if (val2.IsCreated)
				{
					val2.Dispose();
				}
				if (val != default(EntityQuery))
				{
					((EntityQuery)(ref val)).Dispose();
				}
			}
			return false;
		}

		public static bool TryGetPlayerOwnerFromSource(EntityManager em, Entity sourceEntity, out Entity playerCharacterEntity, out Entity userEntity)
		{
			//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 TryGetPlayerOwnerFromSource(em, sourceEntity, 0, out playerCharacterEntity, out userEntity);
		}

		private static bool TryGetPlayerOwnerFromSource(EntityManager em, Entity sourceEntity, int depth, out Entity playerCharacterEntity, out Entity userEntity)
		{
			//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_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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0075: 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_0041: 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_0048: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_0096: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_012a: 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_0107: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			playerCharacterEntity = Entity.Null;
			userEntity = Entity.Null;
			if (depth > 6 || sourceEntity == Entity.Null || !((EntityManager)(ref em)).Exists(sourceEntity))
			{
				return false;
			}
			PlayerCharacter val = default(PlayerCharacter);
			if (((EntityManager)(ref em)).TryGetComponentData<PlayerCharacter>(sourceEntity, ref val))
			{
				Entity userEntity2 = val.UserEntity;
				if (userEntity2 != Entity.Null && ((EntityManager)(ref em)).Exists(userEntity2))
				{
					playerCharacterEntity = sourceEntity;
					userEntity = userEntity2;
					return true;
				}
			}
			User val2 = default(User);
			if (((EntityManager)(ref em)).TryGetComponentData<User>(sourceEntity, ref val2))
			{
				userEntity = sourceEntity;
				Entity entity = val2.LocalCharacter._Entity;
				if (entity != Entity.Null && ((EntityManager)(ref em)).Exists(entity) && ((EntityManager)(ref em)).HasComponent<PlayerCharacter>(entity))
				{
					playerCharacterEntity = entity;
				}
				return true;
			}
			int depth2 = depth + 1;
			UserOwner val3 = default(UserOwner);
			if (((EntityManager)(ref em)).TryGetComponentData<UserOwner>(sourceEntity, ref val3))
			{
				Entity entity2 = val3.Owner._Entity;
				if (entity2 != sourceEntity && TryGetPlayerOwnerFromSource(em, entity2, depth2, out playerCharacterEntity, out userEntity))
				{
					return true;
				}
			}
			EntityOwner val4 = default(EntityOwner);
			if (((EntityManager)(ref em)).TryGetComponentData<EntityOwner>(sourceEntity, ref val4))
			{
				Entity owner = val4.Owner;
				if (owner != sourceEntity && TryGetPlayerOwnerFromSource(em, owner, depth2, out playerCharacterEntity, out userEntity))
				{
					return true;
				}
			}
			EntityCreator val5 = default(EntityCreator);
			if (((EntityManager)(ref em)).TryGetComponentData<EntityCreator>(sourceEntity, ref val5))
			{
				Entity entity3 = val5.Creator._Entity;
				if (entity3 != sourceEntity && TryGetPlayerOwnerFromSource(em, entity3, depth2, out playerCharacterEntity, out userEntity))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsAnyClanMemberOnline(EntityManager em, Entity clanEntity, Entity excludingUserEntity = default(Entity))
		{
			//IL_0002: 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_0019: 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_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_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_003c: 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_0040: 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_0059: 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_004f: 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_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)
			if (!((EntityManager)(ref em)).Exists(clanEntity) || !((EntityManager)(ref em)).HasComponent<ClanTeam>(clanEntity))
			{
				return false;
			}
			NativeList<Entity> val = default(NativeList<Entity>);
			val..ctor(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				TeamUtility.GetClanMembers(em, clanEntity, val);
				Enumerator<Entity> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if ((!(excludingUserEntity != default(Entity)) || !(current == excludingUserEntity)) && ((EntityManager)(ref em)).Exists(current) && ((EntityManager)(ref em)).HasComponent<User>(current) && ((EntityManager)(ref em)).GetComponentData<User>(current).IsConnected)
					{
						return true;
					}
				}
			}
			catch (Exception ex)
			{
				LoggingHelper.Error("[UserHelper] Error in IsAnyClanMemberOnline", ex);
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
			return false;
		}
	}
	internal static class VWorld
	{
		private static World _serverWorld;

		private static EntityManager _entityManager;

		public static World Server
		{
			get
			{
				//IL_0040: 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_005d: Unknown result type (might be due to invalid IL or missing references)
				if (_serverWorld != null && _serverWorld.IsCreated)
				{
					return _serverWorld;
				}
				_serverWorld = GetWorld("Server");
				if (_serverWorld == null || !_serverWorld.IsCreated)
				{
					_entityManager = default(EntityManager);
					LoggingHelper.Error("VWorld: Server world is not available or not created. Subsequent calls may fail.");
					return null;
				}
				_entityManager = _serverWorld.EntityManager;
				return _serverWorld;
			}
		}

		public static EntityManager EntityManager
		{
			get
			{
				//IL_0000: 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_000d: 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_005b: 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_004a: 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_0074: 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_0032: Unknown result type (might be due to invalid IL or missing references)
				if ((_entityManager == default(EntityManager) || (_serverWorld != null && _serverWorld.IsC