Decompiled source of ServersideQoL Skills v2.0.1

ServersideQoL.Skills.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using ServersideQoL.Processors;
using ServersideQoL.Utilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArgusMagnus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("ArgusMagnus")]
[assembly: AssemblyDescription("Introduces additional effects with increasing player skill levels")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+5cb319fbf5621bf6723410a84d5d65328079c58b")]
[assembly: AssemblyProduct("ServersideQoL.Skills")]
[assembly: AssemblyTitle("ServersideQoL.Skills")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")]
[assembly: AssemblyVersion("2.0.1.0")]
[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 ServersideQoL.Skills
{
	public sealed class Config : ConfigBase<Config>
	{
		public sealed class PickaxeConfig
		{
			public ConfigEntry<int> RockCollapseThresholdAtMinSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, 100, "The percentage of destroyed parts required to collapse a rock or ore deposit at pickaxe skill level 0.\r\nThe actual required percentage scales linearly between this value and RockCollapseThresholdAtMaxSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "RockCollapseThresholdAtMinSkill");

			public ConfigEntry<int> RockCollapseThresholdAtMaxSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, 0, "The percentage of destroyed parts required to collapse a rock or ore deposit at pickaxe skill level 100.\r\nThe actual required percentage scales linearly between this value and RockCollapseThresholdAtMinSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "RockCollapseThresholdAtMaxSkill");

			public bool RockCollapseEnabled => Math.Max(RockCollapseThresholdAtMinSkill.Value, RockCollapseThresholdAtMaxSkill.Value) > 0;

			public PickaxeConfig(ConfigFile cfg, [CallerMemberName] string section = null)
			{
			}
		}

		public sealed class BloodMagicConfig
		{
			public ConfigEntry<int> SummonsLevelUpChanceAtMinSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 0 to summon a creature with an increased level.\r\nThe actual chance scales linearly between this value and SummonsLevelUpChanceAtMaxSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsLevelUpChanceAtMinSkill");

			public ConfigEntry<int> SummonsLevelUpChanceAtMaxSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 100 to summon a creature with an increased level.\r\nThe actual chance scales linearly between this value and SummonsLevelUpChanceAtMinSkill with skill level.\r\nSet both of these values to -1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsLevelUpChanceAtMaxSkill");

			public bool SummonsLevelUpEnabled => Math.Max(SummonsLevelUpChanceAtMinSkill.Value, SummonsLevelUpChanceAtMaxSkill.Value) > 0;

			public ConfigEntry<int> SummonsMaxLevel { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, 3, "The maximum level a summoned creature can reach.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 9), (Deprecated<Config>)null, "SummonsMaxLevel");

			public ConfigEntry<int> MakeSummonsFriendlyChanceAtMinSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 0 for hostile summons to be made friendly.\r\nThe actual chance scales linearly between this value and MakeSummonsFriendlyChanceAtMaxSkill with skill level.\r\nSet both of these values to -1 to disable this feature.\r\nThis will not affect summons that are already friendly by default.", (AcceptableValueBase)null, (Deprecated<Config>)null, "MakeSummonsFriendlyChanceAtMinSkill");

			public ConfigEntry<int> MakeSummonsFriendlyChanceAtMaxSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 100 for hostile summons to be made friendly.\r\nThe actual chance scales linearly between this value and MakeSummonsFriendlyChanceAtMinSkill with skill level.\r\nSet both of these values to -1 to disable this feature.\r\nThis will not affect summons that are already friendly by default.", (AcceptableValueBase)null, (Deprecated<Config>)null, "MakeSummonsFriendlyChanceAtMaxSkill");

			public ConfigEntry<bool> MakeFriendlySummonsFollow { get; } = ConfigBase<Config>.BindEx<bool>(cfg, section, true, "True to make friendly summoned creatures follow the summoner", (AcceptableValueBase)null, (Deprecated<Config>)null, "MakeFriendlySummonsFollow");

			public bool MakeSummonsFriendlyEnabled => Math.Max(MakeSummonsFriendlyChanceAtMinSkill.Value, MakeSummonsFriendlyChanceAtMaxSkill.Value) > 0;

			public ConfigEntry<int> MakeSummonsTolerateLavaChanceAtMinSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 0 for a summoned creature to tolerate lava.\r\nThe actual chance scales linearly between this value and MakeSummonsTolerateLavaChanceAtMaxSkill with skill level.\r\nSet both of these values to -1 to disable this feature.\r\nThis will not affect summons that already tolerate lava by default.", (AcceptableValueBase)null, (Deprecated<Config>)null, "MakeSummonsTolerateLavaChanceAtMinSkill");

			public ConfigEntry<int> MakeSummonsTolerateLavaChanceAtMaxSkill { get; } = ConfigBase<Config>.BindEx<int>(cfg, section, -1, "The chance (in percent) at skill level 0 for a summoned creature to tolerate lava.\r\nThe actual chance scales linearly between this value and MakeSummonsTolerateLavaChanceAtMinSkill with skill level.\r\nSet both of these values to -1 to disable this feature.\r\nThis will not affect summons that already tolerate lava by default.", (AcceptableValueBase)null, (Deprecated<Config>)null, "MakeSummonsTolerateLavaChanceAtMaxSkill");

			public bool MakeSummonsTolerateLavaEnabled => Math.Max(MakeSummonsTolerateLavaChanceAtMinSkill.Value, MakeSummonsTolerateLavaChanceAtMaxSkill.Value) > 0;

			public ConfigEntry<float> SummonsHPRegenMultiplierAtMinSkill { get; } = ConfigBase<Config>.BindEx<float>(cfg, section, 1f, "The time it takes for a summoned creature to fully regenerate its health at skill level 0 is multiplied by this factor.\r\nThe actual chance scales linearly between this value and SummonsHPRegenMultiplierAtMaxSkill with skill level.\r\nSet both of these values to 1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsHPRegenMultiplierAtMinSkill");

			public ConfigEntry<float> SummonsHPRegenMultiplierAtMaxSkill { get; } = ConfigBase<Config>.BindEx<float>(cfg, section, 1f, "The time it takes for a summoned creature to fully regenerate its health at skill level 100 is multiplied by this factor.\r\nThe actual chance scales linearly between this value and SummonsHPRegenMultiplierAtMinSkill with skill level.\r\nSet both of these values to 1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsHPRegenMultiplierAtMaxSkill");

			public bool SummonsHPRegenMultiplierEnabled
			{
				get
				{
					float value = SummonsHPRegenMultiplierAtMinSkill.Value;
					float value2 = SummonsHPRegenMultiplierAtMaxSkill.Value;
					if (value > 0f && value2 > 0f && (value != 1f || value2 != 1f))
					{
						return true;
					}
					return false;
				}
			}

			public ConfigEntry<float> SummonsSpeedMultiplierAtMinSkill { get; } = ConfigBase<Config>.BindEx<float>(cfg, section, 1f, "The movement speed of a summoned creature at skill level 0 is multiplied by this factor.\r\nThe actual chance scales linearly between this value and SummonsSpeedMultiplierAtMaxSkill with skill level.\r\nSet both of these values to 1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsSpeedMultiplierAtMinSkill");

			public ConfigEntry<float> SummonsSpeedMultiplierAtMaxSkill { get; } = ConfigBase<Config>.BindEx<float>(cfg, section, 1f, "The movement speed of a summoned creature at skill level 0 is multiplied by this factor.\r\nThe actual chance scales linearly between this value and SummonsSpeedMultiplierAtMinSkill with skill level.\r\nSet both of these values to 1 to disable this feature.", (AcceptableValueBase)null, (Deprecated<Config>)null, "SummonsSpeedMultiplierAtMaxSkill");

			public bool SummonsSpeedMultiplierEnabled
			{
				get
				{
					float value = SummonsSpeedMultiplierAtMinSkill.Value;
					float value2 = SummonsSpeedMultiplierAtMaxSkill.Value;
					if (value > 0f && value2 > 0f && (value != 1f || value2 != 1f))
					{
						return true;
					}
					return false;
				}
			}

			public ConfigEntry<float> AllowReplacementSummonMinSkill { get; } = ConfigBase<Config>.BindEx<float>(cfg, section, float.NaN, "Min skill level required to allow the summoning of new hostile summons (such as summoned trolls) to replace older ones when the limit exceeded", (AcceptableValueBase)null, (Deprecated<Config>)null, "AllowReplacementSummonMinSkill");

			public BloodMagicConfig(ConfigFile cfg, [CallerMemberName] string section = null)
			{
			}
		}

		public sealed class AdvancedConfig
		{
			public sealed class BloodMagicConfig
			{
				public sealed record FollowSummonerConfig(float MoveInterval, float MaxDistance)
				{
					private FollowSummonerConfig()
						: this(0f, 0f)
					{
					}
				}

				public FollowSummonerConfig FollowSummoners { get; init; } = new FollowSummonerConfig(4f, 20f);
			}

			public BloodMagicConfig BloodMagic { get; init; } = new BloodMagicConfig();
		}

		public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx<bool>(cfg, "Skills", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated<Config>)null, "Enabled");

		public PickaxeConfig Pickaxe { get; } = new PickaxeConfig(cfg, "Pickaxe");

		public BloodMagicConfig BloodMagic { get; } = new BloodMagicConfig(cfg, "BloodMagic");

		public YamlConfigEntry<AdvancedConfig> Advanced { get; } = ConfigBase<Config>.BindYaml<AdvancedConfig>(cfg, "Advanced");

		public Config(ConfigFile cfg, Logger logger)
			: base(cfg, logger)
		{
		}
	}
	[Processor("df8713af-a556-4351-9726-5826e791314f")]
	[DependsOn<PlayerRegistryProcessor>]
	public sealed class MineRockProcessor : Processor<MineRockProcessor.PrefabInfo>
	{
		public sealed record PrefabInfo(MineRock5 MineRock5) : ProcessorPrefabInfo()
		{
			[CompilerGenerated]
			public override string ToString()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("PrefabInfo");
				stringBuilder.Append(" { ");
				if (((ProcessorPrefabInfo)this).PrintMembers(stringBuilder))
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append('}');
				return stringBuilder.ToString();
			}

			[CompilerGenerated]
			protected override bool PrintMembers(StringBuilder builder)
			{
				if (((ProcessorPrefabInfo)this).PrintMembers(builder))
				{
					builder.Append(", ");
				}
				builder.Append("MineRock5 = ");
				builder.Append(MineRock5);
				return true;
			}

			[CompilerGenerated]
			public override int GetHashCode()
			{
				return ((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<MineRock5>.Default.GetHashCode(MineRock5);
			}

			[CompilerGenerated]
			public sealed override bool Equals(ProcessorPrefabInfo? other)
			{
				return ((object)this).Equals((object?)other);
			}

			[CompilerGenerated]
			public bool Equals(PrefabInfo? other)
			{
				if ((object)this != other)
				{
					if (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other))
					{
						return EqualityComparer<MineRock5>.Default.Equals(MineRock5, other.MineRock5);
					}
					return false;
				}
				return true;
			}

			[CompilerGenerated]
			private PrefabInfo(PrefabInfo original)
				: base((ProcessorPrefabInfo)(object)original)
			{
				MineRock5 = original.MineRock5;
			}
		}

		private readonly List<(int Idx, float Health)> _notDestroyedIndices = new List<(int, float)>();

		protected override void Initialize()
		{
			Processor.Instance<PlayerRegistryProcessor>().EnableSkillLevelEstimation(ConfigBase<Config>.Instance.Pickaxe.RockCollapseEnabled, "Initialize", 18);
		}

		protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo)
		{
			//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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			//IL_00b0: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigBase<Config>.Instance.Pickaxe.RockCollapseEnabled)
			{
				ZDOVars vars = zdo.Vars;
				string healthString = ((ZDOVars)(ref vars)).GetHealthString("");
				if (healthString != null && healthString.Length > 0)
				{
					float num = 32f;
					PlayerState val = null;
					float num2 = float.NaN;
					foreach (PlayerState playerState in Processor.Instance<PlayerRegistryProcessor>().PlayerStates)
					{
						ItemDrop lastUsedItem = playerState.LastUsedItem;
						if (lastUsedItem == null)
						{
							continue;
						}
						ItemData itemData = lastUsedItem.m_itemData;
						if (itemData == null)
						{
							continue;
						}
						SharedData shared = itemData.m_shared;
						if (shared != null && (int)shared.m_skillType == 12 && !float.IsNaN(num2 = playerState.GetEstimatedSkillLevel((SkillType)12)))
						{
							float num3 = Vector3.Distance(playerState.ZDO.ZDO.GetPosition(), zdo.ZDO.GetPosition());
							if (!(num3 >= num))
							{
								val = playerState;
								num = num3;
							}
						}
					}
					if (val != null)
					{
						if (float.IsNaN(num2))
						{
							num2 = 0f;
						}
						float num4 = Utils.Lerp((float)ConfigBase<Config>.Instance.Pickaxe.RockCollapseThresholdAtMinSkill.Value, (float)ConfigBase<Config>.Instance.Pickaxe.RockCollapseThresholdAtMaxSkill.Value, num2);
						num4 /= 100f;
						if (!(num4 >= 1f))
						{
							bool flag = num4 <= 0f;
							if (!flag)
							{
								SingletonCache<ZPackage>.Instance.Load(Convert.FromBase64String(healthString));
								int num5 = SingletonCache<ZPackage>.Instance.ReadInt();
								_notDestroyedIndices.Clear();
								for (int i = 0; i < num5; i++)
								{
									float num6 = SingletonCache<ZPackage>.Instance.ReadSingle();
									if (num6 > 0f)
									{
										_notDestroyedIndices.Add((i, num6));
									}
								}
								float num7 = (float)(num5 - _notDestroyedIndices.Count) / (float)num5;
								flag = num7 >= num4;
							}
							if (flag)
							{
								HitData val2 = new HitData();
								foreach (var notDestroyedIndex in _notDestroyedIndices)
								{
									int item = notDestroyedIndex.Idx;
									float item2 = notDestroyedIndex.Health;
									val2.m_damage.m_damage = item2;
									val2.m_toolTier = short.MaxValue;
									val2.m_hitType = (HitType)15;
									RPC.DamageMineRock5(zdo, val2, item);
								}
							}
							return (ProcessResult)0;
						}
						return (ProcessResult)0;
					}
					return (ProcessResult)0;
				}
				return (ProcessResult)0;
			}
			return (ProcessResult)2;
		}
	}
	[Processor("b41745c8-07ee-4ae1-897f-68391c136102")]
	[DependsOn<PlayerRegistryProcessor>]
	public sealed class PlayerSpawnedProcessor : Processor<PlayerSpawnedProcessor.PrefabInfo>
	{
		public sealed record PrefabInfo(Humanoid Humanoid, MonsterAI MonsterAI, Tameable? Tameable) : ProcessorPrefabInfo()
		{
			public override bool IsValid
			{
				get
				{
					//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_000c: 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_0012: Invalid comparison between Unknown and I4
					Faction faction = ((Character)Humanoid).m_faction;
					if ((int)faction == 0 || (int)faction == 11)
					{
						return true;
					}
					return false;
				}
			}

			[CompilerGenerated]
			public override string ToString()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("PrefabInfo");
				stringBuilder.Append(" { ");
				if (((ProcessorPrefabInfo)this).PrintMembers(stringBuilder))
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append('}');
				return stringBuilder.ToString();
			}

			[CompilerGenerated]
			protected override bool PrintMembers(StringBuilder builder)
			{
				if (((ProcessorPrefabInfo)this).PrintMembers(builder))
				{
					builder.Append(", ");
				}
				builder.Append("Humanoid = ");
				builder.Append(Humanoid);
				builder.Append(", MonsterAI = ");
				builder.Append(MonsterAI);
				builder.Append(", Tameable = ");
				builder.Append(Tameable);
				return true;
			}

			[CompilerGenerated]
			public override int GetHashCode()
			{
				return ((((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<Humanoid>.Default.GetHashCode(Humanoid)) * -1521134295 + EqualityComparer<MonsterAI>.Default.GetHashCode(MonsterAI)) * -1521134295 + EqualityComparer<Tameable>.Default.GetHashCode(Tameable);
			}

			[CompilerGenerated]
			public sealed override bool Equals(ProcessorPrefabInfo? other)
			{
				return ((object)this).Equals((object?)other);
			}

			[CompilerGenerated]
			public bool Equals(PrefabInfo? other)
			{
				if ((object)this != other)
				{
					if (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other) && EqualityComparer<Humanoid>.Default.Equals(Humanoid, other.Humanoid) && EqualityComparer<MonsterAI>.Default.Equals(MonsterAI, other.MonsterAI))
					{
						return EqualityComparer<Tameable>.Default.Equals(Tameable, other.Tameable);
					}
					return false;
				}
				return true;
			}

			[CompilerGenerated]
			private PrefabInfo(PrefabInfo original)
				: base((ProcessorPrefabInfo)(object)original)
			{
				Humanoid = original.Humanoid;
				MonsterAI = original.MonsterAI;
				Tameable = original.Tameable;
			}
		}

		private sealed record SpawnInfo(int MaxSpawned, string MaxSummonReached, Dictionary<int, List<ServersideQoLZDO>> SpawnedByPrefab);

		private sealed class SpawnedState
		{
			public PlayerState? Summoner { get; set; }

			public DateTimeOffset NextPatrolPointUpdate { get; set; }

			public bool ChancesEvaluated { get; set; }
		}

		public const string Id = "b41745c8-07ee-4ae1-897f-68391c136102";

		private bool _enabled;

		private readonly Dictionary<string, SpawnInfo> _spawnInfo = new Dictionary<string, SpawnInfo>();

		private readonly Dictionary<int, List<ServersideQoLZDO>> _spawnedByPrefab = new Dictionary<int, List<ServersideQoLZDO>>();

		private readonly Dictionary<ServersideQoLZDO, SpawnedState> _spawnedStates = new Dictionary<ServersideQoLZDO, SpawnedState>();

		private PlayerState? _lastSummoningPlayer;

		protected override void Initialize()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_01d5: Invalid comparison between Unknown and I4
			Processor.Instance<PlayerRegistryProcessor>().EnableSkillLevelEstimation(_enabled = ConfigBase<Config>.Instance.BloodMagic.SummonsLevelUpEnabled || ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyEnabled || ConfigBase<Config>.Instance.BloodMagic.MakeSummonsTolerateLavaEnabled || ConfigBase<Config>.Instance.BloodMagic.SummonsHPRegenMultiplierEnabled || ConfigBase<Config>.Instance.BloodMagic.SummonsSpeedMultiplierEnabled, "Initialize", 27);
			foreach (List<ServersideQoLZDO> value2 in _spawnedByPrefab.Values)
			{
				value2.Clear();
			}
			_spawnedStates.Clear();
			_lastSummoningPlayer = null;
			Intercept.UpdateInterception(ZSyncAnimation.SetTrigger, (Delegate)new Action<RoutedRPCData, string>(OnZSyncAnimationSetTrigger), ConfigBase<Config>.Instance.BloodMagic.AllowReplacementSummonMinSkill.Value <= 100f || ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyEnabled);
			if (_spawnInfo.Count != 0 || (!(ConfigBase<Config>.Instance.BloodMagic.AllowReplacementSummonMinSkill.Value <= 100f) && !ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyEnabled))
			{
				return;
			}
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				ItemDrop component = item.GetComponent<ItemDrop>();
				if (component == null)
				{
					continue;
				}
				Attack attack = component.m_itemData.m_shared.m_attack;
				GameObject attackProjectile = attack.m_attackProjectile;
				SpawnAbility val = ((attackProjectile != null) ? attackProjectile.GetComponent<SpawnAbility>() : null);
				if (val == null)
				{
					continue;
				}
				Dictionary<int, List<ServersideQoLZDO>> dictionary = new Dictionary<int, List<ServersideQoLZDO>>();
				GameObject[] spawnPrefab = val.m_spawnPrefab;
				foreach (GameObject val2 in spawnPrefab)
				{
					Humanoid component2 = val2.GetComponent<Humanoid>();
					bool flag;
					if (component2 != null)
					{
						Faction faction = ((Character)component2).m_faction;
						if ((int)faction == 0 || (int)faction == 11)
						{
							flag = true;
							goto IL_01dd;
						}
					}
					flag = false;
					goto IL_01dd;
					IL_01dd:
					if (flag)
					{
						int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)val2).name);
						if (!_spawnedByPrefab.TryGetValue(stableHashCode, out List<ServersideQoLZDO> value))
						{
							_spawnedByPrefab.Add(stableHashCode, value = new List<ServersideQoLZDO>());
						}
						dictionary.Add(stableHashCode, value);
					}
				}
				if (dictionary.Count > 0)
				{
					_spawnInfo.Add(attack.m_attackAnimation, new SpawnInfo(val.m_maxSpawned, val.m_maxSummonReached, dictionary));
				}
			}
			foreach (ServersideQoLZDO item2 in from x in PrivateAccessor.GetObjects(ZDOMan.instance)
				select x.ServersideQoLZDO)
			{
				if (_spawnedByPrefab.TryGetValue(item2.ZDO.GetPrefab(), out List<ServersideQoLZDO> list) && !list.Contains(item2))
				{
					list.Add(item2);
					item2.Destroyed += delegate(ServersideQoLZDO x)
					{
						list.Remove(x);
					};
				}
			}
			foreach (List<ServersideQoLZDO> value3 in _spawnedByPrefab.Values)
			{
				SortBySpawnTime(value3);
			}
		}

		protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo)
		{
			//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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			if (!_spawnedStates.TryGetValue(zdo, out SpawnedState value))
			{
				_spawnedStates.Add(zdo, value = new SpawnedState());
				zdo.Destroyed += delegate(ServersideQoLZDO x)
				{
					_spawnedStates.Remove(x);
				};
				if (prefabInfo.Tameable == null)
				{
					if (!_spawnedByPrefab.TryGetValue(zdo.ZDO.GetPrefab(), out List<ServersideQoLZDO> list))
					{
						_spawnedByPrefab.Add(zdo.ZDO.GetPrefab(), list = new List<ServersideQoLZDO>());
					}
					if (!list.Contains(zdo))
					{
						list.Add(zdo);
						SortBySpawnTime(list);
						zdo.Destroyed += delegate(ServersideQoLZDO x)
						{
							list.Remove(x);
						};
					}
				}
			}
			ZDOVars vars;
			if (value.Summoner == null)
			{
				vars = zdo.Vars;
				string playerName = ((ZDOVars)(ref vars)).GetFollow("");
				if (!string.IsNullOrEmpty(playerName))
				{
					value.Summoner = ((IEnumerable<PlayerState>)Processor.Instance<PlayerRegistryProcessor>().PlayerStates).FirstOrDefault((Func<PlayerState, bool>)((PlayerState x) => x.PlayerName == playerName));
				}
				SpawnedState spawnedState = value;
				if (spawnedState.Summoner == null)
				{
					PlayerState val = (spawnedState.Summoner = _lastSummoningPlayer);
				}
				if (value.Summoner != null && string.IsNullOrEmpty(playerName))
				{
					vars = zdo.Vars;
					((ZDOVars)(ref vars)).SetFollow(playerName = value.Summoner.PlayerName, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 113);
				}
			}
			vars = zdo.Vars;
			bool tamed = ((ZDOVars)(ref vars)).GetTamed(false);
			ProcessResult val2 = EvaluateChances(zdo, value, tamed, prefabInfo);
			if (tamed && ConfigBase<Config>.Instance.BloodMagic.MakeFriendlySummonsFollow.Value && prefabInfo.Tameable == null)
			{
				Config.AdvancedConfig.BloodMagicConfig.FollowSummonerConfig followSummoners = ConfigBase<Config>.Instance.Advanced.Value.BloodMagic.FollowSummoners;
				ComponentFieldAccessor<MonsterAI> val3 = zdo.Fields<MonsterAI>();
				if (val3.UpdateValue((Func<Expression<Func<MonsterAI, float>>>)(() => (MonsterAI x) => ((BaseAI)x).m_randomMoveInterval), followSummoners.MoveInterval, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 125))
				{
					val2 = (ProcessResult)(val2 | 8);
				}
				if (val3.UpdateValue((Func<Expression<Func<MonsterAI, float>>>)(() => (MonsterAI x) => ((BaseAI)x).m_randomMoveRange), followSummoners.MaxDistance, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 127))
				{
					val2 = (ProcessResult)(val2 | 8);
				}
				val2 = (ProcessResult)(val2 & -3);
				if (value.Summoner != null)
				{
					DateTimeOffset utcNow = DateTimeOffset.UtcNow;
					if (utcNow > value.NextPatrolPointUpdate && Utils.DistanceXZ(zdo.ZDO.GetPosition(), value.Summoner.ZDO.ZDO.GetPosition()) > followSummoners.MaxDistance / 2f)
					{
						value.NextPatrolPointUpdate = utcNow.AddSeconds(followSummoners.MoveInterval / 2f);
						uint dataRevision = zdo.ZDO.DataRevision;
						vars = zdo.Vars;
						((ZDOVars)(ref vars)).SetSpawnPoint(value.Summoner.ZDO.ZDO.GetPosition(), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 138);
						vars = zdo.Vars;
						((ZDOVars)(ref vars)).SetPatrol(true, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 139);
						vars = zdo.Vars;
						((ZDOVars)(ref vars)).SetPatrolPoint(value.Summoner.ZDO.ZDO.GetPosition(), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 140);
						if (dataRevision != zdo.ZDO.DataRevision)
						{
							ZDO zDO = zdo.ZDO;
							zDO.DataRevision += 100;
						}
					}
				}
			}
			return val2;
		}

		private static void SortBySpawnTime(List<ServersideQoLZDO> list)
		{
			list.Sort(delegate(ServersideQoLZDO a, ServersideQoLZDO b)
			{
				//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_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)
				ZDOVars vars = a.Vars;
				long ticks = ((ZDOVars)(ref vars)).GetSpawnTime(default(DateTime)).Ticks;
				vars = b.Vars;
				return Math.Sign(ticks - ((ZDOVars)(ref vars)).GetSpawnTime(default(DateTime)).Ticks);
			});
		}

		private ProcessResult EvaluateChances(ServersideQoLZDO zdo, SpawnedState state, bool tamed, PrefabInfo prefabInfo)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: 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_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_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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: 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_00de: 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_00e2: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			ProcessResult val = (ProcessResult)2;
			if (state.ChancesEvaluated)
			{
				return val;
			}
			state.ChancesEvaluated = true;
			if (state.Summoner == null)
			{
				return val;
			}
			State state2 = Random.state;
			ZDOVars vars = zdo.Vars;
			Random.InitState(((ZDOVars)(ref vars)).GetSeed(0));
			try
			{
				float? num = null;
				if (!tamed && ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyEnabled)
				{
					if (!num.HasValue)
					{
						num = state.Summoner.GetEstimatedSkillLevel((SkillType)10);
						if (float.IsNaN(num.Value))
						{
							num = 0f;
						}
					}
					int num2 = Mathf.RoundToInt(Utils.Lerp((float)ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyChanceAtMinSkill.Value, (float)ConfigBase<Config>.Instance.BloodMagic.MakeSummonsFriendlyChanceAtMaxSkill.Value, num.Value));
					if (num2 >= 0 && Random.Range(0, 100) <= num2)
					{
						val = (ProcessResult)(val & -3);
						RPC.SetTamed(zdo, true);
						vars = zdo.Vars;
						((ZDOVars)(ref vars)).SetTamed(true, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 183);
					}
				}
				if (ConfigBase<Config>.Instance.BloodMagic.SummonsLevelUpEnabled)
				{
					if (!num.HasValue)
					{
						num = state.Summoner.GetEstimatedSkillLevel((SkillType)10);
						if (float.IsNaN(num.Value))
						{
							num = 0f;
						}
					}
					int num3 = Mathf.RoundToInt(Utils.Lerp((float)ConfigBase<Config>.Instance.BloodMagic.SummonsLevelUpChanceAtMinSkill.Value, (float)ConfigBase<Config>.Instance.BloodMagic.SummonsLevelUpChanceAtMaxSkill.Value, num.Value));
					int i;
					for (i = 1; i < ConfigBase<Config>.Instance.BloodMagic.SummonsMaxLevel.Value; i++)
					{
						if (!(Random.Range(0f, 100f) <= (float)num3))
						{
							break;
						}
					}
					int num4 = i;
					vars = zdo.Vars;
					if (num4 != ((ZDOVars)(ref vars)).GetLevel(1))
					{
						vars = zdo.Vars;
						((ZDOVars)(ref vars)).SetLevel(i, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 202);
						val = (ProcessResult)(val | 8);
					}
				}
				if (ConfigBase<Config>.Instance.BloodMagic.MakeSummonsTolerateLavaEnabled)
				{
					if (!num.HasValue)
					{
						num = state.Summoner.GetEstimatedSkillLevel((SkillType)10);
						if (float.IsNaN(num.Value))
						{
							num = 0f;
						}
					}
					int num5 = Mathf.RoundToInt(Utils.Lerp((float)ConfigBase<Config>.Instance.BloodMagic.MakeSummonsTolerateLavaChanceAtMinSkill.Value, (float)ConfigBase<Config>.Instance.BloodMagic.MakeSummonsTolerateLavaChanceAtMaxSkill.Value, num.Value));
					if (!((Character)prefabInfo.Humanoid).m_tolerateFire && zdo.Fields<Humanoid>().UpdateValue((Func<Expression<Func<Humanoid, bool>>>)(() => (Humanoid x) => ((Character)x).m_tolerateFire), Random.Range(0, 100) <= num5, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 218))
					{
						val = (ProcessResult)(val | 8);
					}
				}
				if (ConfigBase<Config>.Instance.BloodMagic.SummonsHPRegenMultiplierEnabled)
				{
					if (!num.HasValue)
					{
						num = state.Summoner.GetEstimatedSkillLevel((SkillType)10);
						if (float.IsNaN(num.Value))
						{
							num = 0f;
						}
					}
					float num6 = Utils.Lerp(ConfigBase<Config>.Instance.BloodMagic.SummonsHPRegenMultiplierAtMinSkill.Value, ConfigBase<Config>.Instance.BloodMagic.SummonsHPRegenMultiplierAtMaxSkill.Value, num.Value);
					if (zdo.Fields<Humanoid>().UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_regenAllHPTime), ((Character)prefabInfo.Humanoid).m_regenAllHPTime / num6, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 234))
					{
						val = (ProcessResult)(val | 8);
					}
					if (prefabInfo.Tameable != null && zdo.Fields<Tameable>().UpdateValue((Func<Expression<Func<Tameable, float>>>)(() => (Tameable x) => x.m_fedDuration), float.PositiveInfinity, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 236))
					{
						val = (ProcessResult)(val | 8);
					}
				}
				if (ConfigBase<Config>.Instance.BloodMagic.SummonsSpeedMultiplierEnabled)
				{
					if (!num.HasValue)
					{
						num = state.Summoner.GetEstimatedSkillLevel((SkillType)10);
						if (float.IsNaN(num.Value))
						{
							num = 0f;
						}
					}
					float num7 = Utils.Lerp(ConfigBase<Config>.Instance.BloodMagic.SummonsSpeedMultiplierAtMinSkill.Value, ConfigBase<Config>.Instance.BloodMagic.SummonsSpeedMultiplierAtMaxSkill.Value, num.Value);
					ComponentFieldAccessor<Humanoid> val2 = zdo.Fields<Humanoid>();
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_speed), ((Character)prefabInfo.Humanoid).m_speed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 250))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_crouchSpeed), ((Character)prefabInfo.Humanoid).m_crouchSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 252))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_flyFastSpeed), ((Character)prefabInfo.Humanoid).m_flyFastSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 254))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_flySlowSpeed), ((Character)prefabInfo.Humanoid).m_flySlowSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 256))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_groundTiltSpeed), ((Character)prefabInfo.Humanoid).m_groundTiltSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 260))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_runSpeed), ((Character)prefabInfo.Humanoid).m_runSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 262))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_swimSpeed), ((Character)prefabInfo.Humanoid).m_swimSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 266))
					{
						val = (ProcessResult)(val | 8);
					}
					if (val2.UpdateValue((Func<Expression<Func<Humanoid, float>>>)(() => (Humanoid x) => ((Character)x).m_walkSpeed), ((Character)prefabInfo.Humanoid).m_walkSpeed * num7, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.Skills\\PlayerSpawnedProcessor.cs", 272))
					{
						val = (ProcessResult)(val | 8);
					}
				}
			}
			finally
			{
				Random.state = state2;
			}
			return val;
		}

		private void OnZSyncAnimationSetTrigger(RoutedRPCData data, string name)
		{
			//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_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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			if (!_spawnInfo.TryGetValue(name, out SpawnInfo value) || (_lastSummoningPlayer = Processor.Instance<PlayerRegistryProcessor>().GetStateForPeerID(data.m_senderPeerID)) == null || !(ConfigBase<Config>.Instance.BloodMagic.AllowReplacementSummonMinSkill.Value <= _lastSummoningPlayer.GetEstimatedSkillLevel((SkillType)10)))
			{
				return;
			}
			foreach (List<ServersideQoLZDO> value2 in value.SpawnedByPrefab.Values)
			{
				if (value2.Count >= value.MaxSpawned)
				{
					if (value2[0].ZDO.GetOwner() == data.m_senderPeerID && ZNetScene.InActiveArea(value2[0].ZDO.GetPosition(), _lastSummoningPlayer.ZDO.ZDO.GetSector()))
					{
						RPC.Damage(value2[0], new HitData(float.MaxValue)
						{
							m_attacker = _lastSummoningPlayer.ZDO.ZDO.m_uid
						});
					}
					else
					{
						value2[0].Destroy();
					}
					RPC.ShowMessage(data.m_senderPeerID, (MessageType)2, value.MaxSummonReached);
				}
			}
		}
	}
	[BepInPlugin("ArgusMagnus.ServersideQoL.Skills", "ServersideQoL.Skills", "2.0.1")]
	public sealed class SkillsPlugin : ServersideQoLPluginBase<SkillsPlugin, Config>
	{
		public const string Author = "ArgusMagnus";

		public const string PluginName = "ServersideQoL.Skills";

		public const string PluginGuid = "ArgusMagnus.ServersideQoL.Skills";

		public const string PluginVersion = "2.0.1";

		public const string PluginInformationalVersion = "2.0.1";

		private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639246168460370955L, default(TimeSpan));

		protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger)
		{
			return new Config(configFile, logger);
		}

		protected override void RegisterProcessors(IProcessorCollection processors)
		{
			processors.Add<MineRockProcessor>().Add<PlayerSpawnedProcessor>();
		}

		private void Awake()
		{
		}
	}
}