Decompiled source of CrimsonMoon v0.1.2

CrimsonMoon.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
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 BepInEx.Unity.IL2CPP.Utils.Collections;
using Bloodstone.API;
using CrimsonMoon.Structs;
using CrimsonMoon.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Text;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CrimsonMoon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A sacraficial alter to praise the moon! Honor it in return for a blood moon!")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+1.Branch.master.Sha.64e85107dc6fb12d90304d8a493e10bebed6d33b")]
[assembly: AssemblyProduct("CrimsonMoon")]
[assembly: AssemblyTitle("CrimsonMoon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
namespace CrimsonMoon
{
	internal static class Core
	{
		private static bool _hasInitialized;

		private static MonoBehaviour mono;

		public static DropClearSystem DropItem { get; internal set; }

		internal static void InitializeAfterLoaded()
		{
			if (!_hasInitialized)
			{
				DropItem = new DropClearSystem();
				_hasInitialized = true;
			}
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if ((Object)(object)mono == (Object)null)
			{
				GameObject val = new GameObject("CrimsonMoon");
				mono = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
				Object.DontDestroyOnLoad((Object)val);
			}
			return mono.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
		}
	}
	[BepInPlugin("CrimsonMoon", "CrimsonMoon", "0.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Reloadable]
	public class Plugin : BasePlugin, IRunOnInitialized
	{
		private Harmony _harmony;

		public static ManualLogSource LogInstance { get; private set; }

		public static Settings Settings { get; private set; }

		public override void Load()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			LogInstance = ((BasePlugin)this).Log;
			Settings = new Settings(((BasePlugin)this).Config);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonMoon");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			_harmony = new Harmony("CrimsonMoon");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			CommandRegistry.RegisterAll();
		}

		public void OnGameInitialized()
		{
			Core.InitializeAfterLoaded();
		}

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

		public const string PLUGIN_NAME = "CrimsonMoon";

		public const string PLUGIN_VERSION = "0.1.2";
	}
}
namespace CrimsonMoon.Utils
{
	internal class DropClearSystem
	{
		private EntityQuery dropItemQuery;

		public DropClearSystem()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[4]
			{
				new ComponentType(Il2CppType.Of<ItemPickup>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<Translation>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<DestroyWhenNoCharacterNearbyAfterDuration>(), (AccessMode)0)
			});
			val.None = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<AttachedBuffer>(), (AccessMode)1)
			});
			val.Options = (EntityQueryOptions)2;
			EntityQueryDesc val2 = val;
			EntityManager entityManager = VWorld.Server.EntityManager;
			dropItemQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(val2.All);
		}

		private IEnumerable<Entity> GetDropItems()
		{
			NativeArray<Entity> entities = ((EntityQuery)(ref dropItemQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = entities.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				current.Read<PrefabGUID>();
				yield return current;
			}
			entities.Dispose();
		}

		private int ClearDropItems(Func<Entity, bool> shouldClear = null)
		{
			//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_002e: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			DynamicBuffer<InventoryBuffer> val = default(DynamicBuffer<InventoryBuffer>);
			foreach (Entity dropItem in GetDropItems())
			{
				if (shouldClear != null && !shouldClear(dropItem))
				{
					continue;
				}
				EntityManager entityManager = VWorld.Server.EntityManager;
				if (((EntityManager)(ref entityManager)).TryGetBuffer<InventoryBuffer>(dropItem, ref val))
				{
					Enumerator<InventoryBuffer> enumerator2 = val.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						InventoryBuffer current2 = enumerator2.Current;
						NetworkedEntity itemEntity = current2.ItemEntity;
						if (!(((NetworkedEntity)(ref itemEntity)).GetEntityOnServer() == Entity.Null))
						{
							EntityManager entityManager2 = VWorld.Server.EntityManager;
							itemEntity = current2.ItemEntity;
							DestroyUtility.Destroy(entityManager2, ((NetworkedEntity)(ref itemEntity)).GetEntityOnServer(), (DestroyDebugReason)0, (string)null, 0);
						}
					}
				}
				DestroyUtility.Destroy(VWorld.Server.EntityManager, dropItem, (DestroyDebugReason)0, (string)null, 0);
				num++;
			}
			return num;
		}

		public int ClearDropItemsInRadius(float3 pos, float radius)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float2 posXZ = ((float3)(ref pos)).xz;
			return ClearDropItems(delegate(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_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				Translation val = entity.Read<Translation>();
				return math.distance(posXZ, ((float3)(ref val.Value)).xz) <= radius;
			});
		}
	}
	public static class ECSExtensionService
	{
		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = VWorld.Server.EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

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

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//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_000d: 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)
			EntityManager entityManager = VWorld.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

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

		public static bool Has<T>(this Entity entity)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static void LogComponentTypes(this 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				ManualLogSource logInstance = Plugin.LogInstance;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current);
				}
				logInstance.LogInfo(val);
			}
			Plugin.LogInstance.LogInfo((object)"===");
		}

		public static void LogComponentTypes(this EntityQuery entityQuery)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			foreach (ComponentType item in (Il2CppArrayBase<ComponentType>)(object)((EntityQuery)(ref entityQuery)).GetQueryTypes())
			{
				ManualLogSource logInstance = Plugin.LogInstance;
				val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Query Component Type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(item);
				}
				logInstance.LogInfo(val);
			}
			ManualLogSource logInstance2 = Plugin.LogInstance;
			val = new BepInExInfoLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("===");
			}
			logInstance2.LogInfo(val);
		}

		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//IL_0011: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			PrefabCollectionSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			object obj;
			if (!existingSystemManaged.PrefabGuidToNameDictionary.ContainsKey(prefabGuid))
			{
				obj = "GUID Not Found";
			}
			else
			{
				string text = existingSystemManaged.PrefabGuidToNameDictionary[prefabGuid];
				PrefabGUID val = prefabGuid;
				obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}
	}
}
namespace CrimsonMoon.Structs
{
	public struct PlayerData
	{
		public FixedString64Bytes CharacterName { get; set; }

		public ulong SteamID { get; set; }

		public bool IsOnline { get; set; }

		public Entity UserEntity { get; set; }

		public Entity CharEntity { get; set; }

		public PlayerData(FixedString64Bytes _characterName = default(FixedString64Bytes), ulong _steamID = 0uL, bool _isOnline = false, Entity _userEntity = default(Entity), Entity _charEntity = default(Entity))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			CharacterName = _characterName;
			SteamID = _steamID;
			IsOnline = _isOnline;
			UserEntity = _userEntity;
			CharEntity = _charEntity;
		}
	}
	public class Player
	{
		public string Name { get; set; }

		public ulong SteamID { get; set; }

		public bool IsOnline { get; set; }

		public bool IsAdmin { get; set; }

		public Entity User { get; set; }

		public Entity Character { get; set; }

		public Player(Entity userEntity = default(Entity), Entity charEntity = default(Entity))
		{
			//IL_0007: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_004f: 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)
			User = userEntity;
			User val = User.Read<User>();
			Character = val.LocalCharacter._Entity;
			Name = ((object)(FixedString64Bytes)(ref val.CharacterName)).ToString();
			IsOnline = val.IsConnected;
			IsAdmin = val.IsAdmin;
			SteamID = val.PlatformId;
		}
	}
	public readonly struct Settings
	{
		internal readonly ConfigFile CONFIG;

		internal readonly ConfigEntry<bool> ENABLE_MOD;

		internal readonly ConfigEntry<double> ALTER_LOCATION_X;

		internal readonly ConfigEntry<double> ALTER_LOCATION_Y;

		internal readonly ConfigEntry<double> ALTER_LOCATION_Z;

		internal readonly ConfigEntry<int> SACRAFICE_GUID;

		internal readonly ConfigEntry<int> MIN_AMOUNT;

		public Settings(ConfigFile config)
		{
			CONFIG = config;
			ENABLE_MOD = config.Bind<bool>("Config", "EnableMod", true, "Enable or disable the mod");
			SACRAFICE_GUID = config.Bind<int>("Sacrafice", "SacraficeGUID", 1566989408, "ItemHash for the sacraficed material");
			MIN_AMOUNT = config.Bind<int>("Sacrafice", "MinimumRequired", 3, "This is how many must be dropped to trigger blood moon");
			ALTER_LOCATION_X = config.Bind<double>("Alter", "AlterLocation_X", -1585.3368, "The float3 position of the alter, accepts sacrafices within 10 distance");
			ALTER_LOCATION_Y = config.Bind<double>("Alter", "AlterLocation_Y", -3.8146, (ConfigDescription)null);
			ALTER_LOCATION_Z = config.Bind<double>("Alter", "AlterLocation_Z", -937.0102, (ConfigDescription)null);
		}
	}
}
namespace CrimsonMoon.Hooks
{
	[HarmonyPatch]
	internal class Sacrafice
	{
		[HarmonyPatch(typeof(DropItemThrowSystem), "OnUpdate")]
		public class DropItemThrowSystem_Prefix
		{
			private EntityQuery dropItemQuery;

			public static void Prefix(DropItemThrowSystem __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//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_0038: 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_0047: 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_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: 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_0091: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				EntityQuery _query_2070481711_ = __instance.__query_2070481711_0;
				Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_2070481711_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)).GetEnumerator();
				DropItemAroundPosition val = default(DropItemAroundPosition);
				Vector3 val3 = default(Vector3);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					EntityManager entityManager = VWorld.Server.EntityManager;
					if (((EntityManager)(ref entityManager)).TryGetComponentData<DropItemAroundPosition>(current, ref val) && val.ItemHash == new PrefabGUID(Plugin.Settings.SACRAFICE_GUID.Value) && val.Amount >= Plugin.Settings.MIN_AMOUNT.Value)
					{
						Vector3 val2 = new Vector3(val.Position.x, val.Position.y, val.Position.z);
						((Vector3)(ref val3))..ctor((float)Plugin.Settings.ALTER_LOCATION_X.Value, (float)Plugin.Settings.ALTER_LOCATION_Y.Value, (float)Plugin.Settings.ALTER_LOCATION_Z.Value);
						if (Vector3.Distance(val2, val3) < 10f)
						{
							ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, "The Blood Alter runs red!");
							VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>().JumpToNextBloodMoon();
							Core.StartCoroutine(Clear(val3, 20));
						}
					}
				}
			}

			private static IEnumerator Clear(Vector3 vector, int radius)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				yield return (object)new WaitForSeconds(1f);
				int value = Core.DropItem.ClearDropItemsInRadius(float3.op_Implicit(vector), radius);
				ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, $"Cleared {value}");
			}

			public static void EntityCompomponentDumper(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();
			}
		}
	}
}
namespace CrimsonMoon.Commands
{
	[CommandGroup("crimsonmoon", "cmoon")]
	internal class BloodMoon
	{
		[Command("trigger", "t", null, "Forces next moon to be blood", null, true)]
		public static void TriggerBloodMoon(ChatCommandContext ctx)
		{
			VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>().JumpToNextBloodMoon();
			ctx.Reply("Jumping to Next Blood Moon");
		}
	}
}