Decompiled source of Admiral v3.0.0

Admiral.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
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.Captain.Weapon;
using EntityStates.CaptainSupplyDrop;
using IL.RoR2;
using KinematicCharacterController;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.EntityStates;
using On.EntityStates.Captain.Weapon;
using On.RoR2;
using On.RoR2.Networking;
using On.RoR2.Orbs;
using On.RoR2.Projectile;
using On.RoR2.Skills;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.Hologram;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.Stats;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Admiral")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8bc69138c39bdbf02f9c915547e7ffca95080f4d")]
[assembly: AssemblyProduct("Admiral")]
[assembly: AssemblyTitle("Admiral")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ThinkInvisible.Admiral;

[BepInDependency("com.bepis.r2api", "5.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.ThinkInvisible.Admiral", "Admiral", "3.0.0")]
public class AdmiralPlugin : BaseUnityPlugin
{
	public const string ModVer = "3.0.0";

	public const string ModName = "Admiral";

	public const string ModGuid = "com.ThinkInvisible.Admiral";

	internal static ManualLogSource _logger;

	internal static AssetBundle resources;

	internal static ConfigFile cfgFile;

	private FilingDictionary<Module> allModules;

	public void Awake()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		_logger = ((BaseUnityPlugin)this).Logger;
		cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.ThinkInvisible.Admiral.cfg"), true);
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Admiral.admiral_assets"))
		{
			resources = AssetBundle.LoadFromStream(stream);
		}
		Module.SetupModuleClass();
		allModules = Module.InitModules(new Module.ModInfo
		{
			displayName = "Admiral",
			longIdentifier = "Admiral",
			shortIdentifier = "ADML",
			mainConfigFile = cfgFile
		});
		Module.SetupAll_PluginAwake(allModules);
	}

	public void Start()
	{
		Module.SetupAll_PluginStart(allModules);
	}

	private void Update()
	{
		if (RoR2Application.loadFinished)
		{
			AutoConfigModule.Update();
		}
	}
}
public static class CommonCode
{
	public static GameObject ModifyVanillaPrefab(string addressablePath, string newName, bool shouldNetwork, Func<GameObject, GameObject> modifierCallback)
	{
		//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)
		GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)addressablePath).WaitForCompletion(), "Temporary Setup Prefab", false);
		GameObject val2 = modifierCallback(val);
		GameObject result = PrefabAPI.InstantiateClone(val2, newName, shouldNetwork);
		Object.Destroy((Object)(object)val);
		Object.Destroy((Object)(object)val2);
		return result;
	}

	public static float Wrap(float x, float min, float max)
	{
		if (x < min)
		{
			return max - (min - x) % (max - min);
		}
		return min + (x - min) % (max - min);
	}
}
public static class Compat_RiskOfOptions
{
	public struct OptionIdentityStrings
	{
		public string category;

		public string name;

		public string description;

		public string modName;

		public string modGuid;
	}

	private static bool? _enabled;

	public static bool enabled
	{
		get
		{
			bool valueOrDefault = _enabled.GetValueOrDefault();
			if (!_enabled.HasValue)
			{
				valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				_enabled = valueOrDefault;
			}
			return _enabled.Value;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void SetupMod(string modGuid, string modName, string description, Sprite icon = null)
	{
		ModSettingsManager.SetModDescription(description, modGuid, modName);
		if ((Object)(object)icon != (Object)null)
		{
			ModSettingsManager.SetModIcon(icon, modGuid, modName);
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_CheckBox(ConfigEntry<bool> configEntry, OptionIdentityStrings ident, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0056: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(configEntry, new CheckBoxConfig
		{
			category = ident.category,
			name = ident.name,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_Slider(ConfigEntry<float> configEntry, OptionIdentityStrings ident, float min, float max, string formatString, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0034: 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_0043: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_006e: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new SliderOption(configEntry, new SliderConfig
		{
			category = ident.category,
			name = ident.name,
			max = max,
			min = min,
			formatString = formatString,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_IntSlider(ConfigEntry<int> configEntry, OptionIdentityStrings ident, int min, int max, string formatString, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0034: 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_0043: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_006e: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new IntSliderOption(configEntry, new IntSliderConfig
		{
			category = ident.category,
			name = ident.name,
			max = max,
			min = min,
			formatString = formatString,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_Choice(ConfigEntryBase configEntry, OptionIdentityStrings ident, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0056: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new ChoiceOption(configEntry, new ChoiceConfig
		{
			category = ident.category,
			name = ident.name,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_Keybind(ConfigEntry<KeyboardShortcut> configEntry, OptionIdentityStrings ident, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0056: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new KeyBindOption(configEntry, new KeyBindConfig
		{
			category = ident.category,
			name = ident.name,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_String(ConfigEntry<string> configEntry, OptionIdentityStrings ident, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0056: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(configEntry, new InputFieldConfig
		{
			category = ident.category,
			name = ident.name,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_StepSlider(ConfigEntry<float> configEntry, OptionIdentityStrings ident, float min, float max, float step, string formatString, bool restartRequired, Func<bool> isDisabledDelegate)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0034: 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_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		//IL_0076: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new StepSliderOption(configEntry, new StepSliderConfig
		{
			category = ident.category,
			name = ident.name,
			min = min,
			max = max,
			formatString = formatString,
			increment = step,
			restartRequired = restartRequired,
			description = ident.description,
			checkIfDisabled = (IsDisabledDelegate)(() => isDisabledDelegate())
		}), ident.modGuid, ident.modName);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void AddOption_Button(OptionIdentityStrings ident, string text, UnityAction del)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption(ident.name, ident.category, ident.description, text, del), ident.modGuid, ident.modName);
	}
}
public class CaptainBeaconDecayer : MonoBehaviour
{
	public float lifetime = 15f;

	public bool silent = false;

	private float stopwatch = 0f;

	private GenericEnergyComponent energyCpt;

	public static float lifetimeDropAdjust { get; internal set; } = 4f;


	private void Awake()
	{
		energyCpt = ((Component)this).gameObject.GetComponent<GenericEnergyComponent>();
	}

	private void FixedUpdate()
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Expected O, but got Unknown
		stopwatch += Time.fixedDeltaTime;
		if (Object.op_Implicit((Object)(object)energyCpt))
		{
			energyCpt.capacity = lifetime;
			energyCpt.energy = lifetime - stopwatch + lifetimeDropAdjust;
		}
		if (stopwatch >= lifetime + lifetimeDropAdjust)
		{
			if (!silent)
			{
				EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("prefabs/effects/omnieffect/OmniExplosionVFXEngiTurretDeath"), new EffectData
				{
					origin = ((Component)this).transform.position,
					scale = 5f
				}, true);
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public class FilingDictionary<T> : IEnumerable<T>, IEnumerable
{
	private readonly Dictionary<Type, T> _dict = new Dictionary<Type, T>();

	public int Count => _dict.Count;

	public void Add(T inst)
	{
		_dict.Add(inst.GetType(), inst);
	}

	public void Add<subT>(subT inst) where subT : T
	{
		_dict.Add(typeof(subT), (T)(object)inst);
	}

	public void Set<subT>(subT inst) where subT : T
	{
		_dict[typeof(subT)] = (T)(object)inst;
	}

	public subT Get<subT>() where subT : T
	{
		return (subT)(object)_dict[typeof(subT)];
	}

	public void Remove(T inst)
	{
		_dict.Remove(inst.GetType());
	}

	public void RemoveWhere(Func<T, bool> predicate)
	{
		foreach (T item in _dict.Values.Where(predicate).ToList())
		{
			_dict.Remove(item.GetType());
		}
	}

	public IEnumerator<T> GetEnumerator()
	{
		return _dict.Values.GetEnumerator();
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return GetEnumerator();
	}

	public ReadOnlyFilingDictionary<T> AsReadOnly()
	{
		return new ReadOnlyFilingDictionary<T>(this);
	}
}
public class ReadOnlyFilingDictionary<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
{
	private readonly FilingDictionary<T> baseCollection;

	public int Count => baseCollection.Count;

	public ReadOnlyFilingDictionary(FilingDictionary<T> baseCollection)
	{
		this.baseCollection = baseCollection;
	}

	public IEnumerator<T> GetEnumerator()
	{
		return baseCollection.GetEnumerator();
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return baseCollection.GetEnumerator();
	}
}
public class AutoConfigBinding
{
	public enum DeferType
	{
		UpdateImmediately,
		WaitForNextStage,
		WaitForRunEnd,
		NeverAutoUpdate
	}

	internal static readonly List<AutoConfigBinding> instances = new List<AutoConfigBinding>();

	internal static readonly Dictionary<AutoConfigBinding, (object, bool)> stageDirtyInstances = new Dictionary<AutoConfigBinding, (object, bool)>();

	internal static readonly Dictionary<AutoConfigBinding, object> runDirtyInstances = new Dictionary<AutoConfigBinding, object>();

	internal bool isOverridden = false;

	public AutoConfigContainer owner { get; internal set; }

	public object target { get; internal set; }

	public ConfigEntryBase configEntry { get; internal set; }

	public PropertyInfo boundProperty { get; internal set; }

	public string modName { get; internal set; }

	public AutoConfigUpdateActionsAttribute updateEventAttribute { get; internal set; }

	public MethodInfo propGetter { get; internal set; }

	public MethodInfo propSetter { get; internal set; }

	public Type propType { get; internal set; }

	public object boundKey { get; internal set; }

	public bool onDict { get; internal set; }

	public bool allowConCmd { get; internal set; }

	public object cachedValue { get; internal set; }

	public DeferType deferType { get; internal set; }

	public string readablePath => modName + "/" + configEntry.Definition.Section + "/" + configEntry.Definition.Key;

	internal static void CleanupDirty(bool isRunEnd)
	{
		AdmiralPlugin._logger.LogDebug((object)$"Stage ended; applying {stageDirtyInstances.Count} deferred config changes...");
		foreach (AutoConfigBinding key in stageDirtyInstances.Keys)
		{
			key.DeferredUpdateProperty(stageDirtyInstances[key].Item1, stageDirtyInstances[key].Item2);
		}
		stageDirtyInstances.Clear();
		if (!isRunEnd)
		{
			return;
		}
		AdmiralPlugin._logger.LogDebug((object)$"Run ended; applying {runDirtyInstances.Count} deferred config changes...");
		foreach (AutoConfigBinding key2 in runDirtyInstances.Keys)
		{
			key2.DeferredUpdateProperty(runDirtyInstances[key2], silent: true);
		}
		runDirtyInstances.Clear();
	}

	internal AutoConfigBinding()
	{
		instances.Add(this);
	}

	~AutoConfigBinding()
	{
		if (instances.Contains(this))
		{
			instances.Remove(this);
		}
	}

	internal void OverrideProperty(object newValue, bool silent = false)
	{
		if (!isOverridden)
		{
			runDirtyInstances[this] = cachedValue;
		}
		isOverridden = true;
		UpdateProperty(newValue, silent);
	}

	private void DeferredUpdateProperty(object newValue, bool silent = false)
	{
		object oldValue = propGetter.Invoke(target, (!onDict) ? new object[0] : new object[1] { boundKey });
		propSetter.Invoke(target, (!onDict) ? new object[1] { newValue } : new object[2] { boundKey, newValue });
		AutoConfigUpdateActionTypes autoConfigUpdateActionTypes = updateEventAttribute?.flags ?? AutoConfigUpdateActionTypes.None;
		AutoConfigUpdateActionsAttribute autoConfigUpdateActionsAttribute = updateEventAttribute;
		if (autoConfigUpdateActionsAttribute != null && !autoConfigUpdateActionsAttribute.ignoreDefault)
		{
			autoConfigUpdateActionTypes |= owner.defaultEnabledUpdateFlags;
		}
		cachedValue = newValue;
		owner.OnConfigChanged(new AutoConfigUpdateActionEventArgs
		{
			flags = autoConfigUpdateActionTypes,
			oldValue = oldValue,
			newValue = newValue,
			target = this,
			silent = silent
		});
	}

	internal void UpdateProperty(object newValue, bool silent = false)
	{
		if (deferType == DeferType.UpdateImmediately || (Object)(object)Run.instance == (Object)null || !((Behaviour)Run.instance).enabled)
		{
			DeferredUpdateProperty(newValue, silent);
		}
		else if (deferType == DeferType.WaitForNextStage)
		{
			stageDirtyInstances[this] = (newValue, silent);
		}
		else if (deferType == DeferType.WaitForRunEnd)
		{
			runDirtyInstances[this] = newValue;
		}
		else
		{
			AdmiralPlugin._logger.LogWarning((object)("Something attempted to set the value of an AutoConfigBinding with the DeferForever flag: \"" + readablePath + "\""));
		}
	}

	public static (List<AutoConfigBinding> results, string errorMsg) FindFromPath(string path1, string path2, string path3)
	{
		string p1u = path1.ToUpper();
		string p2u = path2?.ToUpper();
		string p3u = path3?.ToUpper();
		List<AutoConfigBinding> matchesLevel1 = new List<AutoConfigBinding>();
		List<AutoConfigBinding> matchesLevel2 = new List<AutoConfigBinding>();
		List<AutoConfigBinding> matchesLevel3 = new List<AutoConfigBinding>();
		List<AutoConfigBinding> matchesLevel4 = new List<AutoConfigBinding>();
		instances.ForEach(delegate(AutoConfigBinding x)
		{
			if (x.allowConCmd)
			{
				string key = x.configEntry.Definition.Key;
				string text = key.ToUpper();
				string section = x.configEntry.Definition.Section;
				string text2 = section.ToUpper();
				string text3 = x.modName;
				string text4 = text3.ToUpper();
				if (path2 == null)
				{
					if (text.Contains(p1u) || text2.Contains(p1u) || text4.Contains(p1u))
					{
						matchesLevel1.Add(x);
						matchesLevel2.Add(x);
						if (text == p1u)
						{
							matchesLevel3.Add(x);
							if (key == path1)
							{
								matchesLevel4.Add(x);
							}
						}
					}
				}
				else if (path3 == null)
				{
					bool flag = text4.Contains(p1u);
					bool flag2 = text2.Contains(p1u);
					bool flag3 = text2.Contains(p2u);
					bool flag4 = text.Contains(p2u);
					if ((flag && flag3) || (flag2 && flag4) || (flag && flag4))
					{
						matchesLevel1.Add(x);
						if (!(flag && flag4))
						{
							matchesLevel2.Add(x);
							bool flag5 = text3.Contains(path1);
							bool flag6 = section.Contains(path1);
							bool flag7 = section.Contains(path2);
							bool flag8 = key.Contains(path2);
							if ((flag5 && flag7) || (flag6 && flag8))
							{
								matchesLevel3.Add(x);
								bool flag9 = text3 == path1;
								bool flag10 = section == path1;
								bool flag11 = section == path2;
								bool flag12 = key == path2;
								if ((flag9 && flag11) || (flag10 && flag12))
								{
									matchesLevel4.Add(x);
								}
							}
						}
					}
				}
				else if (text.Contains(p3u) && text2.Contains(p2u) && text4.Contains(p1u))
				{
					matchesLevel1.Add(x);
					matchesLevel2.Add(x);
					if (text4 == p3u && text2 == p2u && text == p1u)
					{
						matchesLevel3.Add(x);
						if (text3 == path3 && section == path2 && key == path1)
						{
							matchesLevel4.Add(x);
						}
					}
				}
			}
		});
		if (matchesLevel1.Count == 0)
		{
			return (null, "no level 1 matches");
		}
		if (matchesLevel1.Count == 1)
		{
			return (matchesLevel1, null);
		}
		if (matchesLevel2.Count == 0)
		{
			return (matchesLevel1, "multiple level 1 matches, no level 2 matches");
		}
		if (matchesLevel2.Count == 1)
		{
			return (matchesLevel2, null);
		}
		if (matchesLevel3.Count == 0)
		{
			return (matchesLevel2, "multiple level 2 matches, no level 3 matches");
		}
		if (matchesLevel3.Count == 1)
		{
			return (matchesLevel3, null);
		}
		if (matchesLevel4.Count == 0)
		{
			return (matchesLevel3, "multiple level 3 matches, no level 4 matches");
		}
		if (matchesLevel4.Count == 1)
		{
			return (matchesLevel4, null);
		}
		Debug.LogError((object)("AutoConfig: There are multiple config entries with the path \"" + matchesLevel4[0].readablePath + "\"; this should never happen! Please report this as a bug."));
		return (matchesLevel4, "multiple level 4 matches");
	}
}
public class AutoConfigContainer
{
	public struct BindSubDictInfo
	{
		public object key;

		public object val;

		public Type keyType;

		public int index;
	}

	protected internal readonly List<AutoConfigBinding> bindings = new List<AutoConfigBinding>();

	protected internal virtual AutoConfigUpdateActionTypes defaultEnabledUpdateFlags => AutoConfigUpdateActionTypes.None;

	public event EventHandler<AutoConfigUpdateActionEventArgs> ConfigEntryChanged;

	public AutoConfigBinding FindConfig(string propName)
	{
		return bindings.Find((AutoConfigBinding x) => x.boundProperty.Name == propName && !x.onDict);
	}

	public AutoConfigBinding FindConfig(string propName, object dictKey)
	{
		return bindings.Find((AutoConfigBinding x) => x.boundProperty.Name == propName && x.onDict && x.boundKey == dictKey);
	}

	internal void OnConfigChanged(AutoConfigUpdateActionEventArgs e)
	{
		this.ConfigEntryChanged?.Invoke(this, e);
		Debug.Log((object)$"{e.target.readablePath}: {e.oldValue} > {e.newValue}");
		if ((Object)(object)Run.instance != (Object)null && ((Behaviour)Run.instance).isActiveAndEnabled)
		{
			if ((e.flags & AutoConfigUpdateActionTypes.InvalidateStats) == AutoConfigUpdateActionTypes.InvalidateStats)
			{
				AutoConfigModule.globalStatsDirty = true;
			}
			if ((e.flags & AutoConfigUpdateActionTypes.InvalidateDropTable) == AutoConfigUpdateActionTypes.InvalidateDropTable)
			{
				AutoConfigModule.globalDropsDirty = true;
			}
		}
	}

	private string ReplaceTags(string orig, PropertyInfo prop, string categoryName, BindSubDictInfo? subDict = null)
	{
		return Regex.Replace(orig, "<AIC.([a-zA-Z\\.]+)>", delegate(Match m)
		{
			string value = m.Groups[0].Value;
			string[] array = Regex.Split(value.Substring(1, value.Length - 1 - 1), "(?<!\\\\)\\.");
			if (array.Length >= 2)
			{
				string text = "AutoConfigContainer.Bind on property " + prop.Name + " in category " + categoryName + ": malformed string param \"" + m.Value + "\" ";
				switch (array[1])
				{
				case "Prop":
				{
					if (array.Length < 3)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(not enough params for Prop tag)."));
						return m.Value;
					}
					PropertyInfo property2 = prop.DeclaringType.GetProperty(array[2], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property2 == null)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(could not find Prop \"" + array[2] + "\")."));
						return m.Value;
					}
					return property2.GetValue(this).ToString();
				}
				case "Field":
				{
					if (array.Length < 3)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(not enough params for Field tag)."));
						return m.Value;
					}
					FieldInfo field2 = prop.DeclaringType.GetField(array[2], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field2 == null)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(could not find Field \"" + array[2] + "\")."));
						return m.Value;
					}
					return field2.GetValue(this).ToString();
				}
				case "DictKey":
					if (!subDict.HasValue)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(DictKey tag used on non-BindDict)."));
						return m.Value;
					}
					return subDict.Value.key.ToString();
				case "DictInd":
					if (!subDict.HasValue)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(DictInd tag used on non-BindDict)."));
						return m.Value;
					}
					return subDict.Value.index.ToString();
				case "DictKeyProp":
				{
					if (!subDict.HasValue)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(DictKeyProp tag used on non-BindDict)."));
						return m.Value;
					}
					if (array.Length < 3)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(not enough params for DictKeyProp tag)."));
						return m.Value;
					}
					PropertyInfo property = subDict.Value.key.GetType().GetProperty(array[2], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property == null)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(could not find DictKeyProp \"" + array[2] + "\")."));
						return m.Value;
					}
					return property.GetValue(subDict.Value.key).ToString();
				}
				case "DictKeyField":
				{
					if (!subDict.HasValue)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(DictKeyField tag used on non-BindDict)."));
						return m.Value;
					}
					if (array.Length < 3)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(not enough params for DictKeyField tag)."));
						return m.Value;
					}
					FieldInfo field = subDict.Value.key.GetType().GetField(array[2], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field == null)
					{
						AdmiralPlugin._logger.LogWarning((object)(text + "(could not find DictKeyField \"" + array[2] + "\")."));
						return m.Value;
					}
					return field.GetValue(subDict.Value.key).ToString();
				}
				default:
					AdmiralPlugin._logger.LogWarning((object)(text + "(unknown tag \"" + array[1] + "\")."));
					return m.Value;
				}
			}
			return m.Value;
		});
	}

	public void Bind(PropertyInfo prop, ConfigFile cfl, string modName, string categoryName, AutoConfigAttribute attrib, AutoConfigUpdateActionsAttribute eiattr = null, BindSubDictInfo? subDict = null)
	{
		//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Expected O, but got Unknown
		//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c3: Expected O, but got Unknown
		//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d2: Expected O, but got Unknown
		string text = "AutoConfigContainer.Bind on property " + prop.Name + " in category " + categoryName + " failed: ";
		if (!subDict.HasValue)
		{
			if (bindings.Exists((AutoConfigBinding x) => x.boundProperty == prop))
			{
				AdmiralPlugin._logger.LogError((object)(text + "this property has already been bound."));
				return;
			}
			if ((attrib.flags & AutoConfigFlags.BindDict) == AutoConfigFlags.BindDict)
			{
				if (!prop.PropertyType.GetInterfaces().Any((Type i) => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDictionary<, >)))
				{
					AdmiralPlugin._logger.LogError((object)(text + "BindDict flag cannot be used on property types which don't implement IDictionary."));
					return;
				}
				Type type = prop.PropertyType.GetGenericArguments()[1];
				if (attrib.avb != null && attrib.avbType != type)
				{
					AdmiralPlugin._logger.LogError((object)(text + "dict value and AcceptableValue types must match (received " + type.Name + " and " + attrib.avbType.Name + ")."));
					return;
				}
				if (!TomlTypeConverter.CanConvert(type))
				{
					AdmiralPlugin._logger.LogError((object)(text + "dict value type cannot be converted by BepInEx.Configuration.TomlTypeConverter (received " + type.Name + ")."));
					return;
				}
				IDictionary dictionary = (IDictionary)prop.GetValue(this, null);
				int num = 0;
				List<object> list = (from object k in dictionary.Keys
					select (k)).ToList();
				if (list.Count == 0)
				{
					AdmiralPlugin._logger.LogError((object)(text + "BindDict was used on an empty dictionary. All intended keys must be present at time of binding and cannot be added afterwards."));
				}
				{
					foreach (object item in list)
					{
						Bind(prop, cfl, modName, categoryName, attrib, eiattr, new BindSubDictInfo
						{
							key = item,
							val = dictionary[item],
							keyType = type,
							index = num
						});
						num++;
					}
					return;
				}
			}
		}
		if (!subDict.HasValue)
		{
			if (attrib.avb != null && attrib.avbType != prop.PropertyType)
			{
				AdmiralPlugin._logger.LogError((object)(text + "property and AcceptableValue types must match (received " + prop.PropertyType.Name + " and " + attrib.avbType.Name + ")."));
				return;
			}
			if (!TomlTypeConverter.CanConvert(prop.PropertyType))
			{
				AdmiralPlugin._logger.LogError((object)(text + "property type cannot be converted by BepInEx.Configuration.TomlTypeConverter (received " + prop.PropertyType.Name + ")."));
				return;
			}
		}
		object obj2 = (subDict.HasValue ? prop.GetValue(this) : this);
		IDictionary dictionary2 = (subDict.HasValue ? ((IDictionary)obj2) : null);
		MethodInfo methodInfo = (subDict.HasValue ? dictionary2.GetType().GetProperty("Item").GetGetMethod(nonPublic: true) : (prop.GetGetMethod(nonPublic: true) ?? prop.DeclaringType.GetProperty(prop.Name)?.GetGetMethod(nonPublic: true)));
		MethodInfo methodInfo2 = (subDict.HasValue ? dictionary2.GetType().GetProperty("Item").GetSetMethod(nonPublic: true) : (prop.GetSetMethod(nonPublic: true) ?? prop.DeclaringType.GetProperty(prop.Name)?.GetSetMethod(nonPublic: true)));
		Type type2 = (subDict.HasValue ? subDict.Value.keyType : prop.PropertyType);
		if (methodInfo == null || methodInfo2 == null)
		{
			AdmiralPlugin._logger.LogError((object)(text + "property (or IDictionary Item property, if using BindDict flag) must have both a getter and a setter."));
			return;
		}
		string name = attrib.name;
		if (name != null)
		{
			name = ReplaceTags(name, prop, categoryName, subDict);
		}
		else
		{
			object arg = char.ToUpperInvariant(prop.Name[0]);
			string name2 = prop.Name;
			name = string.Format("{0}{1}{2}", arg, name2.Substring(1, name2.Length - 1), subDict.HasValue ? (":" + subDict.Value.index) : "");
		}
		string desc = attrib.desc;
		desc = ((desc == null) ? ("Automatically generated from a C# " + (subDict.HasValue ? "dictionary " : "") + "property.") : ReplaceTags(desc, prop, categoryName, subDict));
		MethodInfo methodInfo3 = typeof(ConfigFile).GetMethods().First((MethodInfo x) => x.Name == "Bind" && x.GetParameters().Length == 3 && x.GetParameters()[0].ParameterType == typeof(ConfigDefinition) && x.GetParameters()[2].ParameterType == typeof(ConfigDescription)).MakeGenericMethod(type2);
		object obj3 = (subDict.HasValue ? subDict.Value.val : prop.GetValue(this));
		bool flag = (attrib.flags & AutoConfigFlags.DeferForever) == AutoConfigFlags.DeferForever;
		bool flag2 = (attrib.flags & AutoConfigFlags.DeferUntilEndGame) == AutoConfigFlags.DeferUntilEndGame;
		bool flag3 = (attrib.flags & AutoConfigFlags.DeferUntilNextStage) == AutoConfigFlags.DeferUntilNextStage;
		bool flag4 = (attrib.flags & AutoConfigFlags.PreventConCmd) != AutoConfigFlags.PreventConCmd;
		if (flag)
		{
			desc += "\nThis setting cannot be changed while the game is running.";
		}
		ConfigEntryBase cfe = (ConfigEntryBase)methodInfo3.Invoke(cfl, new object[3]
		{
			(object)new ConfigDefinition(categoryName, name),
			obj3,
			(object)new ConfigDescription(desc, attrib.avb, Array.Empty<object>())
		});
		AutoConfigBinding newBinding = new AutoConfigBinding
		{
			boundProperty = prop,
			allowConCmd = (flag4 && !flag && !flag2),
			deferType = (flag ? AutoConfigBinding.DeferType.NeverAutoUpdate : (flag2 ? AutoConfigBinding.DeferType.WaitForRunEnd : (flag3 ? AutoConfigBinding.DeferType.WaitForNextStage : AutoConfigBinding.DeferType.UpdateImmediately))),
			configEntry = cfe,
			modName = modName,
			owner = this,
			propGetter = methodInfo,
			propSetter = methodInfo2,
			propType = type2,
			onDict = subDict.HasValue,
			boundKey = (subDict.HasValue ? subDict.Value.key : null),
			updateEventAttribute = eiattr,
			cachedValue = obj3,
			target = obj2
		};
		bindings.Add(newBinding);
		if (!flag)
		{
			Type type3 = typeof(ConfigEntry<>).MakeGenericType(type2);
			EventInfo @event = type3.GetEvent("SettingChanged");
			Action<object, EventArgs> action = delegate
			{
				newBinding.UpdateProperty(cfe.BoxedValue);
			};
			ParameterExpression[] array = (from p in @event.EventHandlerType.GetMethod("Invoke").GetParameters()
				select Expression.Parameter(p.ParameterType)).ToArray();
			Delegate handler = Expression.Lambda(@event.EventHandlerType, Expression.Call(Expression.Constant(action), action.GetType().GetMethod("Invoke"), array[0], array[1]), array).Compile();
			@event.AddEventHandler(cfe, handler);
		}
		if ((attrib.flags & AutoConfigFlags.NoInitialRead) != AutoConfigFlags.NoInitialRead)
		{
			methodInfo2.Invoke(obj2, (!subDict.HasValue) ? new object[1] { cfe.BoxedValue } : new object[2]
			{
				subDict.Value.key,
				cfe.BoxedValue
			});
			newBinding.cachedValue = cfe.BoxedValue;
		}
		BindRoO(cfe, prop, type2, categoryName, name, desc, flag, flag2 || flag);
	}

	public void BindRoO(AutoConfigBinding bind, params BaseAutoConfigRoOAttribute[] entryRoOAttributes)
	{
		BindRoO(bind.configEntry, bind.boundProperty, bind.propType, bind.configEntry.Definition.Section, bind.configEntry.Definition.Key, bind.configEntry.Description.Description, bind.deferType >= AutoConfigBinding.DeferType.NeverAutoUpdate, bind.deferType >= AutoConfigBinding.DeferType.WaitForRunEnd, entryRoOAttributes);
	}

	public void BindRoO(ConfigEntryBase cfe, PropertyInfo prop, Type propType, string categoryName, string cfgName, string cfgDesc, bool deferForever, bool deferRun, params BaseAutoConfigRoOAttribute[] entryRoOAttributes)
	{
		if (!Compat_RiskOfOptions.enabled)
		{
			return;
		}
		string text = "AutoConfigContainer.Bind on property " + prop.Name + " in category " + categoryName + " could not apply Risk of Options compat: ";
		AutoConfigRoOInfoOverridesAttribute customAttribute = GetType().GetCustomAttribute<AutoConfigRoOInfoOverridesAttribute>();
		AutoConfigRoOInfoOverridesAttribute customAttribute2 = prop.GetCustomAttribute<AutoConfigRoOInfoOverridesAttribute>();
		if (entryRoOAttributes.Length == 0)
		{
			return;
		}
		if ((from x in entryRoOAttributes
			group x by x.GetType()).Any((IGrouping<Type, BaseAutoConfigRoOAttribute> x) => x.Count() > 1))
		{
			AdmiralPlugin._logger.LogWarning((object)("AutoConfigContainer.BindRoO on property " + prop.Name + " in category " + categoryName + " has multiple RoO options of the same type"));
		}
		string text2 = null;
		string text3 = null;
		bool flag = false;
		if (customAttribute != null)
		{
			text2 = customAttribute.modGuid;
			text3 = customAttribute.modName;
			flag = true;
		}
		else
		{
			Assembly assembly = Assembly.GetAssembly(GetType());
			Type[] types;
			try
			{
				types = assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				types = ex.Types;
			}
			Type[] array = types;
			foreach (Type element in array)
			{
				BepInPlugin customAttribute3 = ((MemberInfo)element).GetCustomAttribute<BepInPlugin>();
				if (customAttribute3 != null)
				{
					text2 = customAttribute3.GUID;
					text3 = customAttribute3.Name;
					flag = true;
					break;
				}
			}
		}
		if (!flag)
		{
			AdmiralPlugin._logger.LogError((object)(text + "could not find mod info. Declaring type must be in an assembly with a BepInPlugin, or have an AutoConfigContainerRoOInfoAttribute on it."));
			return;
		}
		Compat_RiskOfOptions.OptionIdentityStrings optionIdentityStrings = default(Compat_RiskOfOptions.OptionIdentityStrings);
		optionIdentityStrings.category = customAttribute2?.categoryName ?? customAttribute?.categoryName ?? categoryName;
		optionIdentityStrings.name = customAttribute2?.entryName ?? customAttribute?.entryName ?? cfgName;
		optionIdentityStrings.description = cfgDesc;
		optionIdentityStrings.modGuid = customAttribute2?.modGuid ?? text2;
		optionIdentityStrings.modName = customAttribute2?.modName ?? text3;
		Compat_RiskOfOptions.OptionIdentityStrings identStrings = optionIdentityStrings;
		foreach (BaseAutoConfigRoOAttribute baseAutoConfigRoOAttribute in entryRoOAttributes)
		{
			if ((baseAutoConfigRoOAttribute.requiredType == typeof(Enum)) ? (!propType.IsEnum) : (propType != baseAutoConfigRoOAttribute.requiredType))
			{
				AdmiralPlugin._logger.LogError((object)(text + baseAutoConfigRoOAttribute.GetType().Name + " may only be applied to " + baseAutoConfigRoOAttribute.requiredType.Name + " properties (got " + propType.Name + ")."));
			}
			else
			{
				baseAutoConfigRoOAttribute.Apply(cfe, identStrings, deferForever, () => (deferRun && Object.op_Implicit((Object)(object)Run.instance)) ? true : false);
			}
		}
	}

	internal void BindRoO(ConfigEntryBase cfe, PropertyInfo prop, Type propType, string categoryName, string cfgName, string cfgDesc, bool deferForever, bool deferRun)
	{
		if (Compat_RiskOfOptions.enabled)
		{
			BindRoO(cfe, prop, propType, categoryName, cfgName, cfgDesc, deferForever, deferRun, prop.GetCustomAttributes<BaseAutoConfigRoOAttribute>().ToArray());
		}
	}

	public void BindAll(ConfigFile cfl, string modName, string categoryName)
	{
		PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (PropertyInfo propertyInfo in properties)
		{
			AutoConfigAttribute customAttribute = propertyInfo.GetCustomAttribute<AutoConfigAttribute>(inherit: true);
			if (customAttribute != null)
			{
				Bind(propertyInfo, cfl, modName, categoryName, customAttribute, propertyInfo.GetCustomAttribute<AutoConfigUpdateActionsAttribute>(inherit: true));
			}
		}
	}
}
internal class AutoConfigModule : Module<AutoConfigModule>
{
	internal static bool globalStatsDirty;

	internal static bool globalDropsDirty;

	internal static bool globalLanguageDirty;

	public override bool managedEnable => false;

	public override void SetupConfig()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		base.SetupConfig();
		NetworkManagerSystem.Disconnect += new hook_Disconnect(On_GNMDisconnect);
		SceneManager.sceneLoaded += Evt_USMSceneLoaded;
	}

	internal static void Update()
	{
		if (!((Object)(object)Run.instance != (Object)null) || !((Behaviour)Run.instance).isActiveAndEnabled)
		{
			globalStatsDirty = false;
			globalDropsDirty = false;
		}
		else
		{
			if (globalStatsDirty)
			{
				globalStatsDirty = false;
				CharacterMaster.readOnlyInstancesList.Where((CharacterMaster x) => x.hasBody && x.GetBody().healthComponent.alive).ToList().ForEach(delegate(CharacterMaster cm)
				{
					if (cm.hasBody)
					{
						cm.GetBody().RecalculateStats();
					}
				});
			}
			if (globalDropsDirty)
			{
				globalDropsDirty = false;
				Run.instance.OnRuleBookUpdated(Run.instance.networkRuleBookComponent);
				Run.instance.BuildDropTable();
			}
		}
		if (globalLanguageDirty)
		{
			globalLanguageDirty = false;
			Language.SetCurrentLanguage(Language.currentLanguageName);
		}
	}

	internal static void On_GNMDisconnect(orig_Disconnect orig, NetworkManagerSystem self)
	{
		orig.Invoke(self);
		AutoConfigBinding.CleanupDirty(isRunEnd: true);
	}

	internal static void Evt_USMSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		AutoConfigBinding.CleanupDirty(isRunEnd: false);
	}
}
[Flags]
public enum AutoConfigFlags
{
	None = 0,
	AVIsList = 1,
	DeferUntilNextStage = 2,
	DeferUntilEndGame = 4,
	DeferForever = 8,
	PreventConCmd = 0x10,
	NoInitialRead = 0x20,
	BindDict = 0x40
}
[Flags]
public enum AutoConfigUpdateActionTypes
{
	None = 0,
	InvalidateLanguage = 1,
	InvalidateModel = 2,
	InvalidateStats = 4,
	InvalidateDropTable = 8
}
public class AutoConfigUpdateActionEventArgs : EventArgs
{
	public AutoConfigUpdateActionTypes flags;

	public object oldValue;

	public object newValue;

	public AutoConfigBinding target;

	public bool silent;
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigUpdateActionsAttribute : Attribute
{
	public readonly AutoConfigUpdateActionTypes flags;

	public readonly bool ignoreDefault;

	public AutoConfigUpdateActionsAttribute(AutoConfigUpdateActionTypes flags, bool ignoreDefault = false)
	{
		this.flags = flags;
		this.ignoreDefault = ignoreDefault;
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigAttribute : Attribute
{
	public readonly string name = null;

	public readonly string desc = null;

	public readonly AcceptableValueBase avb = null;

	public readonly Type avbType = null;

	public readonly AutoConfigFlags flags;

	public AutoConfigAttribute(string name, string desc, AutoConfigFlags flags = AutoConfigFlags.None, params object[] acceptableValues)
		: this(desc, flags, acceptableValues)
	{
		this.name = name;
	}

	public AutoConfigAttribute(string desc, AutoConfigFlags flags = AutoConfigFlags.None, params object[] acceptableValues)
		: this(flags, acceptableValues)
	{
		this.desc = desc;
	}

	public AutoConfigAttribute(AutoConfigFlags flags = AutoConfigFlags.None, params object[] acceptableValues)
	{
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		if (acceptableValues.Length != 0)
		{
			bool flag = (flags & AutoConfigFlags.AVIsList) == AutoConfigFlags.AVIsList;
			if (!flag && acceptableValues.Length != 2)
			{
				throw new ArgumentException("Range mode for acceptableValues (flag AVIsList not set) requires either 0 or 2 params; received " + acceptableValues.Length + ".\nThe description provided was: \"" + desc + "\".");
			}
			Type type = acceptableValues[0].GetType();
			for (int i = 1; i < acceptableValues.Length; i++)
			{
				if (type != acceptableValues[i].GetType())
				{
					throw new ArgumentException("Types of all acceptableValues must match");
				}
			}
			avb = (AcceptableValueBase)Activator.CreateInstance(flag ? typeof(AcceptableValueList<>).MakeGenericType(type) : typeof(AcceptableValueRange<>).MakeGenericType(type), acceptableValues);
			avbType = type;
		}
		this.flags = flags;
	}
}
public abstract class BaseAutoConfigRoOAttribute : Attribute
{
	public string nameOverride;

	public string catOverride;

	public abstract Type requiredType { get; }

	public BaseAutoConfigRoOAttribute(string nameOverride = null, string catOverride = null)
	{
		this.nameOverride = nameOverride;
		this.catOverride = catOverride;
	}

	public abstract void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate);
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOSliderAttribute : BaseAutoConfigRoOAttribute
{
	public string format;

	public float min;

	public float max;

	public override Type requiredType => typeof(float);

	public AutoConfigRoOSliderAttribute(string format, float min, float max, string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
		this.format = format;
		this.min = min;
		this.max = max;
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_Slider((ConfigEntry<float>)(object)cfe, identStrings, min, max, format, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOStepSliderAttribute : BaseAutoConfigRoOAttribute
{
	public string format;

	public float min;

	public float max;

	public float step;

	public override Type requiredType => typeof(float);

	public AutoConfigRoOStepSliderAttribute(string format, float min, float max, float step, string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
		this.format = format;
		this.min = min;
		this.max = max;
		this.step = step;
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_StepSlider((ConfigEntry<float>)(object)cfe, identStrings, min, max, step, format, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOIntSliderAttribute : BaseAutoConfigRoOAttribute
{
	public string format;

	public int min;

	public int max;

	public override Type requiredType => typeof(int);

	public AutoConfigRoOIntSliderAttribute(string format, int min, int max, string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
		this.format = format;
		this.min = min;
		this.max = max;
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_IntSlider((ConfigEntry<int>)(object)cfe, identStrings, min, max, format, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOChoiceAttribute : BaseAutoConfigRoOAttribute
{
	public override Type requiredType => typeof(Enum);

	public AutoConfigRoOChoiceAttribute(string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_Choice(cfe, identStrings, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOKeybindAttribute : BaseAutoConfigRoOAttribute
{
	public override Type requiredType => typeof(KeyboardShortcut);

	public AutoConfigRoOKeybindAttribute(string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_Keybind((ConfigEntry<KeyboardShortcut>)(object)cfe, identStrings, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOCheckboxAttribute : BaseAutoConfigRoOAttribute
{
	public override Type requiredType => typeof(bool);

	public AutoConfigRoOCheckboxAttribute(string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_CheckBox((ConfigEntry<bool>)(object)cfe, identStrings, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOStringAttribute : BaseAutoConfigRoOAttribute
{
	public override Type requiredType => typeof(string);

	public AutoConfigRoOStringAttribute(string nameOverride = null, string catOverride = null)
		: base(nameOverride, catOverride)
	{
	}

	public override void Apply(ConfigEntryBase cfe, Compat_RiskOfOptions.OptionIdentityStrings identStrings, bool deferForever, Func<bool> isDisabledDelegate)
	{
		Compat_RiskOfOptions.AddOption_String((ConfigEntry<string>)(object)cfe, identStrings, deferForever, isDisabledDelegate);
	}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class AutoConfigRoOInfoOverridesAttribute : Attribute
{
	public string modGuid;

	public string modName;

	public string categoryName;

	public string entryName;

	public AutoConfigRoOInfoOverridesAttribute(string guid, string name, string cat = null, string ent = null)
	{
		modGuid = guid;
		modName = name;
		categoryName = cat;
		entryName = ent;
	}

	public AutoConfigRoOInfoOverridesAttribute(Type ownerPluginType, string cat = null, string ent = null)
	{
		BepInPlugin customAttribute = ((MemberInfo)ownerPluginType).GetCustomAttribute<BepInPlugin>();
		if (customAttribute == null)
		{
			AdmiralPlugin._logger.LogError((object)("AutoConfigContainerRoOInfoAttribute received an invalid type " + ownerPluginType.Name + " with no BepInPluginAttribute"));
			return;
		}
		modGuid = customAttribute.GUID;
		modName = customAttribute.Name;
		categoryName = cat;
		entryName = ent;
	}
}
public static class AutoConfigPresetExtensions
{
	public static void ApplyPreset(this AutoConfigContainer container, string name)
	{
		HashSet<ConfigFile> hashSet = new HashSet<ConfigFile>();
		foreach (AutoConfigBinding binding in container.bindings)
		{
			IEnumerable<AutoConfigPresetAttribute> source = binding.boundProperty.GetCustomAttributes(typeof(AutoConfigPresetAttribute), inherit: true).Cast<AutoConfigPresetAttribute>();
			AutoConfigPresetAttribute autoConfigPresetAttribute = source.FirstOrDefault((AutoConfigPresetAttribute p) => p.presetName == name);
			if (autoConfigPresetAttribute != null)
			{
				binding.configEntry.BoxedValue = autoConfigPresetAttribute.boxedValue;
				if (!binding.configEntry.ConfigFile.SaveOnConfigSet)
				{
					hashSet.Add(binding.configEntry.ConfigFile);
				}
			}
		}
		foreach (ConfigFile item in hashSet)
		{
			item.Save();
		}
	}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public class AutoConfigPresetAttribute : Attribute
{
	public readonly string presetName;

	public readonly object boxedValue;

	public AutoConfigPresetAttribute(string name, object value)
	{
		presetName = name;
		boxedValue = value;
	}
}
public abstract class Module<T> : Module where T : Module<T>
{
	public static T instance { get; private set; }

	protected Module()
	{
		if (instance != null)
		{
			throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting Module was instantiated twice");
		}
		instance = this as T;
	}
}
public abstract class Module : AutoConfigContainer
{
	public struct ModInfo
	{
		public string displayName;

		public string longIdentifier;

		public string shortIdentifier;

		public ConfigFile mainConfigFile;
	}

	private static readonly FilingDictionary<Module> _allModules = new FilingDictionary<Module>();

	public static readonly ReadOnlyFilingDictionary<Module> allModules = _allModules.AsReadOnly();

	public readonly string name;

	protected readonly List<LanguageOverlay> languageOverlays = new List<LanguageOverlay>();

	protected readonly List<LanguageOverlay> permanentLanguageOverlays = new List<LanguageOverlay>();

	protected readonly Dictionary<string, string> genericLanguageTokens = new Dictionary<string, string>();

	protected readonly Dictionary<string, Dictionary<string, string>> specificLanguageTokens = new Dictionary<string, Dictionary<string, string>>();

	protected readonly Dictionary<string, string> permanentGenericLanguageTokens = new Dictionary<string, string>();

	protected readonly Dictionary<string, Dictionary<string, string>> permanentSpecificLanguageTokens = new Dictionary<string, Dictionary<string, string>>();

	public bool enabled { get; protected internal set; } = true;


	public virtual bool managedEnable => true;

	public virtual bool managedEnableRoO => true;

	public virtual string enabledConfigDescription => null;

	public virtual AutoConfigFlags enabledConfigFlags => AutoConfigFlags.None;

	public virtual AutoConfigUpdateActionTypes enabledConfigUpdateActionTypes => AutoConfigUpdateActionTypes.InvalidateLanguage;

	public bool languageInstalled { get; private set; } = false;


	public bool permanentLanguageInstalled { get; private set; } = false;


	public Xoroshiro128Plus rng { get; internal set; }

	public ModInfo modInfo { get; private set; }

	public virtual string configCategoryPrefix => "Modules.";

	internal static void SetupModuleClass()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		Run.Start += new hook_Start(On_RunStart);
		Language.SetCurrentLanguage += new hook_SetCurrentLanguage(Language_SetCurrentLanguage);
	}

	private static void On_RunStart(orig_Start orig, Run self)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		orig.Invoke(self);
		if (!NetworkServer.active)
		{
			return;
		}
		Xoroshiro128Plus val = new Xoroshiro128Plus(self.seed);
		foreach (Module allModule in _allModules)
		{
			allModule.rng = new Xoroshiro128Plus(val.nextUlong);
		}
	}

	private static void Language_SetCurrentLanguage(orig_SetCurrentLanguage orig, string newCurrentLanguageName)
	{
		orig.Invoke(newCurrentLanguageName);
		foreach (Module allModule in allModules)
		{
			allModule.RefreshPermanentLanguage();
			if (allModule.enabled)
			{
				if (allModule.languageInstalled)
				{
					allModule.UninstallLanguage();
				}
				allModule.InstallLanguage();
			}
		}
		AutoConfigModule.globalLanguageDirty = false;
	}

	public virtual void SetupConfig()
	{
		string categoryName = configCategoryPrefix + name;
		if (managedEnable)
		{
			Bind(typeof(Module).GetProperty("enabled"), modInfo.mainConfigFile, modInfo.displayName, categoryName, new AutoConfigAttribute(((enabledConfigDescription != null) ? (enabledConfigDescription + "\n") : "") + "Set to False to disable this module, and as much of its content as can be disabled after initial load. Doing so may cause changes in other modules as well.", enabledConfigFlags), (enabledConfigUpdateActionTypes != 0) ? new AutoConfigUpdateActionsAttribute(enabledConfigUpdateActionTypes) : null);
			if (managedEnableRoO && Compat_RiskOfOptions.enabled)
			{
				AutoConfigBinding bind = bindings.First((AutoConfigBinding x) => x.boundProperty == typeof(Module).GetProperty("enabled"));
				BindRoO(bind, new AutoConfigRoOCheckboxAttribute());
			}
		}
		BindAll(modInfo.mainConfigFile, modInfo.displayName, categoryName);
		base.ConfigEntryChanged += delegate(object sender, AutoConfigUpdateActionEventArgs args)
		{
			if (args.target.boundProperty.Name == "enabled")
			{
				if ((bool)args.newValue)
				{
					Install();
				}
				else
				{
					Uninstall();
					if (languageInstalled)
					{
						UninstallLanguage();
					}
				}
				RefreshPermanentLanguage();
			}
			if (args.flags.HasFlag(AutoConfigUpdateActionTypes.InvalidateLanguage))
			{
				if (enabled)
				{
					if (languageInstalled)
					{
						UninstallLanguage();
					}
					InstallLanguage();
				}
				RefreshPermanentLanguage();
			}
		};
	}

	public virtual void SetupAttributes()
	{
	}

	public virtual void SetupBehavior()
	{
	}

	public virtual void SetupLate()
	{
	}

	public virtual void Install()
	{
	}

	public virtual void Uninstall()
	{
	}

	public virtual void InstallLanguage()
	{
		languageOverlays.Add(LanguageAPI.AddOverlay(genericLanguageTokens));
		languageOverlays.Add(LanguageAPI.AddOverlay(specificLanguageTokens));
		languageInstalled = true;
		AutoConfigModule.globalLanguageDirty = true;
	}

	public virtual void UninstallLanguage()
	{
		foreach (LanguageOverlay languageOverlay in languageOverlays)
		{
			languageOverlay.Remove();
		}
		languageOverlays.Clear();
		languageInstalled = false;
		AutoConfigModule.globalLanguageDirty = true;
	}

	public virtual void RefreshPermanentLanguage()
	{
		if (permanentLanguageInstalled)
		{
			foreach (LanguageOverlay permanentLanguageOverlay in permanentLanguageOverlays)
			{
				permanentLanguageOverlay.Remove();
			}
		}
		permanentLanguageOverlays.Clear();
		permanentLanguageOverlays.Add(LanguageAPI.AddOverlay(permanentGenericLanguageTokens));
		permanentLanguageOverlays.Add(LanguageAPI.AddOverlay(permanentSpecificLanguageTokens));
		AutoConfigModule.globalLanguageDirty = true;
	}

	public static FilingDictionary<T> InitDirect<T>(ModInfo modInfo) where T : Module
	{
		return InitAll<T>(modInfo, Assembly.GetCallingAssembly(), (Type t) => (!t.BaseType.IsGenericType) ? (t.BaseType == typeof(T)) : (t.BaseType.GenericTypeArguments[0] == t && t.BaseType.BaseType == typeof(T)));
	}

	public static FilingDictionary<T> InitAll<T>(ModInfo modInfo, Func<Type, bool> extraTypeChecks = null) where T : Module
	{
		return InitAll<T>(modInfo, Assembly.GetCallingAssembly(), extraTypeChecks);
	}

	private static FilingDictionary<T> InitAll<T>(ModInfo modInfo, Assembly callingAssembly, Func<Type, bool> extraTypeChecks) where T : Module
	{
		FilingDictionary<T> filingDictionary = new FilingDictionary<T>();
		foreach (Type item in from t in callingAssembly.GetTypes()
			where t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(T)) && (extraTypeChecks?.Invoke(t) ?? true)
			select t)
		{
			T val = (T)Activator.CreateInstance(item, nonPublic: true);
			val.modInfo = modInfo;
			filingDictionary.Add(val);
		}
		return filingDictionary;
	}

	public static FilingDictionary<Module> InitModules(ModInfo modInfo)
	{
		return InitAll<Module>(modInfo, Assembly.GetCallingAssembly(), (Type t) => (!t.BaseType.IsGenericType) ? (t.BaseType == typeof(Module)) : (t.BaseType.GenericTypeArguments[0] == t && t.BaseType.BaseType == typeof(Module)));
	}

	public static void SetupAll_PluginAwake(IEnumerable<Module> modulesToSetup)
	{
		foreach (Module item in modulesToSetup)
		{
			item.SetupConfig();
		}
		foreach (Module item2 in modulesToSetup)
		{
			item2.SetupAttributes();
		}
		foreach (Module item3 in modulesToSetup)
		{
			item3.SetupBehavior();
		}
	}

	public static void SetupAll_PluginStart(IEnumerable<Module> modulesToSetup, bool installUnmanaged = false)
	{
		foreach (Module item in modulesToSetup)
		{
			item.SetupLate();
		}
		foreach (Module item2 in modulesToSetup)
		{
			if ((installUnmanaged || item2.managedEnable) && item2.enabled)
			{
				item2.Install();
			}
		}
	}

	protected Module()
	{
		name = GetType().Name;
		_allModules.Add(this);
	}
}
public class BeaconRebalance : Module<BeaconRebalance>
{
	internal GameObject muzzleFlashPrefab;

	private bool isNormalRechargeRunning = false;

	[AutoConfigRoOSlider("{0:P0}", 0f, 1f, null, null)]
	[AutoConfig("Fractional influence of cooldown reduction, e.g. Alien Head and unknown cooldown sources from other mods, on temporary beacons (0 = no effect, 1 = full effect).", AutoConfigFlags.DeferUntilNextStage, new object[] { 0f, 1f })]
	public float beaconCDRInfluence { get; private set; } = 0.5f;


	[AutoConfigRoOSlider("{0:P0}", 0f, 1f, null, null)]
	[AutoConfig("Fractional influence of restock, e.g. Bandolier, on temporary beacons (0 = no effect, 1 = full effect).", AutoConfigFlags.DeferUntilNextStage, new object[] { 0f, 1f })]
	public float beaconRestockInfluence { get; private set; } = 0.5f;


	[AutoConfigRoOCheckbox(null, null)]
	[AutoConfig("If false, the original beacon skills will not be replaced; temporary beacons will instead be provided as alternates.", AutoConfigFlags.DeferForever, new object[] { })]
	public bool removeOriginals { get; private set; } = true;


	public override string enabledConfigDescription => "Changes all Beacon skills to have cooldown and lifetime, and replaces some variants which are incompatible with this model.";

	public override AutoConfigUpdateActionTypes enabledConfigUpdateActionTypes => AutoConfigUpdateActionTypes.InvalidateLanguage;

	public override AutoConfigFlags enabledConfigFlags => AutoConfigFlags.DeferUntilNextStage;

	public override void SetupAttributes()
	{
		base.SetupAttributes();
		muzzleFlashPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/effects/muzzleflashes/MuzzleflashSupplyDrop, Healing");
	}

	public override void InstallLanguage()
	{
		base.InstallLanguage();
		languageOverlays.Add(LanguageAPI.AddOverlay("CAPTAIN_SPECIAL_DESCRIPTION", "Request one of two <style=cIsUtility>temporary</style> Supply Beacons. Both beacons have <style=cIsUtility>independent cooldowns</style>."));
	}

	public override void Install()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		base.Install();
		CaptainSupplyDropController.UpdateSkillOverrides += new Manipulator(IL_CSDCUpdateSkillOverrides);
		CaptainSupplyDropController.SetSkillOverride += new hook_SetSkillOverride(On_CSDCSetSkillOverride);
		GenericSkill.CalculateFinalRechargeInterval += new hook_CalculateFinalRechargeInterval(On_GSCalculateFinalRechargeInterval);
		GenericSkill.RecalculateMaxStock += new hook_RecalculateMaxStock(On_GSRecalculateMaxStock);
		GenericSkill.AddOneStock += new hook_AddOneStock(On_GSAddOneStock);
		GenericSkill.RunRecharge += new hook_RunRecharge(On_GSRunRecharge);
		GenericSkill.FixedUpdate += new hook_FixedUpdate(On_GSFixedUpdate);
		Module<EquipBeacon>.instance.Install();
		Module<HealBeacon>.instance.Install();
		Module<ShockBeacon>.instance.Install();
		Module<StasisBeacon>.instance.Install();
	}

	public override void Uninstall()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		base.Uninstall();
		CaptainSupplyDropController.UpdateSkillOverrides -= new Manipulator(IL_CSDCUpdateSkillOverrides);
		CaptainSupplyDropController.SetSkillOverride -= new hook_SetSkillOverride(On_CSDCSetSkillOverride);
		GenericSkill.CalculateFinalRechargeInterval -= new hook_CalculateFinalRechargeInterval(On_GSCalculateFinalRechargeInterval);
		GenericSkill.RecalculateMaxStock -= new hook_RecalculateMaxStock(On_GSRecalculateMaxStock);
		GenericSkill.AddOneStock -= new hook_AddOneStock(On_GSAddOneStock);
		GenericSkill.RunRecharge -= new hook_RunRecharge(On_GSRunRecharge);
		GenericSkill.FixedUpdate -= new hook_FixedUpdate(On_GSFixedUpdate);
		Module<EquipBeacon>.instance.Uninstall();
		Module<HealBeacon>.instance.Uninstall();
		Module<ShockBeacon>.instance.Uninstall();
		Module<StasisBeacon>.instance.Uninstall();
	}

	private bool SkillIsTemporaryBeacon(SkillDef skillDef)
	{
		return (Object)(object)skillDef == (Object)(object)Module<EquipBeacon>.instance.skillDef || (Object)(object)skillDef == (Object)(object)Module<HealBeacon>.instance.skillDef || (Object)(object)skillDef == (Object)(object)Module<ShockBeacon>.instance.skillDef || (Object)(object)skillDef == (Object)(object)Module<StasisBeacon>.instance.skillDef;
	}

	private bool SkillIsTemporaryBeacon(GenericSkill skill)
	{
		return SkillIsTemporaryBeacon(skill.skillDef);
	}

	private void On_GSFixedUpdate(orig_FixedUpdate orig, GenericSkill self)
	{
		isNormalRechargeRunning = true;
		orig.Invoke(self);
		isNormalRechargeRunning = false;
	}

	private void On_GSRunRecharge(orig_RunRecharge orig, GenericSkill self, float dt)
	{
		if (SkillIsTemporaryBeacon(self) && !isNormalRechargeRunning)
		{
			dt *= beaconCDRInfluence;
		}
		orig.Invoke(self, dt);
	}

	private void On_GSAddOneStock(orig_AddOneStock orig, GenericSkill self)
	{
		if (SkillIsTemporaryBeacon(self))
		{
			self.rechargeStopwatch += self.finalRechargeInterval * beaconRestockInfluence;
		}
		else
		{
			orig.Invoke(self);
		}
	}

	private void On_GSRecalculateMaxStock(orig_RecalculateMaxStock orig, GenericSkill self)
	{
		orig.Invoke(self);
		if (SkillIsTemporaryBeacon(self))
		{
			self.maxStock = 1;
		}
	}

	private float On_GSCalculateFinalRechargeInterval(orig_CalculateFinalRechargeInterval orig, GenericSkill self)
	{
		float num = orig.Invoke(self);
		if (SkillIsTemporaryBeacon(self))
		{
			return self.baseRechargeInterval * (1f - beaconCDRInfluence) + num * beaconCDRInfluence;
		}
		return num;
	}

	private void On_CSDCSetSkillOverride(orig_SetSkillOverride orig, CaptainSupplyDropController self, ref SkillDef currentSkillDef, SkillDef newSkillDef, GenericSkill component)
	{
		if (!SkillIsTemporaryBeacon(currentSkillDef))
		{
			orig.Invoke(self, ref currentSkillDef, newSkillDef, component);
		}
	}

	private void IL_CSDCUpdateSkillOverrides(ILContext il)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		int maskLocIndex = -1;
		int num = default(int);
		ILLabel val2 = default(ILLabel);
		if (val.TryGotoNext(new Func<Instruction, bool>[5]
		{
			(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref maskLocIndex),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, maskLocIndex),
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchLdfld<CaptainSupplyDropController>(x, "authorityEnabledSkillsMask"),
			(Instruction x) => ILPatternMatchingExt.MatchBeq(x, ref val2)
		}))
		{
			val.Index = 0;
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, maskLocIndex)
			});
			val.EmitDelegate<Func<byte, byte>>((Func<byte, byte>)((byte orig) => 3));
		}
		else
		{
			AdmiralPlugin._logger.LogError((object)"BeaconRebalance/CSDCUpdateSkillOverrides: Failed to apply IL patch (target instructions not found)");
		}
	}
}
public class CancelOrbitalSkills : Module<CancelOrbitalSkills>
{
	public override string enabledConfigDescription => "Allows orbital skills to be cancelled by reactivating the skill.";

	public override void Install()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		base.Install();
		GenericSkill.ExecuteIfReady += new hook_ExecuteIfReady(GenericSkill_ExecuteIfReady);
	}

	public override void Uninstall()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		base.Uninstall();
		GenericSkill.ExecuteIfReady -= new hook_ExecuteIfReady(GenericSkill_ExecuteIfReady);
	}

	private bool GenericSkill_ExecuteIfReady(orig_ExecuteIfReady orig, GenericSkill self)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		bool flag = orig.Invoke(self);
		if (flag || !Object.op_Implicit((Object)(object)self.stateMachine) || self.stateMachine.HasPendingState())
		{
			return flag;
		}
		Type type = ((object)self.stateMachine.state).GetType();
		SerializableEntityStateType activationState = self.activationState;
		if (type == ((SerializableEntityStateType)(ref activationState)).stateType && (self.stateMachine.state is SetupAirstrike || self.stateMachine.state is SetupSupplyDrop))
		{
			self.stateMachine.SetNextStateToMain();
		}
		return false;
	}
}
public class CatalyzerDartSkill : Module<CatalyzerDartSkill>
{
	public class MalevolentCleanseOnHit : MonoBehaviour
	{
	}

	internal UnlockableDef unlockable;

	internal SkillDef skillDef;

	internal GameObject projectilePrefab;

	[AutoConfigRoOSlider("{0:N0} s", 0f, 120f, null, null)]
	[AutoConfig("Cooldown of Catalyzer Dart.", AutoConfigFlags.DeferForever, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float skillRecharge { get; private set; } = 8f;


	[AutoConfigRoOSlider("{0:P0}", 0f, 10f, null, null)]
	[AutoConfig("Fraction of remaining DoT damage dealt by malevolent cleanses.", AutoConfigFlags.None, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float evilCleanseDoTDamage { get; private set; } = 3f;


	[AutoConfigRoOSlider("{0:P0}", 0f, 20f, null, null)]
	[AutoConfig("Fraction of base damage dealt per non-DoT debuff by malevolent cleanses.", AutoConfigFlags.None, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float evilCleanseNonDoTDamage { get; private set; } = 5f;


	public override string enabledConfigDescription => "Adds the Catalyzer Dart secondary skill variant.";

	public override AutoConfigFlags enabledConfigFlags => AutoConfigFlags.DeferForever;

	public override void SetupAttributes()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		base.SetupAttributes();
		bool flag = default(bool);
		SerializableEntityStateType activationState = ContentAddition.AddEntityState<EntStateFireCatalyzer>(ref flag);
		projectilePrefab = CommonCode.ModifyVanillaPrefab("RoR2/Base/Captain/CaptainTazer.prefab", "CaptainCatalyzerProjectile", shouldNetwork: true, delegate(GameObject projPfbPfb)
		{
			//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)
			projPfbPfb.GetComponent<ProjectileDamage>().damageType = DamageTypeCombo.op_Implicit((DamageType)0);
			((ProjectileExplosion)projPfbPfb.GetComponent<ProjectileImpactExplosion>()).blastRadius = 1f;
			projPfbPfb.AddComponent<MalevolentCleanseOnHit>();
			return projPfbPfb;
		});
		ContentAddition.AddProjectile(projectilePrefab);
		string text = "ADMIRAL_CATALYZER_SKILL_NAME";
		string text2 = "ADMIRAL_CATALYZER_SKILL_DESC";
		string text3 = "Catalyzer Dart";
		LanguageAPI.Add(text, text3);
		LanguageAPI.Add(text2, "Fire a fast dart which <style=cIsHealing>catalyzes all debuffs</style>, converting them to <style=cIsDamage>damage</style>: <style=cIsDamage>300%</style> of the remaining total for DoTs, <style=cIsDamage>1x500%</style> otherwise.");
		skillDef = ScriptableObject.CreateInstance<SkillDef>();
		skillDef.activationStateMachineName = "Weapon";
		skillDef.activationState = activationState;
		skillDef.interruptPriority = (InterruptPriority)1;
		skillDef.baseRechargeInterval = skillRecharge;
		skillDef.baseMaxStock = 1;
		skillDef.rechargeStock = 1;
		skillDef.beginSkillCooldownOnSkillEnd = false;
		skillDef.requiredStock = 1;
		skillDef.stockToConsume = 1;
		skillDef.isCombatSkill = true;
		skillDef.cancelSprintingOnActivation = true;
		skillDef.canceledFromSprinting = false;
		skillDef.mustKeyPress = false;
		skillDef.fullRestockOnAssign = true;
		skillDef.dontAllowPastMaxStocks = false;
		skillDef.skillName = text3;
		skillDef.skillNameToken = text;
		skillDef.skillDescriptionToken = text2;
		skillDef.icon = AdmiralPlugin.resources.LoadAsset<Sprite>("Assets/Admiral/Textures/Icons/icon_AdmiralCatalyzerSkill.png");
		ContentAddition.AddSkillDef(skillDef);
		string text4 = "ACHIEVEMENT_ADMIRAL_" + name.ToUpper(CultureInfo.InvariantCulture) + "_NAME";
		string text5 = "ACHIEVEMENT_ADMIRAL_" + name.ToUpper(CultureInfo.InvariantCulture) + "_DESCRIPTION";
		unlockable = ScriptableObject.CreateInstance<UnlockableDef>();
		unlockable.cachedName = "Admiral_" + name + "Unlockable";
		unlockable.sortScore = 200;
		unlockable.achievementIcon = AdmiralPlugin.resources.LoadAsset<Sprite>("Assets/Admiral/Textures/Icons/icon_AdmiralCatalyzerSkill.png");
		ContentAddition.AddUnlockableDef(unlockable);
		LanguageAPI.Add(text4, "Captain: Hoist By Their Own Petard");
		LanguageAPI.Add(text5, "As Captain, kill 6 other enemies by Shocking the same one.");
	}

	public override void Install()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		base.Install();
		LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSecondarySkillFamily").AddVariant(skillDef, unlockable);
		GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt;
		FireTazer.Fire += new hook_Fire(FireTazer_Fire);
	}

	public override void Uninstall()
	{
		base.Uninstall();
		LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSecondarySkillFamily").RemoveVariant(skillDef);
	}

	private void FireTazer_Fire(orig_Fire orig, FireTazer self)
	{
		if (!(self is EntStateFireCatalyzer))
		{
			orig.Invoke(self);
			return;
		}
		GameObject val = FireTazer.projectilePrefab;
		FireTazer.projectilePrefab = projectilePrefab;
		orig.Invoke(self);
		FireTazer.projectilePrefab = val;
	}

	private void GlobalEventManager_onServerDamageDealt(DamageReport obj)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Invalid comparison between Unknown and I4
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)obj.victimBody) || !Object.op_Implicit((Object)(object)obj.damageInfo.inflictor) || !Object.op_Implicit((Object)(object)obj.damageInfo.inflictor.GetComponent<MalevolentCleanseOnHit>()))
		{
			return;
		}
		int num = 0;
		for (BuffIndex val = (BuffIndex)0; (int)val < BuffCatalog.buffCount; val = (BuffIndex)(val + 1))
		{
			BuffDef buffDef = BuffCatalog.GetBuffDef(val);
			if (buffDef.isDebuff)
			{
				num += obj.victimBody.GetBuffCount(val);
			}
		}
		EntityStateMachine val2 = ((Component)obj.victimBody).GetComponent<SetStateOnHurt>()?.targetStateMachine;
		if (Object.op_Implicit((Object)(object)val2) && (val2.state is FrozenState || val2.state is StunState || val2.state is ShockState))
		{
			num++;
		}
		float num2 = 0f;
		if (DotController.dotControllerLocator.TryGetValue(((Object)((Component)obj.victimBody).gameObject).GetInstanceID(), out var value))
		{
			List<DotStack> dotStackList = value.dotStackList;
			foreach (DotStack item in dotStackList)
			{
				num2 += item.damage * Mathf.Ceil(item.timer / item.dotDef.interval);
			}
		}
		obj.victimBody.healthComponent.TakeDamage(new DamageInfo
		{
			attacker = obj.attacker,
			crit = false,
			damage = (float)num * obj.attackerBody.damage * evilCleanseNonDoTDamage + num2 * evilCleanseDoTDamage,
			damageType = DamageTypeCombo.op_Implicit((DamageType)0),
			procCoefficient = 0f
		});
		CleanseSystem.CleanseBodyServer(obj.victimBody, true, false, true, true, false, false);
	}
}
[RegisterAchievement("Admiral_CatalyzerDartSkill", "Admiral_CatalyzerDartSkillUnlockable", "CompleteMainEnding", 3u, null)]
public class AdmiralCatalyzerAchievement : BaseAchievement
{
	public override bool wantsBodyCallbacks => true;

	public override BodyIndex LookUpRequiredBodyIndex()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		return BodyCatalog.FindBodyIndex("CaptainBody");
	}

	public override void OnInstall()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		((BaseAchievement)this).OnInstall();
		LightningOrb.OnArrival += new hook_OnArrival(LightningOrb_OnArrival);
	}

	public override void OnUninstall()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		((BaseAchievement)this).OnUninstall();
		LightningOrb.OnArrival -= new hook_OnArrival(LightningOrb_OnArrival);
	}

	private void LightningOrb_OnArrival(orig_OnArrival orig, LightningOrb self)
	{
		orig.Invoke(self);
		if (!(self is ShockedOrb shockedOrb) || self.failedToKill || !Object.op_Implicit((Object)(object)shockedOrb.shockVictim))
		{
			return;
		}
		ShockHelper component = shockedOrb.shockVictim.GetComponent<ShockHelper>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.shockKills++;
			if (component.shockKills >= 6)
			{
				((BaseAchievement)this).Grant();
			}
		}
	}
}
public class EntStateFireCatalyzer : FireTazer
{
}
public class EquipBeacon : Module<EquipBeacon>
{
	public class EntStateCallSupplyDropRejuvenator : CallSupplyDropEquipmentRestock
	{
		public override void OnEnter()
		{
			((CallSupplyDropBase)this).supplyDropPrefab = Module<EquipBeacon>.instance.beaconPrefab;
			((CallSupplyDropBase)this).muzzleflashEffect = Module<BeaconRebalance>.instance.muzzleFlashPrefab;
			((CallSupplyDropBase)this).OnEnter();
		}
	}

	public class EntStateRejuvenatorMainState : EquipmentRestockMainState
	{
		public override bool shouldShowEnergy => Module<EquipBeacon>.instance.useInteractable && Module<EquipBeacon>.instance.interactableLimited;

		public override void OnEnter()
		{
			//IL_0042: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			((BaseCaptainSupplyDropState)this).OnEnter();
			if (NetworkServer.active && !Module<EquipBeacon>.instance.useInteractable)
			{
				GameObject val = Object.Instantiate<GameObject>(Module<EquipBeacon>.instance.rejuvWardPrefab, ((EntityState)this).outer.commonComponents.transform.position, ((EntityState)this).outer.commonComponents.transform.rotation);
				val.GetComponent<TeamFilter>().teamIndex = ((BaseCaptainSupplyDropState)this).teamFilter.teamIndex;
				NetworkServer.Spawn(val);
			}
		}

		public override void OnInteractionBegin(Interactor activator)
		{
			if (!Object.op_Implicit((Object)(object)activator))
			{
				return;
			}
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component) && !component.HasBuff(Module<EquipBeacon>.instance.stimmedBuff))
			{
				if (Module<EquipBeacon>.instance.interactableLimited)
				{
					((BaseCaptainSupplyDropState)this).energyComponent.TakeEnergy(base.activationCost);
				}
				component.AddTimedBuff(Module<EquipBeacon>.instance.stimmedBuff, Module<EquipBeacon>.instance.skillLifetime);
			}
		}

		public override Interactability GetInteractability(Interactor activator)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!Module<EquipBeacon>.instance.useInteractable)
			{
				return (Interactability)0;
			}
			if (!Object.op_Implicit((Object)(object)activator))
			{
				return (Interactability)0;
			}
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return (Interactability)0;
			}
			if (Module<EquipBeacon>.instance.interactableLimited && base.activationCost >= ((BaseCaptainSupplyDropState)this).energyComponent.energy)
			{
				return (Interactability)1;
			}
			if (component.HasBuff(Module<EquipBeacon>.instance.stimmedBuff))
			{
				return (Interactability)1;
			}
			return (Interactability)2;
		}

		public override string GetContextString(Interactor activator)
		{
			return Language.GetString("ADMIRAL_SUPPLY_REJUVENATOR_CONTEXT");
		}
	}

	private GameObject rejuvWardPrefab;

	private SkillFamily skillFamily1;

	private SkillFamily skillFamily2;

	private SkillDef origSkillDef;

	internal SkillDef skillDef;

	internal GameObject beaconPrefab;

	[AutoConfigRoOSlider("{0:N0} s", 0f, 120f, null, null)]
	[AutoConfig("Lifetime of the T.Beacon: Rejuvenator deployable and buff.", AutoConfigFlags.DeferForever, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float skillLifetime { get; private set; } = 20f;


	[AutoConfigRoOSlider("{0:N0} s", 0f, 120f, null, null)]
	[AutoConfig("Cooldown of T.Beacon: Rejuvenator.", AutoConfigFlags.DeferForever, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float skillRecharge { get; private set; } = 50f;


	[AutoConfigRoOSlider("{0:P0}", 0f, 5f, null, null)]
	[AutoConfig("Additional fraction of skill recharge rate to provide from the Stimmed buff.", AutoConfigFlags.None, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float rechargeRate { get; private set; } = 0.5f;


	[AutoConfigRoOCheckbox(null, null)]
	[AutoConfig("If true, buff is granted by interacting with the beacon and consuming a once-per-player charge. If false, buff is granted continuously in an area.", AutoConfigFlags.DeferForever, new object[] { })]
	public bool useInteractable { get; private set; } = true;


	[AutoConfigRoOCheckbox(null, null)]
	[AutoConfig("If true and UseInteractable is true, only 3 charges will be provided for all players to share. If false, the beacon will have unlimited charges instead, but players who already have the buff will still not be able to stack or renew it (effectively limiting uses to once per player per beacon cooldown).", AutoConfigFlags.DeferForever, new object[] { })]
	public bool interactableLimited { get; private set; } = false;


	public override string enabledConfigDescription => "Contains config for the T.Beacon: Resupply submodule of Modules.BeaconRebalance. Replaces Beacon: Equipment.";

	public override bool managedEnable => false;

	public BuffDef stimmedBuff { get; private set; }

	public override void SetupAttributes()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: 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_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		base.SetupAttributes();
		bool flag = default(bool);
		SerializableEntityStateType activationState = ContentAddition.AddEntityState<EntStateCallSupplyDropRejuvenator>(ref flag);
		SerializableEntityStateType mainStateType = ContentAddition.AddEntityState<EntStateRejuvenatorMainState>(ref flag);
		skillFamily1 = LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSupplyDrop1SkillFamily");
		skillFamily2 = LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSupplyDrop2SkillFamily");
		origSkillDef = LegacyResourcesAPI.Load<SkillDef>("skilldefs/captainbody/CallSupplyDropEquipmentRestock");
		skillDef = SkillUtil.CloneSkillDef(origSkillDef);
		skillDef.rechargeStock = 1;
		skillDef.baseRechargeInterval = skillRecharge;
		skillDef.skillName = "AdmiralSupplyDropRejuvenator";
		skillDef.skillNameToken = "ADMIRAL_SUPPLY_REJUVENATOR_NAME";
		skillDef.skillDescriptionToken = "ADMIRAL_SUPPLY_REJUVENATOR_DESCRIPTION";
		skillDef.activationState = activationState;
		LanguageAPI.Add(skillDef.skillNameToken, "T.Beacon: Rejuvenator");
		LanguageAPI.Add(skillDef.skillDescriptionToken, "<style=cIsUtility>Temporary beacon</style>. <style=cIsUtility>Buff</style> all nearby allies with <style=cIsUtility>+50% skill recharge rate</style>.");
		ContentAddition.AddSkillDef(skillDef);
		stimmedBuff = ScriptableObject.CreateInstance<BuffDef>();
		((Object)stimmedBuff).name = "Stimmed";
		stimmedBuff.iconSprite = LegacyResourcesAPI.Load<Sprite>("textures/itemicons/texSyringeIcon");
		stimmedBuff.buffColor = Color.red;
		stimmedBuff.canStack = false;
		stimmedBuff.isDebuff = false;
		ContentAddition.AddBuffDef(stimmedBuff);
		LanguageAPI.Add("ADMIRAL_SUPPLY_REJUVENATOR_CONTEXT", "Take stim charge");
		GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("prefabs/networkedobjects/captainsupplydrops/CaptainSupplyDrop, EquipmentRestock"), "TempSetup, BeaconPrefabPrefab", false);
		CaptainBeaconDecayer captainBeaconDecayer = val.AddComponent<CaptainBeaconDecayer>();
		captainBeaconDecayer.lifetime = skillLifetime;
		if (!useInteractable)
		{
			((Behaviour)val.GetComponent<ProxyInteraction>()).enabled = false;
			((Behaviour)val.GetComponent<GenericEnergyComponent>()).enabled = true;
		}
		val.GetComponent<EntityStateMachine>().mainStateType = mainStateType;
		beaconPrefab = PrefabAPI.InstantiateClone(val, "AdmiralSupplyDrop, Rejuvenator", true);
		Object.Destroy((Object)(object)val);
		GameObject val2 = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("prefabs/networkedobjects/captainsupplydrops/CaptainHealingWard"));
		((Behaviour)val2.GetComponent<HealingWard>()).enabled = false;
		Transform val3 = val2.transform.Find("Indicator");
		CaptainBeaconDecayer captainBeaconDecayer2 = val2.AddComponent<CaptainBeaconDecayer>();
		captainBeaconDecayer2.lifetime = skillLifetime - CaptainBeaconDecayer.lifetimeDropAdjust;
		captainBeaconDecayer2.silent = true;
		BuffWard val4 = val2.AddComponent<BuffWard>();
		val4.buffDef = stimmedBuff;
		val4.buffDuration = 1f;
		val4.radius = 10f;
		val4.interval = 1f;
		val4.rangeIndicator = val3;
		((Renderer)((Component)val3.Find("IndicatorRing")).GetComponent<MeshRenderer>()).material.SetColor("_TintColor", new Color(1f, 0.5f, 0f, 1f));
		ParticleSystemRenderer component = ((Component)val3.Find("HealingSymbols")).GetComponent<ParticleSystemRenderer>();
		((Renderer)component).material.SetTexture("_MainTex", LegacyResourcesAPI.Load<Texture>("textures/bufficons/texBuffTeslaIcon"));
		((Renderer)component).material.SetColor("_TintColor", new Color(2f, 0.05f, 0f, 1f));
		component.trailMaterial.SetColor("_TintColor", new Color(2f, 0.05f, 0f, 1f));
		MainModule main = ((Component)val3.Find("Flashes")).GetComponent<ParticleSystem>().main;
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.5f, 0.25f, 0f, 1f));
		rejuvWardPrefab = PrefabAPI.InstantiateClone(val2, "CaptainRejuvWard", true);
		Object.Destroy((Object)(object)val2);
	}

	public override void Install()
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		base.Install();
		if (Module<BeaconRebalance>.instance.removeOriginals)
		{
			skillFamily1.ReplaceVariant(origSkillDef, skillDef);
			skillFamily2.ReplaceVariant(origSkillDef, skillDef);
		}
		else
		{
			skillFamily1.AddVariant(skillDef);
			skillFamily2.AddVariant(skillDef);
		}
		SkillDef.OnFixedUpdate += new hook_OnFixedUpdate(On_SkillDefFixedUpdate);
	}

	public override void Uninstall()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		base.Uninstall();
		if (Module<BeaconRebalance>.instance.removeOriginals)
		{
			skillFamily1.ReplaceVariant(skillDef, origSkillDef);
			skillFamily2.ReplaceVariant(skillDef, origSkillDef);
		}
		else
		{
			skillFamily1.RemoveVariant(skillDef);
			skillFamily2.RemoveVariant(skillDef);
		}
		SkillDef.OnFixedUpdate -= new hook_OnFixedUpdate(On_SkillDefFixedUpdate);
	}

	private void On_SkillDefFixedUpdate(orig_OnFixedUpdate orig, SkillDef self, GenericSkill skillSlot, float deltaTime)
	{
		if (skillSlot.characterBody.HasBuff(stimmedBuff))
		{
			skillSlot.RunRecharge(deltaTime * rechargeRate);
		}
		orig.Invoke(self, skillSlot, deltaTime);
	}
}
public class HealBeacon : Module<HealBeacon>
{
	public class EntStateCallSupplyDropHealing : CallSupplyDropHealing
	{
		public override void OnEnter()
		{
			((CallSupplyDropBase)this).supplyDropPrefab = Module<HealBeacon>.instance.beaconPrefab;
			((CallSupplyDropBase)this).muzzleflashEffect = Module<BeaconRebalance>.instance.muzzleFlashPrefab;
			((CallSupplyDropBase)this).OnEnter();
		}
	}

	public class EntStateHealingMainState : HealZoneMainState
	{
		public override bool shouldShowEnergy => true;
	}

	private SkillFamily skillFamily1;

	private SkillFamily skillFamily2;

	private SkillDef origSkillDef;

	internal SkillDef skillDef;

	internal GameObject beaconPrefab;

	[AutoConfigRoOSlider("{0:N0} s", 0f, 120f, null, null)]
	[AutoConfig("Lifetime of the T.Beacon: Healing deployable.", AutoConfigFlags.DeferForever, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float skillLifetime { get; private set; } = 20f;


	[AutoConfigRoOSlider("{0:N0} s", 0f, 120f, null, null)]
	[AutoConfig("Cooldown of T.Beacon: Healing.", AutoConfigFlags.DeferForever, new object[]
	{
		0f,
		float.MaxValue
	})]
	public float skillRecharge { get; private set; } = 40f;


	public override string enabledConfigDescription => "Contains config for the T.Beacon: Healing submodule of Modules.BeaconRebalance. Replaces Beacon: Healing.";

	public override bool managedEnable => false;

	public override void SetupAttributes()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		base.SetupAttributes();
		bool flag = default(bool);
		SerializableEntityStateType activationState = ContentAddition.AddEntityState<EntStateCallSupplyDropHealing>(ref flag);
		SerializableEntityStateType mainStateType = ContentAddition.AddEntityState<EntStateHealingMainState>(ref flag);
		skillFamily1 = LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSupplyDrop1SkillFamily");
		skillFamily2 = LegacyResourcesAPI.Load<SkillFamily>("skilldefs/captainbody/CaptainSupplyDrop2SkillFamily");
		origSkillDef = LegacyResourcesAPI.Load<SkillDef>("skilldefs/captainbody/CallSupplyDropHealing");
		skillDef = SkillUtil.CloneSkillDef(origSkillDef);
		skillDef.rechargeStock = 1;
		skillDef.baseRechargeInterval = skillRecharge;
		skillDef.skillName = "AdmiralSupplyDropHealing";
		skillDef.skillNameToken = "ADMIRAL_SUPPLY_HEALING_NAME";
		skillDef.skillDescriptionToken = "ADMIRAL_SUPPLY_HEALING_DESCRIPTION";
		skillDef.activationState = activationState;
		LanguageAPI.Add(skillDef.skillNameToken, "T.Beacon: Healing");
		LanguageAPI.Add(skillDef.skillDescriptionToken, "<style=cIsUtility>Temporary beacon</style>. <style=cIsHealing>Heal</style> all nearby allies for <style=cIsHealing>10%</style> of their <style=cIsHealing>maximum health</style> every second.");
		ContentAddition.AddSkillDef(skillDef);
		GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("prefabs/networkedobjects/captainsupplydrops/CaptainSupplyDrop, Healing"), "TempSetup, BeaconPrefabPrefab", false);
		((Behaviour)val.GetComponent<GenericEnergyComponent>()).enabled = true;
		CaptainBeaconDecayer captainBeaconDecayer = val.AddComponent<CaptainBeaconDecayer>();
		captainBeaconDecayer.lifetime = skillLifetime;
		val.GetComponent<EntityStateMachine>().mainStateType = mainStateType;
		beaconPrefab = PrefabAPI.InstantiateClone(val, "AdmiralSupplyDrop, Healing", true);
		Object.Destroy((Object)(object)val);
	}

	public override void Install()
	{
		base.Install();
		if (Module<BeaconRebalance>.instance.removeOriginals)
		{
			skillFamily1.ReplaceVariant(origSkillDef, skillDef);
			skillFamily2.ReplaceVariant(origSkillDef, skillDef);
		}
		else
		{
			skillFamily1.AddVariant(skillDef);
			skillFamily2.AddVariant(skillDef);
		}
	}

	public override void Uninstall()
	{
		base.Uninstall();
		if (Module<BeaconRebalance>.instance.removeOriginals)
		{
			skillFamily1.ReplaceVariant(skillDef, origSkillDef);
			skillFamily2.ReplaceVariant(skillDef, origSkillDef);
		}
		else
		{
			skillFamily1.RemoveVariant(skillDef);
			skillFamily2.RemoveVariant(skillDef);
		}
	}
}
public class EntStateCallJumpPad : BaseSkillState
{
	public override void OnEnter()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0061: Unknown r