Decompiled source of SoulForge v1.0.1

SoulForge.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Bloodstone.Hooks;
using Bloody.Core;
using Bloody.Core.API.v1;
using Bloody.Core.GameData.v1;
using Bloody.Core.Models.v1;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Darrean(inility)")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to manage shard stashing and provided the abilities to add glows to shard holders.")]
[assembly: AssemblyFileVersion("0.1.10.0")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e")]
[assembly: AssemblyProduct("SoulForge")]
[assembly: AssemblyTitle("SoulForge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SoulForge
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SoulForge";

		public const string PLUGIN_NAME = "SoulForge";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("SoulForge", "SoulForge", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SoulForgePlugin : BasePlugin
	{
		private Harmony _harmony;

		public static SoulForgePlugin Instance { get; private set; }

		public static ConfigEntry<bool> AllowSolarusContainer { get; private set; }

		public static ConfigEntry<bool> AllowMonsterContainer { get; private set; }

		public static ConfigEntry<bool> AllowManticoreContainer { get; private set; }

		public static ConfigEntry<bool> AllowDraculaContainer { get; private set; }

		public static ConfigEntry<bool> EnableGlowDracula { get; private set; }

		public static ConfigEntry<bool> EnableGlowAdam { get; private set; }

		public static ConfigEntry<bool> EnableGlowHorror { get; private set; }

		public static ConfigEntry<bool> EnableGlowSolarus { get; private set; }

		public override void Load()
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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
			Instance = this;
			AllowSolarusContainer = ((BasePlugin)this).Config.Bind<bool>("Containers", "Allow_Solarus", true, "Allow the Solarus container?");
			AllowMonsterContainer = ((BasePlugin)this).Config.Bind<bool>("Containers", "Allow_Monster", true, "Allow the Adam(Monster) container?");
			AllowManticoreContainer = ((BasePlugin)this).Config.Bind<bool>("Containers", "Allow_Manticore", true, "Allow the Winged Horror(Manticore) container?");
			AllowDraculaContainer = ((BasePlugin)this).Config.Bind<bool>("Containers", "Allow_Dracula", true, "Allow the Dracula container?");
			EnableGlowDracula = ((BasePlugin)this).Config.Bind<bool>("Glows", "Enable_Dracula_Glow", true, "Enable glow for Dracula Shard?");
			EnableGlowAdam = ((BasePlugin)this).Config.Bind<bool>("Glows", "Enable_Adam_Glow", true, "Enable glow for Adam Shard?");
			EnableGlowHorror = ((BasePlugin)this).Config.Bind<bool>("Glows", "Enable_Horror_Glow", true, "Enable glow for Winged Horror Shard?");
			EnableGlowSolarus = ((BasePlugin)this).Config.Bind<bool>("Glows", "Enable_Solarus_Glow", true, "Enable glow for Solarus Shard?");
			_harmony = new Harmony("SoulForge");
			_harmony.PatchAll();
			Chat.OnChatMessage += new ChatEventHandler(HandleReloadCommand);
		}

		public override bool Unload()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Chat.OnChatMessage -= new ChatEventHandler(HandleReloadCommand);
			return true;
		}

		private void HandleReloadCommand(VChatEvent ev)
		{
			//IL_0061: 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: Expected O, but got Unknown
			//IL_0015: 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)
			if (!ev.Message.Equals("!reload", StringComparison.OrdinalIgnoreCase) || !ev.User.IsAdmin)
			{
				return;
			}
			try
			{
				((BasePlugin)this).Config.Reload();
				((BasePlugin)this).Config.Save();
				RecheckAllPlayersGlows();
				VExtensions.SendSystemMessage(ev.User, "<color=#00FF00>SoulForge config reloaded successfully!</color>");
			}
			catch (Exception ex)
			{
				VExtensions.SendSystemMessage(ev.User, "<color=#FF0000>SoulForge reload failed:</color> " + ex.Message);
				ManualLogSource log = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error reloading SoulForge config: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void RecheckAllPlayersGlows()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0059: 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_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_0099: 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_00a3: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			Entity val = default(Entity);
			foreach (UserModel item in GameData.Users.All)
			{
				if (!item.IsConnected)
				{
					continue;
				}
				Entity entity = item.Character.Entity;
				if (entity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(entity))
				{
					continue;
				}
				foreach (KeyValuePair<PrefabGUID, PrefabGUID> shardNecklacesToVisualBuff in SoulForgeData.ShardNecklacesToVisualBuffs)
				{
					PrefabGUID key = shardNecklacesToVisualBuff.Key;
					PrefabGUID value = shardNecklacesToVisualBuff.Value;
					if (!IsGlowEnabled(key) && BuffUtility.TryGetBuff(entityManager, entity, PrefabIdentifier.op_Implicit(value), ref val))
					{
						SoulForgeHelpers.Unbuff(entity, value);
					}
				}
			}
		}

		public bool IsGlowEnabled(PrefabGUID shardItem)
		{
			//IL_0003: 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_003d: 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)
			if (((PrefabGUID)(ref shardItem)).Equals(SoulForgeData.DraculaShardItem))
			{
				return EnableGlowDracula.Value;
			}
			if (((PrefabGUID)(ref shardItem)).Equals(SoulForgeData.AdamShardItem))
			{
				return EnableGlowAdam.Value;
			}
			if (((PrefabGUID)(ref shardItem)).Equals(SoulForgeData.HorrorShardItem))
			{
				return EnableGlowHorror.Value;
			}
			if (((PrefabGUID)(ref shardItem)).Equals(SoulForgeData.SolarusShardItem))
			{
				return EnableGlowSolarus.Value;
			}
			return true;
		}
	}
	public static class SoulForgeData
	{
		public static PrefabGUID SolarusContainer = new PrefabGUID(-824445631);

		public static PrefabGUID MonsterContainer = new PrefabGUID(-1996942061);

		public static PrefabGUID ManticoreContainer = new PrefabGUID(653759442);

		public static PrefabGUID DraculaContainer = new PrefabGUID(1495743889);

		public static HashSet<PrefabGUID> BlockedContainers = new HashSet<PrefabGUID> { SolarusContainer, MonsterContainer, ManticoreContainer, DraculaContainer };

		public static PrefabGUID DraculaShardItem = new PrefabGUID(-504120321);

		public static PrefabGUID DraculaGlowBuff = new PrefabGUID(662242066);

		public static PrefabGUID AdamShardItem = new PrefabGUID(403228886);

		public static PrefabGUID AdamGlowBuff = new PrefabGUID(1237097606);

		public static PrefabGUID HorrorShardItem = new PrefabGUID(1002452390);

		public static PrefabGUID HorrorGlowBuff = new PrefabGUID(1670636401);

		public static PrefabGUID SolarusShardItem = new PrefabGUID(329820611);

		public static PrefabGUID SolarusGlowBuff = new PrefabGUID(1688799287);

		public static Dictionary<PrefabGUID, PrefabGUID> ShardNecklacesToVisualBuffs = new Dictionary<PrefabGUID, PrefabGUID>
		{
			{ DraculaShardItem, DraculaGlowBuff },
			{ AdamShardItem, AdamGlowBuff },
			{ HorrorShardItem, HorrorGlowBuff },
			{ SolarusShardItem, SolarusGlowBuff }
		};
	}
	public static class SoulForgeHelpers
	{
		public static bool BuffPlayer(Entity character, Entity user, PrefabGUID buffPrefab, int duration = -1, bool persistsThroughDeath = false)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_002c: 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_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0076: 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_007e: 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_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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0141: 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)
			//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_0128: 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_00f4: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_016e: 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_0184: 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)
			EntityManager entityManager = VWorld.Server.EntityManager;
			DebugEventsSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>();
			if (existingSystemManaged == null)
			{
				return false;
			}
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff(entityManager, character, PrefabIdentifier.op_Implicit(buffPrefab), ref val))
			{
				return false;
			}
			ApplyBuffDebugEvent val2 = default(ApplyBuffDebugEvent);
			val2.BuffPrefabGUID = buffPrefab;
			ApplyBuffDebugEvent val3 = val2;
			FromCharacter val4 = default(FromCharacter);
			val4.User = user;
			val4.Character = character;
			FromCharacter val5 = val4;
			existingSystemManaged.ApplyBuff(val5, val3);
			Entity val6 = default(Entity);
			if (BuffUtility.TryGetBuff(entityManager, character, PrefabIdentifier.op_Implicit(buffPrefab), ref val6))
			{
				if (ECSExtensions.Has<CreateGameplayEventsOnSpawn>(val6))
				{
					ECSExtensions.Remove<CreateGameplayEventsOnSpawn>(val6);
				}
				if (ECSExtensions.Has<GameplayEventListeners>(val6))
				{
					ECSExtensions.Remove<GameplayEventListeners>(val6);
				}
				if (persistsThroughDeath)
				{
					ECSExtensions.Add<Buff_Persists_Through_Death>(val6);
					if (ECSExtensions.Has<RemoveBuffOnGameplayEvent>(val6))
					{
						ECSExtensions.Remove<RemoveBuffOnGameplayEvent>(val6);
					}
					if (ECSExtensions.Has<RemoveBuffOnGameplayEventEntry>(val6))
					{
						ECSExtensions.Remove<RemoveBuffOnGameplayEventEntry>(val6);
					}
				}
				if (duration > 0)
				{
					if (ECSExtensions.Has<LifeTime>(val6))
					{
						LifeTime val7 = ECSExtensions.Read<LifeTime>(val6);
						val7.Duration = duration;
						ECSExtensions.Write<LifeTime>(val6, val7);
					}
				}
				else if (duration == 0)
				{
					if (ECSExtensions.Has<LifeTime>(val6))
					{
						LifeTime val8 = ECSExtensions.Read<LifeTime>(val6);
						val8.Duration = -1f;
						val8.EndAction = (LifeTimeEndAction)0;
						ECSExtensions.Write<LifeTime>(val6, val8);
					}
					if (ECSExtensions.Has<RemoveBuffOnGameplayEvent>(val6))
					{
						ECSExtensions.Remove<RemoveBuffOnGameplayEvent>(val6);
					}
					if (ECSExtensions.Has<RemoveBuffOnGameplayEventEntry>(val6))
					{
						ECSExtensions.Remove<RemoveBuffOnGameplayEventEntry>(val6);
					}
				}
				return true;
			}
			return false;
		}

		public static void Unbuff(Entity character, PrefabGUID buffPrefab)
		{
			//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)
			BuffSystem.Unbuff(character, buffPrefab);
		}
	}
	[HarmonyPatch(typeof(PlaceTileModelSystem), "OnUpdate")]
	public static class PlaceTileModelSystemPatch
	{
		[HarmonyPrefix]
		public static void Prefix(PlaceTileModelSystem __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0031: 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_003b: 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_0054: 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_005b: 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_0069: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_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_013a: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery buildTileQuery = __instance._BuildTileQuery;
			NativeArray<Entity> val = ((EntityQuery)(ref buildTileQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (!((EntityManager)(ref entityManager)).HasComponent<BuildTileModelEvent>(current))
				{
					continue;
				}
				BuildTileModelEvent componentData = ((EntityManager)(ref entityManager)).GetComponentData<BuildTileModelEvent>(current);
				PrefabGUID prefabGuid = componentData.PrefabGuid;
				if (!SoulForgeData.BlockedContainers.Contains(prefabGuid))
				{
					continue;
				}
				bool flag = false;
				if (((PrefabGUID)(ref prefabGuid)).Equals(SoulForgeData.SolarusContainer))
				{
					flag = !SoulForgePlugin.AllowSolarusContainer.Value;
				}
				else if (((PrefabGUID)(ref prefabGuid)).Equals(SoulForgeData.MonsterContainer))
				{
					flag = !SoulForgePlugin.AllowMonsterContainer.Value;
				}
				else if (((PrefabGUID)(ref prefabGuid)).Equals(SoulForgeData.ManticoreContainer))
				{
					flag = !SoulForgePlugin.AllowManticoreContainer.Value;
				}
				else if (((PrefabGUID)(ref prefabGuid)).Equals(SoulForgeData.DraculaContainer))
				{
					flag = !SoulForgePlugin.AllowDraculaContainer.Value;
				}
				if (!flag)
				{
					continue;
				}
				Entity val2 = Entity.Null;
				if (((EntityManager)(ref entityManager)).HasComponent<FromCharacter>(current))
				{
					Entity character = ((EntityManager)(ref entityManager)).GetComponentData<FromCharacter>(current).Character;
					if (character != Entity.Null && ((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(character))
					{
						val2 = character;
					}
				}
				if (val2 == Entity.Null && ((EntityManager)(ref entityManager)).HasComponent<EntityOwner>(current))
				{
					Entity owner = ((EntityManager)(ref entityManager)).GetComponentData<EntityOwner>(current).Owner;
					if (owner != Entity.Null && ((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(owner))
					{
						val2 = owner;
					}
				}
				if (val2 != Entity.Null)
				{
					PlayerCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(val2);
					if (componentData2.UserEntity != Entity.Null && ((EntityManager)(ref entityManager)).HasComponent<User>(componentData2.UserEntity))
					{
						User componentData3 = ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData2.UserEntity);
						ServerChatUtils.SendSystemMessageToClient(entityManager, componentData3, "<color=#FF0000>Stashing of this shard has been disabled.</color>");
					}
				}
				((EntityManager)(ref entityManager)).DestroyEntity(current);
			}
			val.Dispose();
		}
	}
	[HarmonyPatch(typeof(ModifyUnitStatBuffSystem_Spawn), "OnUpdate")]
	public static class SoulGlowSpawnPatch
	{
		[HarmonyPrefix]
		public static void Prefix(ModifyUnitStatBuffSystem_Spawn __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0031: 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_003b: 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_0054: 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_0060: 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_0089: 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_009b: 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_00a5: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery _query_1735840491_ = __instance.__query_1735840491_0;
			NativeArray<Entity> val = ((EntityQuery)(ref _query_1735840491_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(current))
				{
					continue;
				}
				PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
				if (SoulForgeData.ShardNecklacesToVisualBuffs.TryGetValue(componentData, out var value) && SoulForgePlugin.Instance.IsGlowEnabled(componentData) && ((EntityManager)(ref entityManager)).HasComponent<EntityOwner>(current))
				{
					Entity owner = ((EntityManager)(ref entityManager)).GetComponentData<EntityOwner>(current).Owner;
					if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(owner))
					{
						PlayerCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(owner);
						SoulForgeHelpers.BuffPlayer(owner, componentData2.UserEntity, value, 0);
					}
				}
			}
			val.Dispose();
		}
	}
	[HarmonyPatch(typeof(ModifyUnitStatBuffSystem_Destroy), "OnUpdate")]
	public static class SoulGlowDestroyPatch
	{
		[HarmonyPrefix]
		public static void Prefix(ModifyUnitStatBuffSystem_Destroy __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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_0038: 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_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_005a: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_009a: 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)
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery _query_1735840524_ = __instance.__query_1735840524_0;
			NativeArray<Entity> val = ((EntityQuery)(ref _query_1735840524_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(current))
				{
					continue;
				}
				PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
				if (SoulForgeData.ShardNecklacesToVisualBuffs.TryGetValue(componentData, out var value) && ((EntityManager)(ref entityManager)).HasComponent<EntityOwner>(current))
				{
					Entity owner = ((EntityManager)(ref entityManager)).GetComponentData<EntityOwner>(current).Owner;
					if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(owner))
					{
						SoulForgeHelpers.Unbuff(owner, value);
					}
				}
			}
			val.Dispose();
		}
	}
}