Decompiled source of Starstorm2Lost v0.1.0

plugins/Starstorm2Lost/Starstorm2Lost.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.GummyClone;
using EntityStates.MimicEquip;
using HG;
using HG.Reflection;
using IL.RoR2;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.EntityStates.GummyClone;
using On.RoR2;
using On.RoR2.Items;
using On.RoR2.UI;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPathsBetter;
using SS2;
using SS2.Components;
using SS2.Monsters;
using Starstorm2Lost.Content;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Starstorm2Lost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c988079955e49d627ea90ee7f89be9a0c0585f20")]
[assembly: AssemblyProduct("Starstorm2Lost")]
[assembly: AssemblyTitle("Starstorm2Lost")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Starstorm2Lost
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("Starstorm2Lost");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "Starstorm2Lost".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal static class LostAssets
	{
		private static Sprite _mysteryIcon;

		private static readonly List<(BuffDef buff, Func<BuffDef> iconSource)> _pendingBuffIcons;

		internal static Sprite MysteryIcon
		{
			get
			{
				//IL_0011: 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)
				if (!Object.op_Implicit((Object)(object)_mysteryIcon))
				{
					_mysteryIcon = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common_MiscIcons.texMysteryIcon_png).WaitForCompletion();
				}
				return _mysteryIcon;
			}
		}

		static LostAssets()
		{
			_pendingBuffIcons = new List<(BuffDef, Func<BuffDef>)>();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				foreach (var pendingBuffIcon in _pendingBuffIcons)
				{
					BuffDef item = pendingBuffIcon.buff;
					BuffDef val = pendingBuffIcon.iconSource();
					if (Object.op_Implicit((Object)(object)val))
					{
						item.iconSprite = val.iconSprite;
					}
				}
				_pendingBuffIcons.Clear();
			});
		}

		internal static BuffDef CreateBuff(string name, Color color, bool canStack, bool isDebuff, Func<BuffDef> iconSource)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = CreateBuff(name, color, canStack, isDebuff, (Sprite)null);
			_pendingBuffIcons.Add((val, iconSource));
			return val;
		}

		internal static BuffDef CreateBuff(string name, Color color, bool canStack, bool isDebuff, Sprite icon)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			BuffDef obj = ScriptableObject.CreateInstance<BuffDef>();
			((Object)obj).name = name;
			obj.buffColor = color;
			obj.canStack = canStack;
			obj.isDebuff = isDebuff;
			obj.isHidden = false;
			obj.iconSprite = icon;
			return obj;
		}
	}
	internal static class LostConfig
	{
		private static ConfigFile _config;

		internal static void Init(ConfigFile config)
		{
			_config = config;
			if (ModCompat.RiskOfOptionsInstalled)
			{
				RiskOfOptionsCompat.SetModDescription();
			}
		}

		internal static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, bool restartRequired = false)
		{
			ConfigEntry<T> val = _config.Bind<T>(section, key, defaultValue, description);
			if (ModCompat.RiskOfOptionsInstalled)
			{
				RiskOfOptionsCompat.AddOption<T>(val, restartRequired);
			}
			return val;
		}
	}
	[BepInPlugin("Phreel.Starstorm2Lost", "Starstorm2Lost", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<List<string>> <>9__12_0;

			public static CollectContentPackProvidersDelegate <>9__12_1;

			internal void <Awake>b__12_0(List<string> folders)
			{
				folders.Add(Path.Combine(PluginDirectory, "languages"));
			}

			internal void <Awake>b__12_1(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new LostContentPack());
			}
		}

		public const string PluginGUID = "Phreel.Starstorm2Lost";

		public const string PluginAuthor = "Phreel";

		public const string PluginName = "Starstorm2Lost";

		public const string PluginVersion = "0.1.0";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			Instance = this;
			PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Log.Init(((BaseUnityPlugin)this).Logger);
			LostConfig.Init(((BaseUnityPlugin)this).Config);
			Language.collectLanguageRootFolders += delegate(List<string> folders)
			{
				folders.Add(Path.Combine(PluginDirectory, "languages"));
			};
			ContentPiece.InitializeAll();
			object obj = <>c.<>9__12_1;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
				{
					add.Invoke((IContentPackProvider)(object)new LostContentPack());
				};
				<>c.<>9__12_1 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
		}
	}
	internal static class ModCompat
	{
		public const string RiskOfOptionsGUID = "com.rune580.riskofoptions";

		public const string EnforcerGUID = "com.EnforcerGang.Enforcer";

		public const string SS2UGUID = "com.ChirrLover.Starstorm2Unofficial";

		public static bool RiskOfOptionsInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static bool EnforcerInstalled => Chainloader.PluginInfos.ContainsKey("com.EnforcerGang.Enforcer");

		public static bool SS2UInstalled => Chainloader.PluginInfos.ContainsKey("com.ChirrLover.Starstorm2Unofficial");
	}
	internal static class RiskOfOptionsCompat
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void SetModDescription()
		{
			ModSettingsManager.SetModDescription("Revives cut and in-development Starstorm 2 content.", "Phreel.Starstorm2Lost", "Starstorm 2 Lost");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void AddOption<T>(ConfigEntry<T> entry, bool restartRequired)
		{
			//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_0032: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004d: 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_005e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			BaseOption val = (BaseOption)((entry is ConfigEntry<bool> val2) ? ((object)new CheckBoxOption(val2, new CheckBoxConfig
			{
				restartRequired = restartRequired
			})) : ((entry is ConfigEntry<int> val3) ? ((object)new IntFieldOption(val3, new IntFieldConfig
			{
				restartRequired = restartRequired
			})) : ((object)((!(entry is ConfigEntry<float> val4)) ? ((FloatFieldOption)null) : new FloatFieldOption(val4, new FloatFieldConfig
			{
				restartRequired = restartRequired
			})))));
			BaseOption val5 = val;
			if (val5 != null)
			{
				ModSettingsManager.AddOption(val5, "Phreel.Starstorm2Lost", "Starstorm 2 Lost");
			}
		}
	}
	internal static class TokenFormatter
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GetLocalizedStringByToken <0>__FormatOnRead;
		}

		private static readonly Dictionary<string, Func<object[]>> _tokens = new Dictionary<string, Func<object[]>>();

		private static bool _hooked;

		internal static void Add(string token, Func<object[]> args)
		{
			//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_0034: Expected O, but got Unknown
			_tokens[token] = args;
			if (!_hooked)
			{
				_hooked = true;
				object obj = <>O.<0>__FormatOnRead;
				if (obj == null)
				{
					hook_GetLocalizedStringByToken val = FormatOnRead;
					<>O.<0>__FormatOnRead = val;
					obj = (object)val;
				}
				Language.GetLocalizedStringByToken += (hook_GetLocalizedStringByToken)obj;
			}
		}

		private static string FormatOnRead(orig_GetLocalizedStringByToken orig, Language self, string token)
		{
			string text = orig.Invoke(self, token);
			if (token == null || !_tokens.TryGetValue(token, out var value) || text == token)
			{
				return text;
			}
			try
			{
				return string.Format(text, value());
			}
			catch (FormatException)
			{
				return text;
			}
		}
	}
}
namespace Starstorm2Lost.Content
{
	public abstract class ContentPiece
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Type, bool> <>9__18_0;

			public static hook_PerformEquipmentAction <>9__24_0;

			internal bool <InitializeAll>b__18_0(Type t)
			{
				if (!t.IsAbstract)
				{
					return typeof(ContentPiece).IsAssignableFrom(t);
				}
				return false;
			}

			internal bool <RegisterEquipmentAction>b__24_0(orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef def)
			{
				if (!Object.op_Implicit((Object)(object)def) || !equipmentActions.TryGetValue(def, out var value))
				{
					return orig.Invoke(self, def);
				}
				return value(self);
			}
		}

		internal static readonly List<ContentPiece> Active = new List<ContentPiece>();

		private static readonly Dictionary<EquipmentDef, Func<EquipmentSlot, bool>> equipmentActions = new Dictionary<EquipmentDef, Func<EquipmentSlot, bool>>();

		public abstract string Category { get; }

		public abstract string Name { get; }

		public virtual bool EnabledByDefault => true;

		public virtual bool IsAvailable => true;

		public string ConfigSection => Regex.Replace(Category + ": " + Name, "[=\\n\\t\\\\\"'\\[\\]]", "");

		public ConfigEntry<bool> Enabled { get; private set; }

		protected virtual void BindConfig()
		{
		}

		protected virtual void Hook()
		{
		}

		public abstract void LoadContent(ContentPack contentPack);

		internal static void InitializeAll()
		{
			foreach (Type item in from t in typeof(ContentPiece).Assembly.GetTypes()
				where !t.IsAbstract && typeof(ContentPiece).IsAssignableFrom(t)
				select t)
			{
				ContentPiece contentPiece = null;
				try
				{
					contentPiece = (ContentPiece)Activator.CreateInstance(item);
					contentPiece.Enabled = LostConfig.Bind(contentPiece.ConfigSection, "Enabled", contentPiece.EnabledByDefault, "Set to false to remove " + contentPiece.Name + " from the game. Everyone in multiplayer must have the same setting.", restartRequired: true);
					if (contentPiece.Enabled.Value && contentPiece.IsAvailable)
					{
						contentPiece.BindConfig();
						contentPiece.Hook();
						Active.Add(contentPiece);
					}
				}
				catch (Exception arg)
				{
					Log.Error($"Failed to initialize {contentPiece?.Name ?? item.Name}: {arg}", "D:\\Games\\LostItems\\starstorm2lost\\Starstorm2Lost\\Content\\ContentPiece.cs", "InitializeAll", 72);
				}
			}
		}

		protected static ItemDef CloneSS2ItemDef(string assetName, SS2Bundle bundle, string newName)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ItemDef obj = Object.Instantiate<ItemDef>(SS2Assets.LoadAsset<ItemDef>(assetName, bundle));
			((Object)obj).name = newName;
			return obj;
		}

		protected static void SetTokens(ItemDef itemDef, string tokenPrefix)
		{
			itemDef.nameToken = tokenPrefix + "_NAME";
			itemDef.pickupToken = tokenPrefix + "_PICKUP";
			itemDef.descriptionToken = tokenPrefix + "_DESC";
			itemDef.loreToken = tokenPrefix + "_LORE";
		}

		protected static void SetTokens(EquipmentDef equipmentDef, string tokenPrefix)
		{
			equipmentDef.nameToken = tokenPrefix + "_NAME";
			equipmentDef.pickupToken = tokenPrefix + "_PICKUP";
			equipmentDef.descriptionToken = tokenPrefix + "_DESC";
			equipmentDef.loreToken = tokenPrefix + "_LORE";
		}

		protected static void AddMonsterLog(ContentPack contentPack, string assetName, SS2Bundle bundle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			UnlockableDef val = SS2Assets.LoadAsset<UnlockableDef>(assetName, bundle);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (string.IsNullOrEmpty(val.cachedName))
				{
					val.cachedName = ((Object)val).name;
				}
				contentPack.unlockableDefs.Add((UnlockableDef[])(object)new UnlockableDef[1] { val });
			}
		}

		protected static void RegisterEquipmentAction(EquipmentDef equipmentDef, Func<EquipmentSlot, bool> action)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (equipmentActions.Count == 0)
			{
				object obj = <>c.<>9__24_0;
				if (obj == null)
				{
					Func<EquipmentSlot, bool> value;
					hook_PerformEquipmentAction val = (orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef def) => (!Object.op_Implicit((Object)(object)def) || !equipmentActions.TryGetValue(def, out value)) ? orig.Invoke(self, def) : value(self);
					<>c.<>9__24_0 = val;
					obj = (object)val;
				}
				EquipmentSlot.PerformEquipmentAction += (hook_PerformEquipmentAction)obj;
			}
			equipmentActions[equipmentDef] = action;
		}

		protected static void SetIcon(ItemDef itemDef, Sprite icon)
		{
			itemDef.pickupIconSprite = icon;
		}

		protected static void SetIcon(EquipmentDef equipmentDef, Sprite icon)
		{
			equipmentDef.pickupIconSprite = icon;
		}

		protected static EquipmentDef CloneSS2EquipmentDef(string assetName, SS2Bundle bundle, string newName)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			EquipmentDef obj = Object.Instantiate<EquipmentDef>(SS2Assets.LoadAsset<EquipmentDef>(assetName, bundle));
			((Object)obj).name = newName;
			return obj;
		}
	}
	public abstract class ItemBodyBehavior : MonoBehaviour
	{
		private struct Registration
		{
			public Func<ItemDef> itemDef;

			public Type behaviorType;

			public bool server;

			public bool client;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c__4<T> where T : ItemBodyBehavior
		{
			public static readonly <>c__4<T> <>9 = new <>c__4<T>();

			public static hook_OnInventoryChanged <>9__4_0;

			internal void <Register>b__4_0(orig_OnInventoryChanged orig, CharacterBody self)
			{
				orig.Invoke(self);
				UpdateBehaviors(self);
			}
		}

		public CharacterBody body;

		public int stack;

		private static readonly List<Registration> registrations = new List<Registration>();

		internal static void Register<T>(Func<ItemDef> itemDef, bool server = true, bool client = false) where T : ItemBodyBehavior
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (registrations.Count == 0)
			{
				object obj = <>c__4<T>.<>9__4_0;
				if (obj == null)
				{
					hook_OnInventoryChanged val = delegate(orig_OnInventoryChanged orig, CharacterBody self)
					{
						orig.Invoke(self);
						UpdateBehaviors(self);
					};
					<>c__4<T>.<>9__4_0 = val;
					obj = (object)val;
				}
				CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj;
			}
			registrations.Add(new Registration
			{
				itemDef = itemDef,
				behaviorType = typeof(T),
				server = server,
				client = client
			});
		}

		private static void UpdateBehaviors(CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body.inventory))
			{
				return;
			}
			bool active = NetworkServer.active;
			bool active2 = NetworkClient.active;
			foreach (Registration registration in registrations)
			{
				if (!(registration.server && active) && !(registration.client && active2))
				{
					continue;
				}
				ItemDef val = registration.itemDef();
				int num = (Object.op_Implicit((Object)(object)val) ? body.inventory.GetItemCountEffective(val) : 0);
				ItemBodyBehavior itemBodyBehavior = (ItemBodyBehavior)(object)((Component)body).GetComponent(registration.behaviorType);
				if (num > 0)
				{
					if (!Object.op_Implicit((Object)(object)itemBodyBehavior))
					{
						itemBodyBehavior = (ItemBodyBehavior)(object)((Component)body).gameObject.AddComponent(registration.behaviorType);
						itemBodyBehavior.body = body;
					}
					itemBodyBehavior.stack = num;
				}
				else if (Object.op_Implicit((Object)(object)itemBodyBehavior))
				{
					Object.Destroy((Object)(object)itemBodyBehavior);
				}
			}
		}
	}
	internal class LostContentPack : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public string identifier => "Phreel.Starstorm2Lost";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			while (!((ResourceAvailability)(ref SS2Assets.assetsAvailability)).available)
			{
				yield return null;
			}
			for (int i = 0; i < ContentPiece.Active.Count; i++)
			{
				ContentPiece contentPiece = ContentPiece.Active[i];
				try
				{
					contentPiece.LoadContent(_contentPack);
				}
				catch (Exception arg)
				{
					Log.Error($"Failed to load content for {contentPiece.Name}: {arg}", "D:\\Games\\LostItems\\starstorm2lost\\Starstorm2Lost\\Content\\LostContentPack.cs", "LoadStaticContentAsync", 31);
				}
				args.ReportProgress(((float)i + 1f) / (float)ContentPiece.Active.Count);
				yield return null;
			}
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(_contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
}
namespace Starstorm2Lost.Content.Monsters
{
	public sealed class Agarthan : ContentPiece
	{
		public static GameObject bodyPrefab;

		public static GameObject masterPrefab;

		public static CharacterSpawnCard spawnCard;

		private static ConfigEntry<int> directorCost;

		private static ConfigEntry<int> selectionWeight;

		private static ConfigEntry<int> minimumStageCompletions;

		private static ConfigEntry<string> stages;

		public override string Category => "Monsters";

		public override string Name => "Agarthan";

		public override bool EnabledByDefault => false;

		protected override void BindConfig()
		{
			directorCost = LostConfig.Bind(base.ConfigSection, "Director Cost", 20, "Credits the director spends to spawn one. For reference, Lemurians cost 11.", restartRequired: true);
			selectionWeight = LostConfig.Bind(base.ConfigSection, "Selection Weight", 1, "How often it's picked compared to other monsters.", restartRequired: true);
			minimumStageCompletions = LostConfig.Bind(base.ConfigSection, "Minimum Stage Completions", 0, "Stages that must be cleared before it can appear.", restartRequired: true);
			stages = LostConfig.Bind(base.ConfigSection, "Stages", "SunderedGrove, TitanicPlains, DistantRoost, WetlandAspect", "Comma separated stages it spawns on, using R2API's DirectorAPI.Stage names.", restartRequired: true);
		}

		public override void LoadContent(ContentPack contentPack)
		{
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			bodyPrefab = SS2Assets.LoadAsset<GameObject>("AgarthanBody", (SS2Bundle)15);
			masterPrefab = SS2Assets.LoadAsset<GameObject>("AgarthanMaster", (SS2Bundle)15);
			contentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { bodyPrefab });
			ContentPiece.AddMonsterLog(contentPack, "Logs.AgarthanBody", (SS2Bundle)15);
			contentPack.masterPrefabs.Add((GameObject[])(object)new GameObject[1] { masterPrefab });
			contentPack.skillDefs.Add((SkillDef[])(object)new SkillDef[2]
			{
				SS2Assets.LoadAsset<SkillDef>("sdAgarthan1", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillDef>("sdAgarthan2", (SS2Bundle)15)
			});
			contentPack.skillFamilies.Add((SkillFamily[])(object)new SkillFamily[2]
			{
				SS2Assets.LoadAsset<SkillFamily>("sfAgarthan1", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillFamily>("sfAgarthan2", (SS2Bundle)15)
			});
			spawnCard = ScriptableObject.CreateInstance<CharacterSpawnCard>();
			((Object)spawnCard).name = "cscSS2LostAgarthan";
			((SpawnCard)spawnCard).prefab = masterPrefab;
			((SpawnCard)spawnCard).sendOverNetwork = true;
			((SpawnCard)spawnCard).hullSize = (HullClassification)0;
			((SpawnCard)spawnCard).nodeGraphType = (GraphType)0;
			((SpawnCard)spawnCard).requiredFlags = (NodeFlags)0;
			((SpawnCard)spawnCard).forbiddenFlags = (NodeFlags)4;
			((SpawnCard)spawnCard).directorCreditCost = directorCost.Value;
			DirectorCard card = new DirectorCard
			{
				spawnCard = (SpawnCard)(object)spawnCard,
				selectionWeight = selectionWeight.Value,
				minimumStageCompletions = minimumStageCompletions.Value,
				spawnDistance = (MonsterSpawnDistance)0,
				preventOverhead = false
			};
			DirectorCardHolder val = new DirectorCardHolder
			{
				Card = card,
				MonsterCategory = (MonsterCategory)2
			};
			string[] array = stages.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string text in array)
			{
				if (Enum.TryParse<Stage>(text.Trim(), ignoreCase: true, out Stage result))
				{
					Helpers.AddNewMonsterToStage(val, false, result, "");
				}
				else
				{
					Log.Warning("Agarthan: unknown stage \"" + text.Trim() + "\" in config, skipping it.", "D:\\Games\\LostItems\\starstorm2lost\\Starstorm2Lost\\Content\\Monsters\\Agarthan.cs", "LoadContent", 90);
				}
			}
		}
	}
	public sealed class EquipmentMimic : ContentPiece
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<DamageReport> <0>__StealEquipment;

			public static Action<DamageReport> <1>__TauntAfterKill;

			public static hook_GetBestBodyName <2>__GetBestBodyName;

			public static hook_Respawn_Vector3_Quaternion_bool <3>__Respawn;

			public static hook_OnEnter <4>__GummyCloneSpawnState_OnEnter;
		}

		private static ConfigEntry<int> selectionWeight;

		private static ConfigEntry<int> minimumStageCompletions;

		private static GameObject masterPrefab;

		private static GameObject theftOrbEffect;

		private static MasterIndex masterIndex = MasterIndex.none;

		public override string Category => "Monsters";

		public override string Name => "Equipment Mimic";

		protected override void BindConfig()
		{
			selectionWeight = LostConfig.Bind(base.ConfigSection, "Selection Weight", 2, "How often it replaces a chest spawn, compared to other chests.", restartRequired: true);
			minimumStageCompletions = LostConfig.Bind(base.ConfigSection, "Minimum Stage Completions", 1, "Stages that must be cleared before it can appear.", restartRequired: true);
		}

		protected override void Hook()
		{
			//IL_0050: 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_005b: Expected O, but got Unknown
			//IL_0070: 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_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			GlobalEventManager.onServerDamageDealt += StealEquipment;
			GlobalEventManager.onCharacterDeathServer += TauntAfterKill;
			object obj = <>O.<2>__GetBestBodyName;
			if (obj == null)
			{
				hook_GetBestBodyName val = GetBestBodyName;
				<>O.<2>__GetBestBodyName = val;
				obj = (object)val;
			}
			Util.GetBestBodyName += (hook_GetBestBodyName)obj;
			object obj2 = <>O.<3>__Respawn;
			if (obj2 == null)
			{
				hook_Respawn_Vector3_Quaternion_bool val2 = Respawn;
				<>O.<3>__Respawn = val2;
				obj2 = (object)val2;
			}
			CharacterMaster.Respawn_Vector3_Quaternion_bool += (hook_Respawn_Vector3_Quaternion_bool)obj2;
			object obj3 = <>O.<4>__GummyCloneSpawnState_OnEnter;
			if (obj3 == null)
			{
				hook_OnEnter val3 = GummyCloneSpawnState_OnEnter;
				<>O.<4>__GummyCloneSpawnState_OnEnter = val3;
				obj3 = (object)val3;
			}
			GummyCloneSpawnState.OnEnter += (hook_OnEnter)obj3;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//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)
				masterIndex = MasterCatalog.FindMasterIndex(masterPrefab);
			});
		}

		public override void LoadContent(ContentPack contentPack)
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: 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_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: 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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			masterPrefab = SS2Assets.LoadAsset<GameObject>("MimicEquipMaster", (SS2Bundle)15);
			GameObject val = SS2Assets.LoadAsset<GameObject>("MimicEquipBody", (SS2Bundle)15);
			contentPack.masterPrefabs.Add((GameObject[])(object)new GameObject[1] { masterPrefab });
			contentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { val });
			ContentPiece.AddMonsterLog(contentPack, "Logs.MimicEquip.0", (SS2Bundle)15);
			contentPack.skillDefs.Add((SkillDef[])(object)new SkillDef[4]
			{
				SS2Assets.LoadAsset<SkillDef>("SkillMimicEquipLeap", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillDef>("SkillMimicEquipOpen", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillDef>("SkillMimicEquipRechest", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillDef>("SkillMimicEquipUseEquipment", (SS2Bundle)15)
			});
			contentPack.skillFamilies.Add((SkillFamily[])(object)new SkillFamily[4]
			{
				SS2Assets.LoadAsset<SkillFamily>("sfMimicEquip1", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillFamily>("sfMimicEquip2", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillFamily>("sfMimicEquip3", (SS2Bundle)15),
				SS2Assets.LoadAsset<SkillFamily>("sfMimicEquip4", (SS2Bundle)15)
			});
			MimicEquip._masterPrefab = masterPrefab;
			MimicEquip.jetVFX = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoDashJets.prefab").WaitForCompletion();
			MimicEquip.leapLandVFX = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/CryoCanisterExplosionSecondary.prefab").WaitForCompletion();
			MimicEquip.rechestVFX = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/RoboCratePodGroundImpact.prefab").WaitForCompletion();
			MimicEquip.itemStarburst = SS2Assets.LoadAsset<GameObject>("Chest1Starburst", (SS2Bundle)15);
			MimicEquip.zipperVFX = SS2Assets.LoadAsset<GameObject>("ChestUnzipReal", (SS2Bundle)17);
			typeof(MimicEquip).GetProperty("StealItemDamageType", BindingFlags.Static | BindingFlags.Public).GetSetMethod(nonPublic: true).Invoke(null, new object[1] { DamageAPI.ReserveDamageType() });
			theftOrbEffect = SS2Assets.LoadAsset<GameObject>("EquipTakenOrbEffect", (SS2Bundle)15);
			InspectDef val2 = SS2Assets.LoadAsset<InspectDef>("idMimicEquip", (SS2Bundle)15);
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.Info.Visual = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/ChestIcon_1.png").WaitForCompletion();
			}
			AkBank val3 = default(AkBank);
			if (Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoBody.prefab").WaitForCompletion().TryGetComponent<AkBank>(ref val3) && !Object.op_Implicit((Object)(object)val.GetComponent<AkBank>()))
			{
				SS2Util.CopyComponent<AkBank>(val3, val);
			}
			InteractableSpawnCard spawnCard = SS2Assets.LoadAsset<InteractableSpawnCard>("iscMimicEquip", (SS2Bundle)15);
			Helpers.AddNewInteractable(new DirectorCardHolder
			{
				Card = new DirectorCard
				{
					spawnCard = (SpawnCard)(object)spawnCard,
					selectionWeight = selectionWeight.Value,
					minimumStageCompletions = minimumStageCompletions.Value
				},
				InteractableCategory = (InteractableCategory)2
			});
		}

		private static bool IsEquipmentMimic(CharacterMaster master)
		{
			//IL_0008: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)master) && masterIndex != MasterIndex.none)
			{
				return master.masterIndex == masterIndex;
			}
			return false;
		}

		private static void StealEquipment(DamageReport report)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0075: 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_00d1: 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_00dd: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_012c: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected I4, but got Unknown
			//IL_00b9: Expected O, but got Unknown
			if (!DamageAPI.HasModdedDamageType(report.damageInfo, MimicEquip.StealItemDamageType) || !Object.op_Implicit((Object)(object)report.victimBody) || !Object.op_Implicit((Object)(object)report.victimBody.inventory) || !Object.op_Implicit((Object)(object)report.attackerBody))
			{
				return;
			}
			EquipmentIndex equipmentIndex = report.victimBody.inventory.GetEquipmentIndex();
			if ((int)equipmentIndex == -1)
			{
				return;
			}
			MimicEquipInventoryManager component = ((Component)report.attackerBody).GetComponent<MimicEquipInventoryManager>();
			if (Object.op_Implicit((Object)(object)component))
			{
				report.victimBody.inventory.RemoveEquipment(equipmentIndex);
				component.AddEquip(equipmentIndex);
				if (Object.op_Implicit((Object)(object)theftOrbEffect))
				{
					EffectData val = new EffectData
					{
						origin = report.victimBody.corePosition,
						genericFloat = 1.5f,
						genericUInt = (uint)(equipmentIndex + 1)
					};
					val.SetNetworkedObjectReference(report.attacker);
					EffectManager.SpawnEffect(theftOrbEffect, val, true);
				}
				PickupDef pickupDef = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(equipmentIndex));
				Chat.SendBroadcastChat((ChatMessageBase)new MimicTheftMessage
				{
					subjectAsCharacterBody = report.attackerBody,
					baseToken = "SS2_MIMIC_THEFT",
					pickupToken = pickupDef.nameToken,
					pickupColor = Color32.op_Implicit(pickupDef.baseColor),
					victimName = report.victimBody.GetDisplayName()
				});
			}
		}

		private static void TauntAfterKill(DamageReport report)
		{
			//IL_0059: 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_006a: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)report.victimBody) && report.victimBody.isPlayerControlled && IsEquipmentMimic(report.attackerMaster) && Object.op_Implicit((Object)(object)report.attackerMaster.bodyInstanceObject))
			{
				EntityStateMachine val = EntityStateMachine.FindByCustomName(report.attackerMaster.bodyInstanceObject, "Body");
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetNextState((EntityState)new MimicEquipChestRechest
					{
						taunting = true
					});
				}
				EntityStateMachine val2 = EntityStateMachine.FindByCustomName(report.attackerMaster.bodyInstanceObject, "Weapon");
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.SetNextStateToMain();
				}
			}
		}

		private static string GetBestBodyName(orig_GetBestBodyName orig, GameObject bodyObject)
		{
			MimicPingCorrecter val = default(MimicPingCorrecter);
			GenericDisplayNameProvider val2 = default(GenericDisplayNameProvider);
			if (Object.op_Implicit((Object)(object)bodyObject) && bodyObject.TryGetComponent<MimicPingCorrecter>(ref val) && val.isInteractable && bodyObject.TryGetComponent<GenericDisplayNameProvider>(ref val2))
			{
				return val2.GetDisplayName();
			}
			return orig.Invoke(bodyObject);
		}

		private static CharacterBody Respawn(orig_Respawn_Vector3_Quaternion_bool orig, CharacterMaster self, Vector3 footPosition, Quaternion rotation, bool wasRevivedMidStage)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_006a: Expected O, but got Unknown
			CharacterBody result = orig.Invoke(self, footPosition, rotation, wasRevivedMidStage);
			if (IsEquipmentMimic(self) && Object.op_Implicit((Object)(object)self.inventory) && (self.inventory.GetItemCountPermanent(Items.ExtraLifeConsumed) > 0 || self.inventory.GetItemCountPermanent(Items.ExtraLifeVoidConsumed) > 0))
			{
				EntityStateMachine val = EntityStateMachine.FindByCustomName(self.bodyInstanceObject, "Body");
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetNextState((EntityState)new MimicEquipChestActivateEnter());
				}
			}
			return result;
		}

		private static void GummyCloneSpawnState_OnEnter(orig_OnEnter orig, GummyCloneSpawnState self)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)((EntityState)self).characterBody) && ((EntityState)self).characterBody.baseNameToken == "SS2_MIMIC_EQUIP_BODY_NAME")
			{
				((EntityState)self).outer.SetNextState((EntityState)new MimicEquipChestInteractableIdle());
			}
		}
	}
}
namespace Starstorm2Lost.Content.Items
{
	public sealed class Augury : ContentPiece
	{
		public class AuguryBehavior : ItemBodyBehavior, IOnTakeDamageServerReceiver
		{
			private NetworkedBodyAttachment attachment;

			private EntityStateMachine stateMachine;

			private void Start()
			{
				attachment = Object.Instantiate<GameObject>(attachmentPrefab).GetComponent<NetworkedBodyAttachment>();
				attachment.AttachToGameObjectAndSpawn(((Component)body).gameObject, (string)null);
				stateMachine = ((Component)attachment).GetComponent<EntityStateMachine>();
				ref IOnTakeDamageServerReceiver[] onTakeDamageReceivers = ref body.healthComponent.onTakeDamageReceivers;
				IOnTakeDamageServerReceiver val = (IOnTakeDamageServerReceiver)(object)this;
				ArrayUtils.ArrayAppend<IOnTakeDamageServerReceiver>(ref onTakeDamageReceivers, ref val);
			}

			private void OnDestroy()
			{
				if (Object.op_Implicit((Object)(object)attachment))
				{
					Object.Destroy((Object)(object)((Component)attachment).gameObject);
				}
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent))
				{
					int num = Array.IndexOf(body.healthComponent.onTakeDamageReceivers, (IOnTakeDamageServerReceiver)(object)this);
					if (num >= 0)
					{
						ArrayUtils.ArrayRemoveAtAndResize<IOnTakeDamageServerReceiver>(ref body.healthComponent.onTakeDamageReceivers, num, 1);
					}
				}
			}

			public void OnTakeDamageServer(DamageReport report)
			{
				if (Object.op_Implicit((Object)(object)stateMachine) && stateMachine.state is AuguryIdle auguryIdle)
				{
					auguryIdle.OnTakeDamage(report);
				}
			}
		}

		public abstract class AuguryBaseState : BaseBodyAttachmentState
		{
			protected AuguryEffectController auguryEffect;

			public override void OnEnter()
			{
				((BaseBodyAttachmentState)this).OnEnter();
				ChildLocator component = ((EntityState)this).GetComponent<ChildLocator>();
				Transform val = (Object.op_Implicit((Object)(object)component) ? component.FindChild("Center") : null);
				auguryEffect = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<AuguryEffectController>() : null);
			}
		}

		public class AuguryIdle : AuguryBaseState
		{
			private float tankedDamage;

			private TeamIndex latestAttackerTeam = (TeamIndex)2;

			private Vector3 effectScale;

			public void OnTakeDamage(DamageReport report)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Invalid comparison between Unknown and I4
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				if (!report.isFallDamage)
				{
					tankedDamage += report.damageDealt;
					if ((int)report.attackerTeamIndex != -1)
					{
						latestAttackerTeam = report.attackerTeamIndex;
					}
				}
			}

			public override void Update()
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				((EntityState)this).Update();
				if (Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)this).attachedBody) && Object.op_Implicit((Object)(object)auguryEffect))
				{
					effectScale = Vector3.one * (tankedDamage / ((BaseBodyAttachmentState)this).attachedBody.maxHealth) / 2f * ((BaseBodyAttachmentState)this).attachedBody.bestFitRadius;
					auguryEffect.UpdateSize(effectScale);
				}
			}

			public override void FixedUpdate()
			{
				//IL_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				((EntityState)this).FixedUpdate();
				if (NetworkServer.active && Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)this).attachedBody) && tankedDamage > ((BaseBodyAttachmentState)this).attachedBody.maxHealth * damageThreshold.Value)
				{
					tankedDamage = 0f;
					((EntityState)this).outer.SetNextState((EntityState)(object)new AuguryPrepDetonation
					{
						scale = effectScale,
						detonatorTeam = latestAttackerTeam
					});
				}
			}

			public override void OnSerialize(NetworkWriter writer)
			{
				((EntityState)this).OnSerialize(writer);
				writer.Write(tankedDamage);
			}

			public override void OnDeserialize(NetworkReader reader)
			{
				((EntityState)this).OnDeserialize(reader);
				tankedDamage = reader.ReadSingle();
			}
		}

		public class AuguryPrepDetonation : AuguryBaseState
		{
			private const float baseDuration = 10f;

			private const float minDuration = 3f;

			public Vector3 scale;

			public TeamIndex detonatorTeam;

			private float duration;

			public override void OnEnter()
			{
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				base.OnEnter();
				float num = (Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)this).attachedBody) ? ((BaseBodyAttachmentState)this).attachedBody.attackSpeed : 1f);
				duration = Mathf.Clamp(10f / num, 3f, 10f);
				if (Object.op_Implicit((Object)(object)auguryEffect))
				{
					auguryEffect.BeginScale(scale, duration);
				}
			}

			public override void FixedUpdate()
			{
				//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)
				((EntityState)this).FixedUpdate();
				if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
				{
					((EntityState)this).outer.SetNextState((EntityState)(object)new AuguryDetonation
					{
						attackerTeam = detonatorTeam
					});
				}
			}

			public override void OnSerialize(NetworkWriter writer)
			{
				//IL_0009: 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)
				((EntityState)this).OnSerialize(writer);
				writer.Write(scale);
				writer.Write((byte)detonatorTeam);
			}

			public override void OnDeserialize(NetworkReader reader)
			{
				//IL_0009: 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_001b: Unknown result type (might be due to invalid IL or missing references)
				((EntityState)this).OnDeserialize(reader);
				scale = reader.ReadVector3();
				detonatorTeam = (TeamIndex)(sbyte)reader.ReadByte();
			}
		}

		public class AuguryDetonation : AuguryBaseState
		{
			private const float duration = 5f;

			public TeamIndex attackerTeam;

			public override void OnEnter()
			{
				//IL_002d: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: 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_00fb: Expected O, but got Unknown
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				base.OnEnter();
				if (NetworkServer.active && Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)this).attachedBody))
				{
					GameObject gameObject = ((Component)((BaseBodyAttachmentState)this).attachedBody).gameObject;
					foreach (TeamComponent item in new List<TeamComponent>(TeamComponent.GetTeamMembers(attackerTeam)))
					{
						CharacterBody val = (Object.op_Implicit((Object)(object)item) ? item.body : null);
						if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
						{
							if (val.isBoss || val.isChampion)
							{
								val.healthComponent.TakeDamage(new DamageInfo
								{
									attacker = gameObject,
									inflictor = gameObject,
									position = val.corePosition,
									damage = val.maxHealth * bossDamage.Value,
									damageColorIndex = (DamageColorIndex)7,
									damageType = DamageTypeCombo.op_Implicit((DamageType)2),
									procCoefficient = 0f
								});
							}
							else
							{
								val.healthComponent.Suicide(gameObject, gameObject, DamageTypeCombo.op_Implicit((DamageType)65536));
							}
						}
					}
				}
				if (Object.op_Implicit((Object)(object)auguryEffect))
				{
					auguryEffect.fadeOut = true;
				}
			}

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= 5f)
				{
					if (Object.op_Implicit((Object)(object)auguryEffect) && Object.op_Implicit((Object)(object)auguryEffect.explosionScaleCurve))
					{
						((Behaviour)auguryEffect.explosionScaleCurve).enabled = false;
					}
					((EntityState)this).outer.SetNextState((EntityState)(object)new AuguryRecharge());
				}
			}
		}

		public class AuguryRecharge : AuguryBaseState
		{
			private float rechargeDuration;

			public override void OnEnter()
			{
				base.OnEnter();
				float num = (Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)this).attachedBody) ? ((BaseBodyAttachmentState)this).attachedBody.attackSpeed : 1f);
				rechargeDuration = Mathf.Clamp(rechargeTime.Value / num, rechargeTime.Value * 0.5f, rechargeTime.Value * 1.5f);
				if (Object.op_Implicit((Object)(object)auguryEffect))
				{
					auguryEffect.RestoreDefaults();
				}
			}

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > rechargeDuration)
				{
					((EntityState)this).outer.SetNextState((EntityState)(object)new AuguryIdle());
				}
			}
		}

		private const string NemesisEnforcerBossBodyName = "NemesisEnforcerBossBody";

		public static ItemDef itemDef;

		internal static GameObject attachmentPrefab;

		internal static ConfigEntry<float> damageThreshold;

		internal static ConfigEntry<float> bossDamage;

		internal static ConfigEntry<float> rechargeTime;

		private static BodyIndex nemesisEnforcerBossIndex = (BodyIndex)(-1);

		public override string Category => "Items";

		public override string Name => "Augury";

		public override bool IsAvailable => ModCompat.EnforcerInstalled;

		protected override void BindConfig()
		{
			damageThreshold = LostConfig.Bind(base.ConfigSection, "Damage Threshold", 6f, "Damage you must take before the blackout, as a multiple of max health.");
			bossDamage = LostConfig.Bind(base.ConfigSection, "Boss Damage", 0.5f, "Fraction of max health bosses lose to the blackout instead of dying.");
			rechargeTime = LostConfig.Bind(base.ConfigSection, "Recharge Time", 60f, "Seconds before Augury starts charging again, reduced by attack speed.");
			TokenFormatter.Add("SS2LOST_ITEM_AUGURY_DESC", () => new object[2]
			{
				damageThreshold.Value * 100f,
				bossDamage.Value * 100f
			});
		}

		protected override void Hook()
		{
			ItemBodyBehavior.Register<AuguryBehavior>(() => itemDef);
			GlobalEventManager.onCharacterDeathServer += DropFromNemesisEnforcer;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//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)
				nemesisEnforcerBossIndex = BodyCatalog.FindBodyIndex("NemesisEnforcerBossBody");
			});
		}

		public override void LoadContent(ContentPack contentPack)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			itemDef = ContentPiece.CloneSS2ItemDef("Augury", (SS2Bundle)15, "SS2Lost_Augury");
			itemDef.descriptionToken = "SS2LOST_ITEM_AUGURY_DESC";
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
			attachmentPrefab = PrefabAPI.InstantiateClone(SS2Assets.LoadAsset<GameObject>("AuguryBodyAttachment", (SS2Bundle)15), "SS2LostAuguryBodyAttachment", true);
			EntityStateMachine component = attachmentPrefab.GetComponent<EntityStateMachine>();
			component.initialStateType = new SerializableEntityStateType(typeof(AuguryIdle));
			component.mainStateType = new SerializableEntityStateType(typeof(AuguryIdle));
			contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { attachmentPrefab });
			contentPack.entityStateTypes.Add(new Type[4]
			{
				typeof(AuguryIdle),
				typeof(AuguryPrepDetonation),
				typeof(AuguryDetonation),
				typeof(AuguryRecharge)
			});
		}

		private static void DropFromNemesisEnforcer(DamageReport report)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			if (Object.op_Implicit((Object)(object)report.victimBody) && (int)nemesisEnforcerBossIndex != -1 && report.victimBody.bodyIndex == nemesisEnforcerBossIndex)
			{
				PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(itemDef.itemIndex)), report.victimBody.corePosition, Vector3.up * 20f, false);
			}
		}
	}
	public sealed class BabyToys : ContentPiece
	{
		public class BabyToysTracker : MonoBehaviour
		{
			public long experienceOffset;

			public int keptLevels;

			private int pendingLevels;

			internal uint lastAppliedLevel;

			private CharacterMaster master;

			public ulong AdjustedExperience
			{
				get
				{
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					if (!Object.op_Implicit((Object)(object)TeamManager.instance))
					{
						return 0uL;
					}
					return (ulong)Math.Max((long)TeamManager.instance.GetTeamExperience(master.teamIndex) + experienceOffset, 0L);
				}
			}

			public uint Level => FindLevelForExperience(AdjustedExperience);

			private void Awake()
			{
				master = ((Component)this).GetComponent<CharacterMaster>();
			}

			private void FixedUpdate()
			{
				if (experienceOffset != 0L && master.hasBody && Level != lastAppliedLevel)
				{
					master.GetBody().MarkAllStatsDirty();
				}
			}

			internal void ServerSetLevelReduction(int targetReduction)
			{
				int num = keptLevels + pendingLevels;
				if (targetReduction > num)
				{
					pendingLevels += targetReduction - num;
					ServerTryRemovePendingLevels();
				}
				else if (targetReduction < num)
				{
					int num2 = num - targetReduction;
					int num3 = Math.Min(pendingLevels, num2);
					pendingLevels -= num3;
					num2 -= num3;
					if (num2 > 0)
					{
						int num4 = Math.Min(num2, keptLevels);
						ShiftLevels(num4);
						keptLevels -= num4;
						ServerSync();
					}
				}
			}

			internal void ServerTryRemovePendingLevels()
			{
				if (pendingLevels > 0)
				{
					int num = Math.Min(pendingLevels, (int)(Level - 1));
					if (num > 0)
					{
						ShiftLevels(-num);
						keptLevels += num;
						pendingLevels -= num;
						ServerSync();
					}
				}
			}

			private void ShiftLevels(int levelDelta)
			{
				ulong adjustedExperience = AdjustedExperience;
				uint num = FindLevelForExperience(adjustedExperience);
				ulong experienceForLevel = TeamManager.GetExperienceForLevel(num);
				ulong experienceForLevel2 = TeamManager.GetExperienceForLevel(num + 1);
				double num2 = ((experienceForLevel2 > experienceForLevel) ? ((double)(adjustedExperience - experienceForLevel) / (double)(experienceForLevel2 - experienceForLevel)) : 0.0);
				int num3 = Math.Max(1, (int)num + levelDelta);
				ulong experienceForLevel3 = TeamManager.GetExperienceForLevel((uint)num3);
				ulong experienceForLevel4 = TeamManager.GetExperienceForLevel((uint)(num3 + 1));
				ulong num4 = experienceForLevel3 + (ulong)Math.Ceiling((double)(experienceForLevel4 - experienceForLevel3) * num2);
				experienceOffset = Math.Min(experienceOffset + (long)(num4 - adjustedExperience), 0L);
				if (master.hasBody)
				{
					master.GetBody().MarkAllStatsDirty();
				}
			}

			private void ServerSync()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					NetworkIdentity component = ((Component)master).GetComponent<NetworkIdentity>();
					if (Object.op_Implicit((Object)(object)component))
					{
						NetMessageExtensions.Send((INetMessage)(object)new SyncBabyToys(component.netId, experienceOffset, keptLevels), (NetworkDestination)1);
					}
				}
			}

			public static uint FindLevelForExperience(ulong experience)
			{
				uint num = 1u;
				while (true)
				{
					ulong experienceForLevel = TeamManager.GetExperienceForLevel(num + 1);
					if (experienceForLevel > experience || experienceForLevel <= TeamManager.GetExperienceForLevel(num))
					{
						break;
					}
					num++;
				}
				return num;
			}
		}

		public class SyncBabyToys : INetMessage, ISerializableObject
		{
			private NetworkInstanceId masterId;

			private long experienceOffset;

			private int keptLevels;

			public SyncBabyToys()
			{
			}

			public SyncBabyToys(NetworkInstanceId masterId, long experienceOffset, int keptLevels)
			{
				//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)
				this.masterId = masterId;
				this.experienceOffset = experienceOffset;
				this.keptLevels = keptLevels;
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(masterId);
				writer.Write(experienceOffset);
				writer.Write(keptLevels);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				masterId = reader.ReadNetworkId();
				experienceOffset = reader.ReadInt64();
				keptLevels = reader.ReadInt32();
			}

			public void OnReceived()
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					return;
				}
				GameObject val = Util.FindNetworkObject(masterId);
				if (Object.op_Implicit((Object)(object)val))
				{
					BabyToysTracker babyToysTracker = val.GetComponent<BabyToysTracker>();
					if (!Object.op_Implicit((Object)(object)babyToysTracker))
					{
						babyToysTracker = val.AddComponent<BabyToysTracker>();
					}
					babyToysTracker.experienceOffset = experienceOffset;
					babyToysTracker.keptLevels = keptLevels;
					CharacterMaster component = val.GetComponent<CharacterMaster>();
					if (Object.op_Implicit((Object)(object)component) && component.hasBody)
					{
						component.GetBody().MarkAllStatsDirty();
					}
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Inventory> <0>__OnInventoryChanged;

			public static Action<CharacterBody> <1>__OnCharacterLevelUp;

			public static Manipulator <2>__ApplyExperienceOffset;

			public static StatHookEventHandler <3>__AddKeptLevels;

			public static hook_Update <4>__ExpBar_Update;
		}

		public static ItemDef itemDef;

		internal static ConfigEntry<int> levelsPerStack;

		public override string Category => "Items";

		public override string Name => "Baby's Toys";

		protected override void BindConfig()
		{
			levelsPerStack = LostConfig.Bind(base.ConfigSection, "Levels Per Stack", 3, "Levels lost per stack. The stats of lost levels are kept.");
			TokenFormatter.Add("SS2_ITEM_BABYTOYS_PICKUP", () => new object[1] { levelsPerStack.Value });
			TokenFormatter.Add("SS2_ITEM_BABYTOYS_DESC", () => new object[1] { levelsPerStack.Value });
		}

		protected override void Hook()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//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_0081: Expected O, but got Unknown
			//IL_0096: 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_00a1: Expected O, but got Unknown
			NetworkingAPI.RegisterMessageType<SyncBabyToys>();
			Inventory.onInventoryChangedGlobal += OnInventoryChanged;
			GlobalEventManager.onCharacterLevelUp += OnCharacterLevelUp;
			object obj = <>O.<2>__ApplyExperienceOffset;
			if (obj == null)
			{
				Manipulator val = ApplyExperienceOffset;
				<>O.<2>__ApplyExperienceOffset = val;
				obj = (object)val;
			}
			CharacterBody.RecalculateStats += (Manipulator)obj;
			object obj2 = <>O.<3>__AddKeptLevels;
			if (obj2 == null)
			{
				StatHookEventHandler val2 = AddKeptLevels;
				<>O.<3>__AddKeptLevels = val2;
				obj2 = (object)val2;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj2;
			object obj3 = <>O.<4>__ExpBar_Update;
			if (obj3 == null)
			{
				hook_Update val3 = ExpBar_Update;
				<>O.<4>__ExpBar_Update = val3;
				obj3 = (object)val3;
			}
			ExpBar.Update += (hook_Update)obj3;
		}

		public override void LoadContent(ContentPack contentPack)
		{
			itemDef = ContentPiece.CloneSS2ItemDef("BabyToys", (SS2Bundle)11, "SS2Lost_BabyToys");
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
		}

		private static void OnInventoryChanged(Inventory inventory)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)itemDef))
			{
				return;
			}
			CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			int itemCountEffective = inventory.GetItemCountEffective(itemDef);
			BabyToysTracker babyToysTracker = ((Component)component).GetComponent<BabyToysTracker>();
			if (!Object.op_Implicit((Object)(object)babyToysTracker))
			{
				if (itemCountEffective <= 0)
				{
					return;
				}
				babyToysTracker = ((Component)component).gameObject.AddComponent<BabyToysTracker>();
			}
			babyToysTracker.ServerSetLevelReduction(itemCountEffective * levelsPerStack.Value);
		}

		private static void OnCharacterLevelUp(CharacterBody body)
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master))
			{
				BabyToysTracker component = ((Component)body.master).GetComponent<BabyToysTracker>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ServerTryRemovePendingLevels();
				}
			}
		}

		private static void ApplyExperienceOffset(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<TeamManager>(x, "GetTeamLevel")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<uint, CharacterBody, uint>>((Func<uint, CharacterBody, uint>)delegate(uint teamLevel, CharacterBody body)
				{
					BabyToysTracker babyToysTracker = (Object.op_Implicit((Object)(object)body.master) ? ((Component)body.master).GetComponent<BabyToysTracker>() : null);
					return (!Object.op_Implicit((Object)(object)babyToysTracker) || babyToysTracker.experienceOffset == 0L) ? teamLevel : (babyToysTracker.lastAppliedLevel = babyToysTracker.Level);
				});
			}
			else
			{
				Log.Error("Baby's Toys: could not find the team level lookup in CharacterBody.RecalculateStats, levels will not be reduced.", "D:\\Games\\LostItems\\starstorm2lost\\Starstorm2Lost\\Content\\Items\\BabyToys.cs", "ApplyExperienceOffset", 110);
			}
		}

		private static void AddKeptLevels(CharacterBody body, StatHookEventArgs args)
		{
			BabyToysTracker babyToysTracker = (Object.op_Implicit((Object)(object)body.master) ? ((Component)body.master).GetComponent<BabyToysTracker>() : null);
			if (Object.op_Implicit((Object)(object)babyToysTracker) && babyToysTracker.keptLevels > 0)
			{
				args.levelFlatAdd += (float)babyToysTracker.keptLevels;
			}
		}

		private static void ExpBar_Update(orig_Update orig, ExpBar self)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self.source) && Object.op_Implicit((Object)(object)self.fillRectTransform))
			{
				BabyToysTracker component = ((Component)self.source).GetComponent<BabyToysTracker>();
				if (Object.op_Implicit((Object)(object)component) && component.experienceOffset != 0L)
				{
					ulong adjustedExperience = component.AdjustedExperience;
					uint num = BabyToysTracker.FindLevelForExperience(adjustedExperience);
					ulong experienceForLevel = TeamManager.GetExperienceForLevel(num);
					ulong experienceForLevel2 = TeamManager.GetExperienceForLevel(num + 1);
					float num2 = ((experienceForLevel2 > experienceForLevel) ? ((float)(adjustedExperience - experienceForLevel) / (float)(experienceForLevel2 - experienceForLevel)) : 1f);
					self.fillRectTransform.anchorMax = new Vector2(num2, 1f);
				}
			}
		}
	}
	public sealed class Balloon : ContentPiece
	{
		public class BalloonBehavior : ItemBodyBehavior
		{
			private void FixedUpdate()
			{
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				CharacterMotor characterMotor = body.characterMotor;
				if (body.hasEffectiveAuthority && Object.op_Implicit((Object)(object)characterMotor) && !characterMotor.isGrounded && Object.op_Implicit((Object)(object)body.inputBank) && body.inputBank.jump.down && !(characterMotor.velocity.y > 0f))
				{
					float num = Mathf.Min(gravityReduction.Value + gravityReductionPerStack.Value * (float)(stack - 1), maxGravityReduction.Value);
					characterMotor.velocity.y -= Physics.gravity.y * num * Time.fixedDeltaTime;
				}
			}
		}

		public static ItemDef itemDef;

		private static ConfigEntry<float> gravityReduction;

		private static ConfigEntry<float> gravityReductionPerStack;

		private static ConfigEntry<float> maxGravityReduction;

		public override string Category => "Items";

		public override string Name => "Balloon";

		public override bool EnabledByDefault => false;

		protected override void BindConfig()
		{
			gravityReduction = LostConfig.Bind(base.ConfigSection, "Gravity Reduction", 0.5f, "Fraction of gravity removed while holding jump with one stack.");
			gravityReductionPerStack = LostConfig.Bind(base.ConfigSection, "Gravity Reduction Per Stack", 0.1f, "Fraction of gravity removed by each additional stack.");
			maxGravityReduction = LostConfig.Bind(base.ConfigSection, "Max Gravity Reduction", 0.85f, "Cap on the gravity reduction, so stacking never makes you float upward.");
			TokenFormatter.Add("SS2LOST_ITEM_BALLOON_DESC", () => new object[2]
			{
				gravityReduction.Value * 100f,
				gravityReductionPerStack.Value * 100f
			});
		}

		protected override void Hook()
		{
			ItemBodyBehavior.Register<BalloonBehavior>(() => itemDef, server: true, client: true);
		}

		public override void LoadContent(ContentPack contentPack)
		{
			itemDef = ContentPiece.CloneSS2ItemDef("Balloon", (SS2Bundle)15, "SS2Lost_Balloon");
			ContentPiece.SetTokens(itemDef, "SS2LOST_ITEM_BALLOON");
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
		}
	}
	public sealed class BaneFlask : ContentPiece
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<DamageReport> <0>__OnServerDamageDealt;

			public static Action<DamageReport> <1>__OnCharacterDeath;

			public static CustomDotBehaviour <2>__ScaleWithDebuffs;
		}

		public static ItemDef itemDef;

		public static BuffDef baneBuff;

		public static DotIndex baneDotIndex;

		private static ConfigEntry<float> baneDamage;

		private static ConfigEntry<float> damagePerDebuff;

		private static ConfigEntry<float> baneDuration;

		private static ConfigEntry<float> spreadRadius;

		private static GameObject spreadEffect;

		private static GameObject debuffEffect;

		private static GameObject goopEffect;

		public override string Category => "Items";

		public override string Name => "Bane Flask";

		public override bool EnabledByDefault => false;

		protected override void BindConfig()
		{
			baneDamage = LostConfig.Bind(base.ConfigSection, "Bane Damage", 0.3f, "Bane damage per second per stack. (1 = 100% damage)");
			damagePerDebuff = LostConfig.Bind(base.ConfigSection, "Damage Per Debuff", 0.25f, "Extra Bane damage for every other debuff on the target. (0.25 = +25% each)");
			baneDuration = LostConfig.Bind(base.ConfigSection, "Bane Duration", 5f, "Duration of Bane, in seconds.");
			spreadRadius = LostConfig.Bind(base.ConfigSection, "Spread Radius", 15f, "Radius debuffs spread to on kill, in meters. For reference, Gasoline is 12m.");
			TokenFormatter.Add("SS2LOST_ITEM_BANEFLASK_DESC", () => new object[3]
			{
				baneDamage.Value * 100f,
				damagePerDebuff.Value * 100f,
				spreadRadius.Value
			});
		}

		protected override void Hook()
		{
			GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
			GlobalEventManager.onDeathProcServer += OnCharacterDeath;
		}

		public override void LoadContent(ContentPack contentPack)
		{
			//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_00c5: 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_00d0: Expected O, but got Unknown
			itemDef = ContentPiece.CloneSS2ItemDef("BaneFlask", (SS2Bundle)11, "SS2Lost_BaneFlask");
			itemDef.descriptionToken = "SS2LOST_ITEM_BANEFLASK_DESC";
			itemDef.loreToken = "SS2LOST_ITEM_BANEFLASK_LORE";
			ContentPiece.SetIcon(itemDef, LostAssets.MysteryIcon);
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
			baneBuff = Object.Instantiate<BuffDef>(SS2Assets.LoadAsset<BuffDef>("BuffBane", (SS2Bundle)11));
			((Object)baneBuff).name = "SS2Lost_BuffBane";
			contentPack.buffDefs.Add((BuffDef[])(object)new BuffDef[1] { baneBuff });
			float num = baneDamage.Value * 0.5f;
			BuffDef obj = baneBuff;
			object obj2 = <>O.<2>__ScaleWithDebuffs;
			if (obj2 == null)
			{
				CustomDotBehaviour val = ScaleWithDebuffs;
				<>O.<2>__ScaleWithDebuffs = val;
				obj2 = (object)val;
			}
			baneDotIndex = DotAPI.RegisterDotDef(0.5f, num, (DamageColorIndex)4, obj, (CustomDotBehaviour)obj2, (CustomDotVisual)null);
			spreadEffect = SS2Assets.LoadAsset<GameObject>("BaneGraysparkVFX", (SS2Bundle)11);
			debuffEffect = SS2Assets.LoadAsset<GameObject>("BaneGrayVFX", (SS2Bundle)11);
			goopEffect = SS2Assets.LoadAsset<GameObject>("BaneGrayGoop", (SS2Bundle)11);
		}

		private static void ScaleWithDebuffs(DotController self, DotStack dotStack)
		{
			CharacterBody victimBody = self.victimBody;
			if (!Object.op_Implicit((Object)(object)victimBody))
			{
				return;
			}
			int num = 0;
			BuffIndex[] activeBuffsList = victimBody.activeBuffsList;
			for (int i = 0; i < activeBuffsList.Length; i++)
			{
				BuffDef buffDef = BuffCatalog.GetBuffDef(activeBuffsList[i]);
				if (Object.op_Implicit((Object)(object)buffDef) && buffDef.isDebuff && (Object)(object)buffDef != (Object)(object)baneBuff)
				{
					num++;
				}
			}
			dotStack.damage *= 1f + damagePerDebuff.Value * (float)num;
		}

		private static void OnServerDamageDealt(DamageReport report)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!(report.damageInfo.procCoefficient <= 0f) && Object.op_Implicit((Object)(object)report.attackerBody) && Object.op_Implicit((Object)(object)report.attackerBody.inventory) && Object.op_Implicit((Object)(object)report.victimBody))
			{
				int itemCountEffective = report.attackerBody.inventory.GetItemCountEffective(itemDef);
				if (itemCountEffective > 0 && !report.victimBody.HasBuff(baneBuff))
				{
					InflictDotInfo val = new InflictDotInfo
					{
						attackerObject = report.attacker,
						victimObject = ((Component)report.victim).gameObject,
						dotIndex = baneDotIndex,
						duration = baneDuration.Value,
						damageMultiplier = itemCountEffective
					};
					DotController.InflictDot(ref val);
				}
			}
		}

		private static void OnCharacterDeath(DamageReport report)
		{
			//IL_007b: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: 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_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Expected O, but got Unknown
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: 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_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Expected O, but got Unknown
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)report.attackerBody) || !Object.op_Implicit((Object)(object)report.attackerBody.inventory) || !Object.op_Implicit((Object)(object)report.victimBody) || report.attackerBody.inventory.GetItemCountEffective(itemDef) <= 0)
			{
				return;
			}
			CharacterBody victimBody = report.victimBody;
			CharacterBody attackerBody = report.attackerBody;
			Dictionary<BuffIndex, float> dictionary = new Dictionary<BuffIndex, float>();
			foreach (TimedBuff timedBuff in victimBody.timedBuffs)
			{
				BuffDef buffDef = BuffCatalog.GetBuffDef(timedBuff.buffIndex);
				if (Object.op_Implicit((Object)(object)buffDef) && buffDef.isDebuff && (!dictionary.TryGetValue(timedBuff.buffIndex, out var value) || value < timedBuff.timer))
				{
					dictionary[timedBuff.buffIndex] = timedBuff.timer;
				}
			}
			Dictionary<DotIndex, DotStack> dictionary2 = new Dictionary<DotIndex, DotStack>();
			DotController val = DotController.FindDotController(((Component)victimBody).gameObject);
			if (Object.op_Implicit((Object)(object)val))
			{
				foreach (DotStack dotStack in val.dotStackList)
				{
					if (!dictionary2.TryGetValue(dotStack.dotIndex, out var value2) || value2.timer < dotStack.timer)
					{
						dictionary2[dotStack.dotIndex] = dotStack;
					}
				}
			}
			List<BuffIndex> list = new List<BuffIndex>();
			BuffIndex[] activeBuffsList = victimBody.activeBuffsList;
			foreach (BuffIndex val2 in activeBuffsList)
			{
				BuffDef buffDef2 = BuffCatalog.GetBuffDef(val2);
				if (Object.op_Implicit((Object)(object)buffDef2) && buffDef2.isDebuff && !dictionary.ContainsKey(val2) && !((Object)(object)buffDef2 == (Object)(object)baneBuff) && !IsDotBuff(dictionary2, buffDef2))
				{
					list.Add(val2);
				}
			}
			if (dictionary.Count == 0 && dictionary2.Count == 0 && list.Count == 0)
			{
				return;
			}
			SphereSearch val3 = new SphereSearch
			{
				origin = victimBody.corePosition,
				mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask,
				radius = spreadRadius.Value + victimBody.radius
			};
			List<HurtBox> list2 = new List<HurtBox>();
			val3.RefreshCandidates();
			val3.FilterCandidatesByHurtBoxTeam(TeamMask.GetUnprotectedTeams(attackerBody.teamComponent.teamIndex));
			val3.FilterCandidatesByDistinctHurtBoxEntities();
			val3.GetHurtBoxes(list2);
			foreach (HurtBox item in list2)
			{
				HealthComponent healthComponent = item.healthComponent;
				if (!Object.op_Implicit((Object)(object)healthComponent) || !healthComponent.alive || (Object)(object)healthComponent.body == (Object)(object)victimBody)
				{
					continue;
				}
				foreach (KeyValuePair<BuffIndex, float> item2 in dictionary)
				{
					healthComponent.body.AddTimedBuff(item2.Key, item2.Value);
				}
				foreach (BuffIndex item3 in list)
				{
					healthComponent.body.AddBuff(item3);
				}
				foreach (DotStack value3 in dictionary2.Values)
				{
					float num = attackerBody.damage * value3.dotDef.damageCoefficient;
					InflictDotInfo val4 = new InflictDotInfo
					{
						attackerObject = ((Component)attackerBody).gameObject,
						victimObject = ((Component)healthComponent).gameObject,
						dotIndex = value3.dotIndex,
						duration = value3.timer,
						damageMultiplier = ((num > 0f) ? (value3.damage / num) : 1f)
					};
					DotController.InflictDot(ref val4);
				}
				if (Object.op_Implicit((Object)(object)debuffEffect))
				{
					EffectManager.SpawnEffect(debuffEffect, new EffectData
					{
						origin = healthComponent.body.corePosition,
						scale = 1f
					}, true);
				}
			}
			if (Object.op_Implicit((Object)(object)spreadEffect))
			{
				EffectManager.SpawnEffect(spreadEffect, new EffectData
				{
					origin = victimBody.corePosition,
					scale = 1f
				}, true);
			}
			if (Object.op_Implicit((Object)(object)goopEffect) && Object.op_Implicit((Object)(object)victimBody.characterMotor) && victimBody.characterMotor.isGrounded)
			{
				EffectManager.SpawnEffect(goopEffect, new EffectData
				{
					origin = victimBody.footPosition,
					scale = 1f
				}, true);
			}
		}

		private static bool IsDotBuff(Dictionary<DotIndex, DotStack> dots, BuffDef buffDef)
		{
			foreach (DotStack value in dots.Values)
			{
				if ((Object)(object)value.dotDef.associatedBuff == (Object)(object)buffDef)
				{
					return true;
				}
			}
			return false;
		}
	}
	public sealed class ChucklingFungus : ContentPiece
	{
		public class ChucklingFungusBehavior : ItemBodyBehavior
		{
			private GameObject wardInstance;

			private void FixedUpdate()
			{
				//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_005b: Unknown result type (might be due to invalid IL or missing references)
				if (body.notMovingStopwatch > 1f)
				{
					if (!Object.op_Implicit((Object)(object)wardInstance))
					{
						wardInstance = Object.Instantiate<GameObject>(wardPrefab, body.corePosition, Quaternion.identity);
						wardInstance.GetComponent<TeamFilter>().teamIndex = body.teamComponent.teamIndex;
						HealingWard component = wardInstance.GetComponent<HealingWard>();
						component.interval = 0.25f;
						component.healFraction = (healPerSecond.Value + healPerSecondPerStack.Value * (float)(stack - 1)) * component.interval;
						component.healPoints = 0f;
						component.Networkradius = body.radius + radius.Value + radiusPerStack.Value * (float)(stack - 1);
						NetworkServer.Spawn(wardInstance);
					}
				}
				else
				{
					DestroyWard();
				}
			}

			private void OnDisable()
			{
				DestroyWard();
			}

			private void DestroyWard()
			{
				if (Object.op_Implicit((Object)(object)wardInstance))
				{
					Object.Destroy((Object)(object)wardInstance);
					wardInstance = null;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Init <0>__AddCorruption;
		}

		private const string SS2UDormantFungusName = "SS2U_Dungus";

		public static ItemDef itemDef;

		private static ConfigEntry<float> healPerSecond;

		private static ConfigEntry<float> healPerSecondPerStack;

		private static ConfigEntry<float> radius;

		private static ConfigEntry<float> radiusPerStack;

		private static GameObject wardPrefab;

		public override string Category => "Items";

		public override string Name => "Chuckling Fungus";

		public override bool EnabledByDefault => false;

		protected override void BindConfig()
		{
			healPerSecond = LostConfig.Bind(base.ConfigSection, "Heal Per Second", 0.055f, "Fraction of max health healed per second with one stack.");
			healPerSecondPerStack = LostConfig.Bind(base.ConfigSection, "Heal Per Second Per Stack", 0.0275f, "Fraction of max health healed per second added by each additional stack.");
			radius = LostConfig.Bind(base.ConfigSection, "Radius", 3f, "Radius of the healing zone with one stack, in meters (added to your body size).");
			radiusPerStack = LostConfig.Bind(base.ConfigSection, "Radius Per Stack", 1.5f, "Radius added by each additional stack, in meters.");
		}

		protected override void Hook()
		{
			//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_0041: Expected O, but got Unknown
			ItemBodyBehavior.Register<ChucklingFungusBehavior>(() => itemDef);
			object obj = <>O.<0>__AddCorruption;
			if (obj == null)
			{
				hook_Init val = AddCorruption;
				<>O.<0>__AddCorruption = val;
				obj = (object)val;
			}
			ContagiousItemManager.Init += (hook_Init)obj;
		}

		public override void LoadContent(ContentPack contentPack)
		{
			itemDef = ContentPiece.CloneSS2ItemDef("ChucklingFungus", (SS2Bundle)11, "SS2Lost_ChucklingFungus");
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
			wardPrefab = SS2Assets.LoadAsset<GameObject>("ChungusWard", (SS2Bundle)11);
			contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { wardPrefab });
		}

		private static void AddCorruption(orig_Init orig)
		{
			//IL_0005: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex("SS2U_Dungus"));
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)itemDef))
			{
				Pair val2 = new Pair
				{
					itemDef1 = val,
					itemDef2 = itemDef
				};
				Pair[] value = ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem];
				ArrayUtils.ArrayAppend<Pair>(ref value, ref val2);
				ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem] = value;
			}
			else if (ModCompat.SS2UInstalled)
			{
				Log.Warning("Starstorm 2 Unofficial's Dormant Fungus (SS2U_Dungus) isn't loaded, so Chuckling Fungus won't corrupt anything. Set \"SS2 Official - Autoconfig\" to false in SS2U's config to keep it.", "D:\\Games\\LostItems\\starstorm2lost\\Starstorm2Lost\\Content\\Items\\ChucklingFungus.cs", "AddCorruption", 68);
			}
			orig.Invoke();
		}
	}
	public sealed class HottestSauce : ContentPiece
	{
		public static ItemDef itemDef;

		private static ConfigEntry<float> radius;

		private static ConfigEntry<float> burnDuration;

		private static ConfigEntry<float> impactDamage;

		private static ConfigEntry<float> burnDamage;

		private static ConfigEntry<float> burnDamagePerStack;

		private static GameObject explosionEffect;

		public override string Category => "Items";

		public override string Name => "Hottest Sauce";

		protected override void BindConfig()
		{
			radius = LostConfig.Bind(base.ConfigSection, "Radius", 30f, "Radius around you that gets ignited, in meters.");
			burnDuration = LostConfig.Bind(base.ConfigSection, "Burn Duration", 6f, "Duration of the burn, in seconds.");
			impactDamage = LostConfig.Bind(base.ConfigSection, "Impact Damage", 1.5f, "Instant damage dealt to every enemy hit. (1 = 100% base damage)");
			burnDamage = LostConfig.Bind(base.ConfigSection, "Burn Damage", 1f, "Burn damage per second with one stack. (1 = 100% damage)");
			burnDamagePerStack = LostConfig.Bind(base.ConfigSection, "Burn Damage Per Stack", 0.5f, "Burn damage per second added by each additional stack.");
			TokenFormatter.Add("SS2_ITEM_HOTTESTSAUCE_DESC", () => new object[2] { radius.Value, burnDuration.Value });
		}

		protected override void Hook()
		{
			EquipmentSlot.onServerEquipmentActivated += OnServerEquipmentActivated;
		}

		public override void LoadContent(ContentPack contentPack)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			itemDef = ContentPiece.CloneSS2ItemDef("HottestSauce", (SS2Bundle)15, "SS2Lost_HottestSauce");
			contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { itemDef });
			explosionEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_IgniteOnKill.IgniteExplosionVFX_prefab).WaitForCompletion();
		}

		private static void OnServerEquipmentActivated(EquipmentSlot slot, EquipmentIndex equipmentIndex)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_009f: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_0051: 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_006d: Expected O, but got Unknown
			//IL_0125: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0154: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody characterBody = slot.characterBody;
			if (!Object.op_Implicit((Object)(object)characterBody) || !Object.op_Implicit((Object)(object)characterBody.inventory))
			{
				return;
			}
			int itemCountEffective = characterBody.inventory.GetItemCountEffective(itemDef);
			if (itemCountEffective <= 0)
			{
				return;
			}
			Vector3 corePosition = characterBody.corePosition;
			if (Object.op_Implicit((Object)(object)explosionEffect))
			{
				EffectManager.SpawnEffect(explosionEffect, new EffectData
				{
					origin = corePosition,
					scale = radius.Value
				}, true);
			}
			SphereSearch val = new SphereSearch
			{
				origin = corePosition,
				mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask,
				radius = radius.Value
			};
			List<HurtBox> list = new List<HurtBox>();
			val.RefreshCandidates();
			val.FilterCandidatesByHurtBoxTeam(TeamMask.GetUnprotectedTeams(characterBody.teamComponent.teamIndex));
			val.FilterCandidatesByDistinctHurtBoxEntities();
			val.GetHurtBoxes(list);
			float damageMultiplier = burnDamage.Value + burnDamagePerStack.Value * (float)(itemCountEffective - 1);
			foreach (HurtBox item in list)
			{
				HealthComponent healthComponent = item.healthComponent;
				if (Object.op_Implicit((Object)(object)healthComponent) && !((Object)(object)healthComponent == (Object)(object)characterBody.healthComponent))
				{
					healthComponent.TakeDamage(new DamageInfo
					{
						attacker = ((Component)characterBody).gameObject,
						inflictor = ((Component)characterBody).gameObject,
						position = ((Component)item).transform.position,
						crit = characterBody.RollCrit(),
						damage = characterBody.damage * impactDamage.Value,
						damageColorIndex = (DamageColorIndex)3,
						damageType = DamageTypeCombo.op_Implicit((DamageType)0),
						procCoefficient = 0f
					});
					InflictDotInfo val2 = new InflictDotInfo
					{
						attackerObject = ((Component)characterBody).gameObject,
						victimObject = ((Component)healthComponent).gameObject,
						dotIndex = (DotIndex)1,
						duration = burnDuration.Value,
						damageMultiplier = damageMultiplier
					};
					StrengthenBurnUtils.CheckDotForUpgrade(characterBody.inventory, ref val2);
					DotController.InflictDot(ref val2);
				}
			}
		}
	}
	public sealed class Nanobots : ContentPiece
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_BeginScrapping_UniquePickup <0>__ScrapperController_BeginScrapping;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<object[]> <>9__10_0;

			public static StatHookEventHandler <>9__11_0;

			internal object[] <BindConfig>b__10_0()
			{
				return new object[1] { armorPerStack.Value };
			}

			internal void <Hook>b__11_0(CharacterBody body, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)body.inventory))
				{
					args.armorAdd += armorPerStack.Value * (float)body.inventory.GetItemCountEffective(itemDef);
				}
			}
		}

		public static ItemDef itemDef;

		private static ConfigEntry<float> armorPerStack;

		private static ConfigEntry<bool> disassembleScrappers;

		private static GameObject disassembleEffect;

		public override string Category => "Items";

		public override string Name => "Nanobots";

		public override bool EnabledByDefault => false;

		protected overr