Decompiled source of OfflineRaidGuard v0.2.0

OfflineRaidGuard.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using Bloody.Core;
using Bloody.Core.API.v1;
using Bloody.Core.GameData.v1;
using Bloody.Core.Models.v1;
using Bloody.Core.Models.v1.Base;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using OfflineRaidGuard.Utils;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Scripting;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SkyTech6")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Only allow raiding when the defenders (user-specific or clan) are online.")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+5.Branch.master.Sha.6587dbb68fbb44cad86acb698264a397c6e82c75")]
[assembly: AssemblyProduct("OfflineRaidGuard")]
[assembly: AssemblyTitle("OfflineRaidGuard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace OfflineRaidGuard
{
	[BepInPlugin("OfflineRaidGuard", "OfflineRaidGuard", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Reloadable]
	public class Plugin : BasePlugin, IRunOnInitialized
	{
		private Harmony harmony;

		public static ConfigEntry<bool> EnableMod;

		public static ConfigEntry<bool> FactorAllies;

		public static ConfigEntry<int> MaxAllyCacheAge;

		public static bool isInitialized;

		public static ManualLogSource Logger;

		private static World _serverWorld;

		public static SystemsCore SystemsCore;

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

		public static bool IsServer => VWorld.IsServer;

		private static World GetWorld(string name)
		{
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return current;
				}
			}
			return null;
		}

		public void InitConfig()
		{
			EnableMod = ((BasePlugin)this).Config.Bind<bool>("Config", "Enable Mod", true, "Enable/disable the mod.");
			FactorAllies = ((BasePlugin)this).Config.Bind<bool>("Config", "Factor in Ally Status", true, "Include the besieged player allies online status before blocking siege.");
			MaxAllyCacheAge = ((BasePlugin)this).Config.Bind<int>("Config", "Max Ally Cache Age", 300, "Max age of the besieged player allies cache in seconds.\nIf the cache age is older than specified, the cache will be renewed.\nDon't set this too short as allies gathering process can slightly impact your server performance.\nThis cache is only for allies gathering, their online/offline status is updated instantly.");
		}

		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			InitConfig();
			Logger = ((BasePlugin)this).Log;
			harmony = new Harmony("OfflineRaidGuard");
			harmony.PatchAll();
			EventsHandlerSystem.OnInitialize += new OnGameDataInitializedEventHandler(GameDataOnInitialize);
			EventsHandlerSystem.OnDestroy += new OnGameDataDestroyedEventHandler(GameDataOnDestroy);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OfflineRaidGuard");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			EventsHandlerSystem.OnInitialize -= new OnGameDataInitializedEventHandler(GameDataOnInitialize);
			EventsHandlerSystem.OnDestroy -= new OnGameDataDestroyedEventHandler(GameDataOnDestroy);
			((BasePlugin)this).Config.Clear();
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		public void OnGameInitialized()
		{
			_ = VWorld.IsServer;
		}

		private static void GameDataOnInitialize(World world)
		{
			SystemsCore = Core.SystemsCore;
			Helper.GetServerGameManager(out Helper.SGM);
			isInitialized = true;
		}

		private static void GameDataOnDestroy()
		{
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OfflineRaidGuard";

		public const string PLUGIN_NAME = "OfflineRaidGuard";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace OfflineRaidGuard.Utils
{
	public static class Cache
	{
		public static Dictionary<Entity, Entity> PlyonOwnerCache = new Dictionary<Entity, Entity>();

		public static Dictionary<Entity, PlayerGroup> AlliesCache = new Dictionary<Entity, PlayerGroup>();
	}
	public static class Helper
	{
		public static ServerGameManager SGM;

		public static bool GetServerGameManager(out ServerGameManager sgm)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			sgm = Plugin.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager;
			return true;
		}

		public static int GetAllies(Entity CharacterEntity, out List<Entity> Group)
		{
			//IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0034: 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_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)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			Group = new List<Entity>();
			EntityManager entityManager = Plugin.Server.EntityManager;
			EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (!((Entity)(ref current)).Equals(CharacterEntity) && ((ServerGameManager)(ref SGM)).IsAllies(CharacterEntity, current))
				{
					Group.Add(current);
				}
			}
			return Group.Count;
		}

		public static PrefabGUID GetPrefabGUID(Entity entity)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Plugin.Server.EntityManager;
			try
			{
				return ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(entity);
			}
			catch
			{
				return new PrefabGUID(0);
			}
		}

		public static string GetPrefabName(PrefabGUID hashCode)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			PrefabCollectionSystem existingSystemManaged = Plugin.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			string result = "Nonexistent";
			if (((PrefabGUID)(ref hashCode)).GuidHash == 0)
			{
				return result;
			}
			try
			{
				Entity val = ((PrefabLookupMap)(ref ((PrefabCollectionSystem_Base)existingSystemManaged).PrefabLookupMap))[hashCode];
				return ((object)(Entity)(ref val)).ToString();
			}
			catch
			{
				return "NoPrefabName";
			}
		}
	}
	public struct PlayerGroup
	{
		public int AllyCount { get; set; }

		public List<Entity> Allies { get; set; }

		public DateTime TimeStamp { get; set; }

		public PlayerGroup(int allyCount = 0, List<Entity> allies = null, DateTime timeStamp = default(DateTime))
		{
			AllyCount = allyCount;
			Allies = allies;
			TimeStamp = timeStamp;
		}
	}
}
namespace OfflineRaidGuard.Models
{
	public class Player
	{
		public ulong PlatformId { get; set; }

		public string? CharacterName { get; set; }

		public bool IsConnected { get; set; }

		public Entity UserEntity { get; set; }

		public Entity CharEntity { get; set; }

		public Player()
		{
		}

		public Player(ulong PlatformId, string? CharacterName, bool isConnected, Entity userEntity, Entity charEntity)
		{
			//IL_001c: 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)
			this.PlatformId = PlatformId;
			this.CharacterName = CharacterName;
			IsConnected = isConnected;
			UserEntity = userEntity;
			CharEntity = charEntity;
		}
	}
}
namespace OfflineRaidGuard.Hooks
{
	[HarmonyPatch]
	internal class StatChange
	{
		[HarmonyPatch(typeof(StatChangeSystem), "ApplyHealthChangeToEntity")]
		[HarmonyPrefix]
		private static void ApplyHealthChangeToEntity(StatChangeSystem __instance, ref StatChangeEvent statChange)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_013c: 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_0106: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			if (!Plugin.EnableMod.Value || !((StatChangeEvent)(ref statChange)).HasFlag((StatChangeFlag)65536))
			{
				return;
			}
			EntityManager entityManager = VWorld.Server.EntityManager;
			bool flag = default(bool);
			if (!((EntityManager)(ref entityManager)).HasComponent<CastleHeartConnection>(statChange.Entity))
			{
				ManualLogSource logger = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No Castle Heart Connection Found");
				}
				logger.LogWarning(val);
				return;
			}
			entityManager = VWorld.Server.EntityManager;
			Entity entity = ((EntityManager)(ref entityManager)).GetComponentData<CastleHeartConnection>(statChange.Entity).CastleHeartEntity._Entity;
			entityManager = VWorld.Server.EntityManager;
			if (!((EntityManager)(ref entityManager)).HasComponent<CastleHeart>(entity))
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(21, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No Castle Heart Found");
				}
				logger2.LogWarning(val);
				return;
			}
			entityManager = VWorld.Server.EntityManager;
			CastleHeart componentData = ((EntityManager)(ref entityManager)).GetComponentData<CastleHeart>(entity);
			if (!((Enum)componentData.State).HasFlag((Enum)(object)(CastleHeartState)1))
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(56, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Castle State (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CastleHeartState>(componentData.State);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") != IsProcessing; Castle must be decaying");
				}
				logger3.LogWarning(val);
				return;
			}
			if (!Cache.PlyonOwnerCache.TryGetValue(entity, out var userEntity))
			{
				ManualLogSource logger4 = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlyonOwnerCache did not contain this heart. Finding Owner");
				}
				logger4.LogWarning(val);
				entityManager = VWorld.Server.EntityManager;
				userEntity = ((EntityManager)(ref entityManager)).GetComponentData<UserOwner>(entity).Owner._Entity;
			}
			List<UserModel> list = GameData.Users.All.ToList();
			if (list.Exists((UserModel x) => ((EntityModel)x).Entity == userEntity))
			{
				UserModel val2 = list.First((UserModel x) => ((EntityModel)x).Entity == userEntity);
				ManualLogSource logger5 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Castle Heart Owner is found to be ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val2.CharacterName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
				}
				logger5.LogInfo(val3);
				if (!val2.IsConnected)
				{
					if (Plugin.FactorAllies.Value)
					{
						PlayerGroup allies = GetAllies(val2.Character.Entity);
						if (allies.AllyCount > 0)
						{
							foreach (Entity ally in allies.Allies)
							{
								if (!list.Exists((UserModel x) => ((EntityModel)x).Entity == ally))
								{
									continue;
								}
								UserModel val4 = list.First((UserModel x) => ((EntityModel)x).Entity == ally);
								if (val4.IsConnected)
								{
									ManualLogSource logger6 = Plugin.Logger;
									val3 = new BepInExInfoLogInterpolatedStringHandler(74, 2, ref flag);
									if (flag)
									{
										((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Castle Heart Owner (");
										((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val2.CharacterName);
										((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") Clan Member (");
										((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val4.CharacterName);
										((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" is Connected, Raiding them is allowed.");
									}
									logger6.LogInfo(val3);
								}
							}
						}
					}
					statChange.Change = 0f;
					statChange.OriginalChange = 0f;
				}
				else
				{
					ManualLogSource logger7 = Plugin.Logger;
					val3 = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Castle Heart Owner (");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val2.CharacterName);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") is Connected, Raiding them is allowed.");
					}
					logger7.LogInfo(val3);
				}
			}
			else
			{
				statChange.Change = 0f;
				statChange.OriginalChange = 0f;
				Plugin.Logger.LogWarning((object)"Owner could not be found, damage will not apply. This should be reported to SkyTech6 on the V Rising Discord community Technical Support channel.");
			}
		}

		private static PlayerGroup GetAllies(Entity characterEntity)
		{
			//IL_0005: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!Cache.AlliesCache.TryGetValue(characterEntity, out var value) || (DateTime.Now - value.TimeStamp).TotalSeconds > (double)Plugin.MaxAllyCacheAge.Value)
			{
				List<Entity> Group;
				int allies = Helper.GetAllies(characterEntity, out Group);
				PlayerGroup playerGroup = default(PlayerGroup);
				playerGroup.AllyCount = allies;
				playerGroup.Allies = Group;
				playerGroup.TimeStamp = DateTime.Now;
				value = playerGroup;
				Cache.AlliesCache[characterEntity] = value;
			}
			return value;
		}

		public static void EntityComponentDumper(string filePath, Entity entity)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			File.AppendAllText(filePath, "--------------------------------------------------" + Environment.NewLine);
			File.AppendAllText(filePath, "Dumping components of " + ((object)(Entity)(ref entity)).ToString() + ":" + Environment.NewLine);
			EntityManager entityManager = VWorld.Server.EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				File.AppendAllText(filePath, ((object)(ComponentType)(ref current)).ToString() + Environment.NewLine);
			}
			File.AppendAllText(filePath, "--------------------------------------------------" + Environment.NewLine);
			File.AppendAllText(filePath, DumpEntity(entity));
		}

		private static string DumpEntity(Entity entity, bool fullDump = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder val = new StringBuilder();
			EntityDebuggingUtility.DumpEntity(VWorld.Server, entity, fullDump, val);
			return ((Object)val).ToString();
		}
	}
}