Decompiled source of SagesHouseholdItems v1.0.1

SagesHouseholdItems.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Skills;
using SagesHouseholdItems.Equipment;
using SagesHouseholdItems.Items;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SagesHouseholdItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SagesHouseholdItems")]
[assembly: AssemblyTitle("SagesHouseholdItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SagesHouseholdItems
{
	[BepInPlugin("HIFU.SagesHouseholdItems", "SagesHouseholdItems", "1.0.1")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.SagesHouseholdItems";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "SagesHouseholdItems";

		public const string PluginVersion = "1.0.1";

		public static ConfigFile config;

		public static AssetBundle assetBundle;

		public List<ItemBase> Items = new List<ItemBase>();

		public List<EquipmentBase> Equipments = new List<EquipmentBase>();

		public static ManualLogSource ModLogger;

		public Shader hgStandard;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			ModLogger = ((BaseUnityPlugin)this).Logger;
			config = new ConfigFile(Paths.ConfigPath + "\\HIFU.SagesHouseholdItems.cfg", true);
			assetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("SagesHouseholdItems.dll", "sageshouseholditems"));
			hgStandard = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion();
			Material[] array = assetBundle.LoadAllAssets<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if (((Object)val.shader).name.Contains("hgstandard"))
				{
					val.shader = hgStandard;
				}
			}
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(ItemBase))
				select type;
			foreach (Type item in enumerable)
			{
				ItemBase itemBase = (ItemBase)Activator.CreateInstance(item);
				if (ValidateItem(itemBase, Items))
				{
					itemBase.Init(config);
				}
			}
			IEnumerable<Type> enumerable2 = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(EquipmentBase))
				select type;
			foreach (Type item2 in enumerable2)
			{
				EquipmentBase equipmentBase = (EquipmentBase)Activator.CreateInstance(item2);
				if (ValidateEquipment(equipmentBase, Equipments))
				{
					equipmentBase.Init(config);
				}
			}
		}

		public bool ValidateItem(ItemBase item, List<ItemBase> itemList)
		{
			bool value = config.Bind<bool>("Item: " + item.ConfigName, "Enable Item?", true, "Should this item appear in runs?").Value;
			bool value2 = config.Bind<bool>("Item: " + item.ConfigName, "Blacklist Item from AI Use?", false, "Should the AI not be able to obtain this item?").Value;
			if (value)
			{
				itemList.Add(item);
				if (value2)
				{
					item.AIBlacklisted = true;
				}
			}
			return value;
		}

		public bool ValidateEquipment(EquipmentBase equipment, List<EquipmentBase> equipmentList)
		{
			if (config.Bind<bool>("Equipment: " + equipment.EquipmentName, "Enable Equipment?", true, "Should this equipment appear in runs?").Value)
			{
				equipmentList.Add(equipment);
				return true;
			}
			return false;
		}
	}
}
namespace SagesHouseholdItems.Items
{
	public class CrackedMirror : ItemBase<CrackedMirror>
	{
		public static GameObject bleedVFX;

		public override string ItemName => "Cracked Mirror";

		public override string ConfigName => "Cracked Mirror";

		public override string ItemLangTokenName => "SAGE_CRACKED_MIRROR";

		public override string ItemPickupDesc => "Increase your damage... <color=#FF7F7F>BUT take damage when using skills.</color>";

		public override string ItemFullDescription => "Increase base damage by <style=cIsDamage>60%</style> <style=cStack>(+60% per stack)</style>. Take <style=cIsDamage>1%</style> <style=cStack>(+1% per stack)</style> of <style=cIsHealing>your maximum health</style> as <style=cIsDamage>damage</style> upon using a skill, depending on the <style=cIsUtility>skill's cooldown</style>.";

		public override string ItemLore => "Liar. Slaver. Hoarder.\r\n\r\nThese are the truths which will be revealed to you when you gaze upon this mirror.\r\n\r\nYou have taken our gifts and wasted them, dedicated them to your vermin collection.\r\n\r\nSome day, I will add your horrified face to <i>my</i> collection. It will be etched into this mirror, permanently. I will keep it by my side, as a reminder of your failures.";

		public override ItemTier Tier => (ItemTier)3;

		public override GameObject ItemModel => Main.assetBundle.LoadAsset<GameObject>("Assets/SagesHouseholdItems/CrackedMirror/CrackedMirrorHolder.prefab");

		public override Sprite ItemIcon => Main.assetBundle.LoadAsset<Sprite>("Assets/SagesHouseholdItems/CrackedMirror/texCrackedMirrorIcon.png");

		public override void Init(ConfigFile config)
		{
			CreateConfig(config);
			CreateLang();
			CreateItem();
			Hooks();
		}

		public override void CreateConfig(ConfigFile config)
		{
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public override void Hooks()
		{
			//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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			bleedVFX = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Imp/SpurtImpBlood.prefab").WaitForCompletion(), "CrackedMirrorVFX", false);
			EffectComponent component = bleedVFX.GetComponent<EffectComponent>();
			component.applyScale = true;
			MainModule main = ((Component)bleedVFX.transform.GetChild(0)).GetComponent<ParticleSystem>().main;
			MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
			((MinMaxCurve)(ref startLifetime)).constantMin = 0.3f;
			((MinMaxCurve)(ref startLifetime)).constantMax = 0.5f;
			MinMaxCurve startSpeed = ((MainModule)(ref main)).startSpeed;
			((MinMaxCurve)(ref startSpeed)).constantMin = 5f;
			((MinMaxCurve)(ref startSpeed)).constantMax = 10f;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			MinMaxCurve startDelay = ((MainModule)(ref main)).startDelay;
			((MinMaxCurve)(ref startDelay)).constant = 0.15f;
			MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
			((MinMaxCurve)(ref startSize)).mode = (ParticleSystemCurveMode)0;
			((MinMaxCurve)(ref startSize)).constant = 1f;
			MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
			((MinMaxGradient)(ref startColor)).color = Color32.op_Implicit(new Color32((byte)109, (byte)23, (byte)20, (byte)180));
			ContentAddition.AddEffect(bleedVFX);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
			CharacterBody.OnSkillActivated += new hook_OnSkillActivated(CharacterBody_OnSkillActivated);
		}

		private void CharacterBody_OnSkillActivated(orig_OnSkillActivated orig, CharacterBody self, GenericSkill skill)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			HealthComponent healthComponent = self.healthComponent;
			if (Object.op_Implicit((Object)(object)healthComponent))
			{
				int count = GetCount(self);
				if (count > 0 && skill.cooldownRemaining > 0f && skill.skillDef.skillNameToken != "MAGE_UTILITY_ICE_NAME")
				{
					DamageInfo val = new DamageInfo
					{
						attacker = ((Component)self).gameObject,
						crit = false,
						damage = healthComponent.fullCombinedHealth * 0.02f * (float)count * skill.baseRechargeInterval,
						damageColorIndex = (DamageColorIndex)8,
						force = Vector3.zero,
						inflictor = ((Component)self).gameObject,
						procCoefficient = 0f,
						procChainMask = default(ProcChainMask),
						position = ((Component)self).gameObject.transform.position,
						damageType = (DamageType)2
					};
					healthComponent.TakeDamage(val);
					Vector3 val2 = default(Vector3);
					((Vector3)(ref val2))..ctor(Random.Range(-1f, 1f), Random.Range(-0.5f, 0.5f), Random.Range(-1f, 1f));
					EffectManager.SpawnEffect(bleedVFX, new EffectData
					{
						origin = ((Component)self).gameObject.transform.position + val2,
						scale = Mathf.Sqrt(skill.baseRechargeInterval * 0.5f)
					}, true);
				}
			}
			orig.Invoke(self, skill);
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)sender))
			{
				int count = GetCount(sender);
				if (count > 0)
				{
					args.damageMultAdd += 0.6f * (float)count;
				}
			}
		}
	}
	public abstract class ItemBase<T> : ItemBase where T : ItemBase<T>
	{
		public static T instance { get; private set; }

		public ItemBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBase was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class ItemBase
	{
		public ItemDef ItemDef;

		public abstract string ItemName { get; }

		public abstract string ConfigName { get; }

		public abstract string ItemLangTokenName { get; }

		public abstract string ItemPickupDesc { get; }

		public abstract string ItemFullDescription { get; }

		public abstract string ItemLore { get; }

		public abstract ItemTier Tier { get; }

		public virtual ItemTag[] ItemTags { get; set; } = (ItemTag[])(object)new ItemTag[0];


		public abstract GameObject ItemModel { get; }

		public abstract Sprite ItemIcon { get; }

		public virtual bool CanRemove { get; } = true;


		public virtual bool AIBlacklisted { get; set; } = false;


		public abstract void Init(ConfigFile config);

		public virtual void CreateConfig(ConfigFile config)
		{
		}

		protected virtual void CreateLang()
		{
			LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_NAME", ItemName);
			LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_PICKUP", ItemPickupDesc);
			LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_DESCRIPTION", ItemFullDescription);
			LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_LORE", ItemLore);
		}

		public abstract ItemDisplayRuleDict CreateItemDisplayRules();

		protected void CreateItem()
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			if (AIBlacklisted)
			{
				ItemTags = new List<ItemTag>(ItemTags) { (ItemTag)4 }.ToArray();
			}
			ItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)ItemDef).name = "ITEM_" + ItemLangTokenName;
			ItemDef.nameToken = "ITEM_" + ItemLangTokenName + "_NAME";
			ItemDef.pickupToken = "ITEM_" + ItemLangTokenName + "_PICKUP";
			ItemDef.descriptionToken = "ITEM_" + ItemLangTokenName + "_DESCRIPTION";
			ItemDef.loreToken = "ITEM_" + ItemLangTokenName + "_LORE";
			ItemDef.pickupModelPrefab = ItemModel;
			ItemDef.pickupIconSprite = ItemIcon;
			ItemDef.hidden = false;
			ItemDef.canRemove = CanRemove;
			ItemDef.deprecatedTier = Tier;
			if (ItemTags.Length != 0)
			{
				ItemDef.tags = ItemTags;
			}
			ItemAPI.Add(new CustomItem(ItemDef, CreateItemDisplayRules()));
		}

		public virtual void Hooks()
		{
		}

		public int GetCount(CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return 0;
			}
			return body.inventory.GetItemCount(ItemDef);
		}

		public int GetCount(CharacterMaster master)
		{
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				return 0;
			}
			return master.inventory.GetItemCount(ItemDef);
		}

		public int GetCountSpecific(CharacterBody body, ItemDef itemDef)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return 0;
			}
			return body.inventory.GetItemCount(itemDef);
		}
	}
	public class SagesZippo : ItemBase<SagesZippo>
	{
		public ProcType sagesZippoProcType = (ProcType)1982754;

		public override string ItemName => "Sage's Zippo";

		public override string ConfigName => "Sages Zippo";

		public override string ItemLangTokenName => "SAGE_SAGES_ZIPPO";

		public override string ItemPickupDesc => "Gain a small chance on hit to incinerate enemies.";

		public override string ItemFullDescription => "Gain a <style=cIsDamage>10%</style> chance on hit to incinerate enemies for <style=cIsDamage>500%</style> <style=cStack>(+300% per stack)</style> TOTAL damage.";

		public override string ItemLore => "<style=cMono>//--AUTO-TRANSCRIPTION FROM UES [Redacted] --//</style>\r\n\r\n\"Man, this planet sucks. I haven't slept in days. I can hardly focus on anything with the looming threat of imminent death. Worst of all, it won't stop raining.\"\r\n\r\n\"Want a cigarette?\"\r\n\r\n\"Eh, why not.\"\r\n\r\n\"There's uh, one condition though.\"\r\n\r\n\"Hit me.\"\r\n\r\n\"My lighter is out of fuel. I hope you got a light.\"\r\n\r\n\"Who do you think I am, an amateur? Of course I got a light. Here.\"\r\n\r\n\"Uh... It's out of juice.\"\r\n\r\n[Expletive Redacted]";

		public override ItemTier Tier => (ItemTier)2;

		public override GameObject ItemModel => Main.assetBundle.LoadAsset<GameObject>("Assets/SagesHouseholdItems/SagesZippo/SagesZippoHolder.prefab");

		public override Sprite ItemIcon => Main.assetBundle.LoadAsset<Sprite>("Assets/SagesHouseholdItems/SagesZippo/texSagesZippoIcon.png");

		public override bool AIBlacklisted => true;

		public override void Init(ConfigFile config)
		{
			CreateConfig(config);
			CreateLang();
			CreateItem();
			Hooks();
		}

		public override void CreateConfig(ConfigFile config)
		{
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		public override void Hooks()
		{
			GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt;
		}

		private void GlobalEventManager_onServerDamageDealt(DamageReport report)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody attackerBody = report.attackerBody;
			if (!Object.op_Implicit((Object)(object)attackerBody))
			{
				return;
			}
			CharacterMaster master = attackerBody.master;
			if (!Object.op_Implicit((Object)(object)master))
			{
				return;
			}
			HealthComponent victim = report.victim;
			if (!Object.op_Implicit((Object)(object)victim))
			{
				return;
			}
			Inventory inventory = attackerBody.inventory;
			if (!Object.op_Implicit((Object)(object)inventory))
			{
				return;
			}
			DamageInfo damageInfo = report.damageInfo;
			ProcChainMask procChainMask = damageInfo.procChainMask;
			if (!((ProcChainMask)(ref procChainMask)).HasProc(sagesZippoProcType))
			{
				int count = GetCount(attackerBody);
				float num = 5f + 3f * (float)(count - 1);
				if (count > 0 && Util.CheckRoll(10f * damageInfo.procCoefficient, master))
				{
					InflictDotInfo val = default(InflictDotInfo);
					val.attackerObject = ((Component)attackerBody).gameObject;
					val.victimObject = ((Component)victim).gameObject;
					val.maxStacksFromAttacker = uint.MaxValue;
					val.dotIndex = (DotIndex)1;
					val.totalDamage = damageInfo.damage * num;
					val.damageMultiplier = 4f;
					InflictDotInfo val2 = val;
					StrengthenBurnUtils.CheckDotForUpgrade(inventory, ref val2);
					DotController.InflictDot(ref val2);
					((ProcChainMask)(ref procChainMask)).AddProc(sagesZippoProcType);
				}
			}
		}
	}
}
namespace SagesHouseholdItems.Equipment
{
	public abstract class EquipmentBase<T> : EquipmentBase where T : EquipmentBase<T>
	{
		public static T instance { get; private set; }

		public EquipmentBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting EquipmentBoilerplate/Equipment was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class EquipmentBase
	{
		public EquipmentDef EquipmentDef;

		public abstract string EquipmentName { get; }

		public abstract string EquipmentLangTokenName { get; }

		public abstract string EquipmentPickupDesc { get; }

		public abstract string EquipmentFullDescription { get; }

		public abstract string EquipmentLore { get; }

		public abstract GameObject EquipmentModel { get; }

		public abstract Sprite EquipmentIcon { get; }

		public virtual bool AppearsInSinglePlayer { get; } = true;


		public virtual bool AppearsInMultiPlayer { get; } = true;


		public virtual bool CanDrop { get; } = true;


		public virtual float Cooldown { get; } = 60f;


		public virtual bool EnigmaCompatible { get; } = true;


		public virtual bool IsBoss { get; } = false;


		public virtual bool IsLunar { get; } = false;


		public abstract ItemDisplayRuleDict CreateItemDisplayRules();

		public abstract void Init(ConfigFile config);

		protected virtual void CreateConfig(ConfigFile config)
		{
		}

		protected virtual void CreateLang()
		{
			LanguageAPI.Add("EQUIPMENT_" + EquipmentLangTokenName + "_NAME", EquipmentName);
			LanguageAPI.Add("EQUIPMENT_" + EquipmentLangTokenName + "_PICKUP", EquipmentPickupDesc);
			LanguageAPI.Add("EQUIPMENT_" + EquipmentLangTokenName + "_DESCRIPTION", EquipmentFullDescription);
			LanguageAPI.Add("EQUIPMENT_" + EquipmentLangTokenName + "_LORE", EquipmentLore);
		}

		protected void CreateEquipment()
		{
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			EquipmentDef = ScriptableObject.CreateInstance<EquipmentDef>();
			((Object)EquipmentDef).name = "EQUIPMENT_" + EquipmentLangTokenName;
			EquipmentDef.nameToken = "EQUIPMENT_" + EquipmentLangTokenName + "_NAME";
			EquipmentDef.pickupToken = "EQUIPMENT_" + EquipmentLangTokenName + "_PICKUP";
			EquipmentDef.descriptionToken = "EQUIPMENT_" + EquipmentLangTokenName + "_DESCRIPTION";
			EquipmentDef.loreToken = "EQUIPMENT_" + EquipmentLangTokenName + "_LORE";
			EquipmentDef.pickupModelPrefab = EquipmentModel;
			EquipmentDef.pickupIconSprite = EquipmentIcon;
			EquipmentDef.appearsInSinglePlayer = AppearsInSinglePlayer;
			EquipmentDef.appearsInMultiPlayer = AppearsInMultiPlayer;
			EquipmentDef.canDrop = CanDrop;
			EquipmentDef.cooldown = Cooldown;
			EquipmentDef.enigmaCompatible = EnigmaCompatible;
			EquipmentDef.isBoss = IsBoss;
			EquipmentDef.isLunar = IsLunar;
			ItemAPI.Add(new CustomEquipment(EquipmentDef, CreateItemDisplayRules()));
			EquipmentSlot.PerformEquipmentAction += new hook_PerformEquipmentAction(PerformEquipmentAction);
		}

		private bool PerformEquipmentAction(orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef equipmentDef)
		{
			if ((Object)(object)equipmentDef == (Object)(object)EquipmentDef)
			{
				return ActivateEquipment(self);
			}
			return orig.Invoke(self, equipmentDef);
		}

		protected abstract bool ActivateEquipment(EquipmentSlot slot);

		public virtual void Hooks()
		{
		}
	}
	public class MysteriousRemote : EquipmentBase
	{
		public class MuteController : NetworkBehaviour
		{
			public float duration = 10f;

			public float force;

			public CharacterBody body;

			public float mass;

			public Rigidbody rigidBody;

			public CharacterMotor characterMotor;

			public DamageInfo damageInfo;

			public float timer = 0f;

			public SkillLocator skillLocator;

			public void Start()
			{
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: 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_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Expected O, but got Unknown
				body = ((Component)this).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)body.characterMotor))
				{
					characterMotor = body.characterMotor;
					mass = characterMotor.mass;
				}
				else if (Object.op_Implicit((Object)(object)body.rigidbody))
				{
					rigidBody = body.rigidbody;
					mass = rigidBody.mass;
				}
				skillLocator = body.skillLocator;
				if (Object.op_Implicit((Object)(object)skillLocator.secondary))
				{
					skillLocator.secondary.SetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
				if (Object.op_Implicit((Object)(object)skillLocator.utility))
				{
					skillLocator.utility.SetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
				if (Object.op_Implicit((Object)(object)skillLocator.special))
				{
					skillLocator.special.SetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
				if (mass < 50f)
				{
					mass = 50f;
				}
				force = 50f * mass;
				damageInfo = new DamageInfo
				{
					attacker = null,
					inflictor = null,
					damage = 1f,
					damageColorIndex = (DamageColorIndex)0,
					damageType = (DamageType)0,
					crit = false,
					dotIndex = (DotIndex)(-1),
					force = Vector3.down * force * Time.fixedDeltaTime,
					position = ((Component)this).transform.position,
					procChainMask = default(ProcChainMask),
					procCoefficient = 0f
				};
			}

			public void Ground()
			{
				//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_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Expected O, but got Unknown
				if (NetworkServer.active)
				{
					damageInfo = new DamageInfo
					{
						attacker = null,
						inflictor = null,
						damage = 0f,
						damageColorIndex = (DamageColorIndex)0,
						damageType = (DamageType)0,
						crit = false,
						dotIndex = (DotIndex)(-1),
						force = Vector3.down * force * Time.fixedDeltaTime,
						position = ((Component)this).transform.position,
						procChainMask = default(ProcChainMask),
						procCoefficient = 0f
					};
					if (Object.op_Implicit((Object)(object)characterMotor))
					{
						body.healthComponent.TakeDamageForce(damageInfo, false, false);
					}
					else if (Object.op_Implicit((Object)(object)rigidBody))
					{
						body.healthComponent.TakeDamageForce(damageInfo, false, false);
					}
				}
			}

			public void FixedUpdate()
			{
				timer += Time.fixedDeltaTime;
				if (timer >= duration)
				{
					Object.Destroy((Object)(object)this);
				}
				else
				{
					Ground();
				}
			}

			public void Refresh()
			{
				timer = 0f;
			}

			public void OnDestroy()
			{
				if (Object.op_Implicit((Object)(object)skillLocator.secondary))
				{
					skillLocator.secondary.UnsetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
				if (Object.op_Implicit((Object)(object)skillLocator.utility))
				{
					skillLocator.utility.UnsetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
				if (Object.op_Implicit((Object)(object)skillLocator.special))
				{
					skillLocator.special.UnsetSkillOverride((object)body, uselessSkillDef, (SkillOverridePriority)3);
				}
			}
		}

		public static readonly SphereSearch muteSphereSearch = new SphereSearch();

		public static readonly List<HurtBox> muteHurtBoxBuffer = new List<HurtBox>();

		public static BuffDef muteBuff;

		public static SkillDef uselessSkillDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Captain/CaptainSkillDisconnected.asset").WaitForCompletion();

		public static GameObject muteVFX;

		public override string EquipmentName => "Mysterious Remote";

		public override string EquipmentLangTokenName => "SAGE_MYSTERIOUS_REMOTE";

		public override string EquipmentPickupDesc => "Silence and force nearby enemies to the ground.";

		public override string EquipmentFullDescription => "<style=cIsUtility>Silence</style> enemies within an <style=cIsUtility>18m</style> radius, <style=cIsUtility>disabling their non-primary skills</style> and <style=cIsUtility>forcing them to the ground</style> for <style=cIsUtility>10s</style>.";

		public override string EquipmentLore => "<style=cMono>//--AUTO-TRANSCRIPTION FROM ROOM 5012A OF UES [Redacted]--//</style>\r\n\r\n\"Look at this.\"\r\n\r\n\"What is that, the remote to your [Redacted]?\"\r\n\r\n\"Heh. No. I don't know what it is, actually. We found it on the planet.\"\r\n\r\n\"Press a button, see what it does.\"\r\n\r\n\"Sure, what's the worst that could happen.\"\r\n\r\n...\r\n\r\n\"Nothing happened.\"\r\n\r\n...\r\n\r\n\"Dude? You good?\"\r\n\r\n...\r\n\r\n\"Are you...?\"\r\n\r\n...\r\n\r\n\"Hahaha! That's mint! Maybe I'll keep you like this so I don't have to hear any more of your [Expletive Redacted] jokes.\"\r\n\r\n...";

		public override float Cooldown => 30f;

		public override GameObject EquipmentModel => Main.assetBundle.LoadAsset<GameObject>("Assets/SagesHouseholdItems/MysteriousRemote/MysteriousRemoteHolder.prefab");

		public override Sprite EquipmentIcon => Main.assetBundle.LoadAsset<Sprite>("Assets/SagesHouseholdItems/MysteriousRemote/texMysteriousRemoteIcon.png");

		public override void Init(ConfigFile config)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			CreateConfig(config);
			CreateLang();
			CreateEquipment();
			Hooks();
			muteBuff = ScriptableObject.CreateInstance<BuffDef>();
			muteBuff.canStack = false;
			muteBuff.isDebuff = true;
			muteBuff.isCooldown = true;
			muteBuff.isHidden = false;
			muteBuff.buffColor = Color32.op_Implicit(new Color32((byte)220, (byte)220, (byte)220, byte.MaxValue));
			muteBuff.iconSprite = Main.assetBundle.LoadAsset<Sprite>("Assets/SagesHouseholdItems/texBuffMuted.png");
			ContentAddition.AddBuffDef(muteBuff);
			muteVFX = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/IgniteOnKill/IgniteExplosionVFX.prefab").WaitForCompletion(), "MysteriousRemoteVFX", false);
			MainModule main = muteVFX.GetComponent<ParticleSystem>().main;
			MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
			((MinMaxGradient)(ref startColor)).color = Color32.op_Implicit(new Color32((byte)140, (byte)140, (byte)140, byte.MaxValue));
			Transform transform = muteVFX.transform;
			ParticleSystemRenderer component = ((Component)transform.GetChild(0)).GetComponent<ParticleSystemRenderer>();
			Material val = Object.Instantiate<Material>(Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/IgniteOnKill/matOmniHitspark3Gasoline.mat").WaitForCompletion());
			val.SetTexture("_RemapTex", (Texture)(object)Main.assetBundle.LoadAsset<Texture2D>("Assets/SagesHouseholdItems/texRampGray.png"));
			((Renderer)component).material = val;
			Light component2 = ((Component)transform.GetChild(1)).GetComponent<Light>();
			component2.color = Color32.op_Implicit(new Color32((byte)120, (byte)120, (byte)120, byte.MaxValue));
			ColorOverLifetimeModule colorOverLifetime = ((Component)transform.GetChild(2)).GetComponent<ParticleSystem>().colorOverLifetime;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(Color32.op_Implicit(new Color32((byte)150, (byte)150, (byte)150, byte.MaxValue)), 0f),
				new GradientColorKey(Color32.op_Implicit(new Color32((byte)120, (byte)120, (byte)120, byte.MaxValue)), 0.424f),
				new GradientColorKey(Color.black, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			ContentAddition.AddEffect(muteVFX);
		}

		public override void Hooks()
		{
		}

		protected override void CreateConfig(ConfigFile config)
		{
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			return new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
		}

		protected override bool ActivateEquipment(EquipmentSlot slot)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			muteSphereSearch.radius = 18f;
			muteSphereSearch.mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask;
			CharacterBody characterBody = slot.characterBody;
			if (Object.op_Implicit((Object)(object)characterBody))
			{
				TeamIndex teamIndex = characterBody.teamComponent.teamIndex;
				muteSphereSearch.origin = characterBody.corePosition;
				muteSphereSearch.RefreshCandidates();
				muteSphereSearch.FilterCandidatesByDistinctHurtBoxEntities();
				muteSphereSearch.OrderCandidatesByDistance();
				muteSphereSearch.GetHurtBoxes(muteHurtBoxBuffer);
				muteSphereSearch.ClearCandidates();
				for (int i = 0; i < muteHurtBoxBuffer.Count; i++)
				{
					HurtBox val = muteHurtBoxBuffer[i];
					HealthComponent healthComponent = val.healthComponent;
					if (!Object.op_Implicit((Object)(object)healthComponent))
					{
						continue;
					}
					CharacterBody body = healthComponent.body;
					TeamIndex teamIndex2 = body.teamComponent.teamIndex;
					if (Object.op_Implicit((Object)(object)body) && teamIndex2 != teamIndex)
					{
						body.AddTimedBuffAuthority(muteBuff.buffIndex, 10f);
						if ((Object)(object)((Component)body).GetComponent<MuteController>() == (Object)null)
						{
							((Component)body).gameObject.AddComponent<MuteController>();
						}
						else
						{
							((Component)body).GetComponent<MuteController>().Refresh();
						}
					}
				}
			}
			Util.PlaySound("Play_nullifier_impact", ((Component)slot).gameObject);
			EffectManager.SpawnEffect(muteVFX, new EffectData
			{
				origin = characterBody.corePosition,
				scale = 18f
			}, true);
			muteHurtBoxBuffer.Clear();
			return true;
		}
	}
}