Decompiled source of KatsuroItems v1.1.0

KatsuroItems.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using KatsuroItems.Items;
using KatsuroItems.Items.Components;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KatsuroItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e2ed07c5dd9cfd475998e69d58d4227d78a7e8e1")]
[assembly: AssemblyProduct("KatsuroItems")]
[assembly: AssemblyTitle("KatsuroItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace KatsuroItems
{
	public class Assets
	{
		public static AssetBundle assetBundle;

		public static Material matSelfDestructOverlay;

		public static GameObject selfDestructExplosionPrefab;

		public static void Init()
		{
			CreateSelfDestructOverlay();
			CreateSelfDestructExplosion();
			GetAssetBundle();
		}

		private static void CreateSelfDestructOverlay()
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			matSelfDestructOverlay = new Material(Addressables.LoadAssetAsync<Material>((object)RoR2_Base_Common.matEnergyShield_mat).WaitForCompletion());
			matSelfDestructOverlay.SetFloat("_OffsetAmount", 0.07f);
			matSelfDestructOverlay.SetColor("_TintColor", new Color(1f, 0f, 0f, 1f));
		}

		private static void CreateSelfDestructExplosion()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00a7: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			selfDestructExplosionPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_LaserTurbine.LaserTurbineBombExplosion_prefab).WaitForCompletion(), "SelfDestructExplosion", false);
			Transform val = selfDestructExplosionPrefab.transform.Find("Sparklers/SubEmitter0");
			Material val2 = new Material(((Renderer)((Component)val).GetComponent<ParticleSystemRenderer>()).sharedMaterial);
			val2.SetTexture("_RemapTex", Addressables.LoadAssetAsync<Texture>((object)RoR2_Base_Common_ColorRamps.texRampMageFire_png).WaitForCompletion());
			((Renderer)((Component)val).GetComponent<ParticleSystemRenderer>()).sharedMaterial = val2;
			Transform val3 = selfDestructExplosionPrefab.transform.Find("Sparklers/Fireball");
			Material val4 = new Material(((Renderer)((Component)val3).GetComponent<ParticleSystemRenderer>()).sharedMaterial);
			val4.SetTexture("_RemapTex", Addressables.LoadAssetAsync<Texture>((object)RoR2_Base_Common_ColorRamps.texRampMageFire_png).WaitForCompletion());
			((Renderer)((Component)val3).GetComponent<ParticleSystemRenderer>()).sharedMaterial = val4;
			Transform val5 = selfDestructExplosionPrefab.transform.Find("Sparklers/Flash");
			Material val6 = new Material(((Renderer)((Component)val5).GetComponent<ParticleSystemRenderer>()).sharedMaterial);
			val6.SetTexture("_RemapTex", Addressables.LoadAssetAsync<Texture>((object)RoR2_Base_Common_ColorRamps.texRampMageFire_png).WaitForCompletion());
			((Renderer)((Component)val5).GetComponent<ParticleSystemRenderer>()).sharedMaterial = val6;
			Transform val7 = selfDestructExplosionPrefab.transform.Find("Slashes");
			((Component)val7).transform.localScale = Vector3.one * 30f;
			ParticleSystem component = ((Component)val7).gameObject.GetComponent<ParticleSystem>();
			MainModule main = component.main;
			((MainModule)(ref main)).loop = false;
			Material val8 = new Material(((Renderer)((Component)val7).GetComponent<ParticleSystemRenderer>()).sharedMaterial);
			val8.SetTexture("_RemapTex", Addressables.LoadAssetAsync<Texture>((object)RoR2_DLC2_Chef.texChefOilDecalRamp_png).WaitForCompletion());
			((Renderer)((Component)val7).GetComponent<ParticleSystemRenderer>()).sharedMaterial = val8;
			GameObject gameObject = ((Component)selfDestructExplosionPrefab.transform.Find("EvisOverlapProjectileGhost")).gameObject;
			Object.Destroy((Object)(object)gameObject.GetComponent<DetachParticleOnDestroyAndEndEmission>());
			Transform val9 = selfDestructExplosionPrefab.transform.Find("Point Light");
			((Component)val9).GetComponent<Light>().color = new Color(1f, 0.16f, 0f, 1f);
			foreach (Transform componentInChild in selfDestructExplosionPrefab.GetComponentInChildren<Transform>())
			{
				Transform val10 = componentInChild;
				Transform transform = ((Component)val10).transform;
				transform.localScale *= 1.4f;
			}
			Content.CreateAndAddEffectDef(selfDestructExplosionPrefab);
		}

		private static void GetAssetBundle()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("KatsuroItems.katsuroitems");
			if (stream != null)
			{
				assetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
	public static class Buffs
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static StatHookEventHandler <0>__SnowboardSpeedIncrease;
		}

		public static BuffDef snowboardBuff;

		public static BuffDef selfDestructBuff;

		public static void Init()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			snowboardBuff = Content.CreateAndAddBuff("SnowboardBuff", LegacyResourcesAPI.Load<BuffDef>("BuffDefs/WhipBoost").iconSprite, Color.white, canStack: true, isDebuff: false);
			selfDestructBuff = Content.CreateAndAddBuff("SelfDestructBuff", Addressables.LoadAssetAsync<BuffDef>((object)RoR2_Base_Grandparent.bdOverheat_asset).WaitForCompletion().iconSprite, new Color(1f, 0f, 0f), canStack: false, isDebuff: true);
			SetupBehaviours();
		}

		private static void SetupBehaviours()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			object obj = <>O.<0>__SnowboardSpeedIncrease;
			if (obj == null)
			{
				StatHookEventHandler val = SnowboardSpeedIncrease;
				<>O.<0>__SnowboardSpeedIncrease = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}

		private static void SnowboardSpeedIncrease(CharacterBody self, StatHookEventArgs args)
		{
			if (self.HasBuff(snowboardBuff))
			{
				int buffCount = self.GetBuffCount(snowboardBuff);
				args.moveSpeedMultAdd += (float)buffCount * 0.05f;
			}
		}
	}
	internal class Content
	{
		internal static void AddBuffDef(BuffDef buffDef)
		{
			ContentPacks.buffDefs.Add(buffDef);
		}

		internal static BuffDef CreateAndAddBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = buffName;
			val.buffColor = buffColor;
			val.canStack = canStack;
			val.isDebuff = isDebuff;
			val.eliteDef = null;
			val.iconSprite = buffIcon;
			AddBuffDef(val);
			return val;
		}

		internal static void AddEffectDef(EffectDef effectDef)
		{
			ContentPacks.effectDefs.Add(effectDef);
		}

		internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			EffectDef val = new EffectDef(effectPrefab);
			AddEffectDef(val);
			return val;
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public static List<GameObject> bodyPrefabs = new List<GameObject>();

		public static List<GameObject> masterPrefabs = new List<GameObject>();

		public static List<GameObject> projectilePrefabs = new List<GameObject>();

		public static List<SurvivorDef> survivorDefs = new List<SurvivorDef>();

		public static List<UnlockableDef> unlockableDefs = new List<UnlockableDef>();

		public static List<SkillFamily> skillFamilies = new List<SkillFamily>();

		public static List<SkillDef> skillDefs = new List<SkillDef>();

		public static List<Type> entityStates = new List<Type>();

		public static List<BuffDef> buffDefs = new List<BuffDef>();

		public static List<EffectDef> effectDefs = new List<EffectDef>();

		public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>();

		public string identifier => "mwmw.KatsuroItems";

		public void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray());
			contentPack.masterPrefabs.Add(masterPrefabs.ToArray());
			contentPack.projectilePrefabs.Add(projectilePrefabs.ToArray());
			contentPack.survivorDefs.Add(survivorDefs.ToArray());
			contentPack.unlockableDefs.Add(unlockableDefs.ToArray());
			contentPack.skillDefs.Add(skillDefs.ToArray());
			contentPack.skillFamilies.Add(skillFamilies.ToArray());
			contentPack.entityStateTypes.Add(entityStates.ToArray());
			contentPack.buffDefs.Add(buffDefs.ToArray());
			contentPack.effectDefs.Add(effectDefs.ToArray());
			contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

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

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	public static class Hooks
	{
		public delegate void Handle_HealthComponentTakeDamageProcess(HealthComponent self, DamageInfo damageInfo);

		public delegate void Handle_CharacterBodyStart(CharacterBody self);

		public delegate void Handle_GlobalEventManagerOnCharacterHitGroundServer(GlobalEventManager self, CharacterBody characterBody, HitGroundInfo hitGroundInfo);

		public delegate void Handle_CharacterModelUpdateOverlays(CharacterModel self);

		public delegate void IL_Handle_EquipmentSlotOnEquipmentExecuted(ILContext il);

		public delegate void IL_Handle_GlobalEventManagerOnCharacterHitGroundServer(ILContext il);

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TakeDamageProcess <0>__HealthComponent_TakeDamageProcess;

			public static hook_Start <1>__CharacterBody_Start;

			public static hook_OnCharacterHitGroundServer <2>__GlobalEventManager_OnCharacterHitGroundServer;

			public static hook_UpdateOverlays <3>__CharacterModel_UpdateOverlays;

			public static Manipulator <4>__IL_EquipmentSlot_OnEquipmentExecuted;

			public static Manipulator <5>__IL_GlobalEventManager_OnCharacterHitGroundServer;
		}

		public static Handle_HealthComponentTakeDamageProcess Handle_HealthComponentTakeDamageProcess_Actions;

		public static Handle_CharacterBodyStart Handle_CharacterBodyStart_Actions;

		public static Handle_GlobalEventManagerOnCharacterHitGroundServer Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions;

		public static Handle_CharacterModelUpdateOverlays Handle_CharacterModelUpdateOverlays_Actions;

		public static IL_Handle_EquipmentSlotOnEquipmentExecuted IL_Handle_EquipmentSlotOnEquipmentExecuted_Actions;

		public static IL_Handle_GlobalEventManagerOnCharacterHitGroundServer IL_Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions;

		internal static void HealthComponent_TakeDamageProcess(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
		{
			orig.Invoke(self, damageInfo);
			Handle_HealthComponentTakeDamageProcess_Actions(self, damageInfo);
		}

		internal static void CharacterBody_Start(orig_Start orig, CharacterBody self)
		{
			orig.Invoke(self);
			Handle_CharacterBodyStart_Actions(self);
		}

		internal static void GlobalEventManager_OnCharacterHitGroundServer(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody characterBody, HitGroundInfo hitGroundInfo)
		{
			//IL_0004: 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)
			orig.Invoke(self, characterBody, hitGroundInfo);
			Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions(self, characterBody, hitGroundInfo);
		}

		internal static void CharacterModel_UpdateOverlays(orig_UpdateOverlays orig, CharacterModel self)
		{
			orig.Invoke(self);
			Handle_CharacterModelUpdateOverlays_Actions(self);
		}

		internal static void IL_EquipmentSlot_OnEquipmentExecuted(ILContext il)
		{
			IL_Handle_EquipmentSlotOnEquipmentExecuted_Actions(il);
		}

		internal static void IL_GlobalEventManager_OnCharacterHitGroundServer(ILContext il)
		{
			IL_Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions(il);
		}

		public static void AddHooks()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//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_0087: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00dc: 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_00e7: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			if (Handle_HealthComponentTakeDamageProcess_Actions != null)
			{
				object obj = <>O.<0>__HealthComponent_TakeDamageProcess;
				if (obj == null)
				{
					hook_TakeDamageProcess val = HealthComponent_TakeDamageProcess;
					<>O.<0>__HealthComponent_TakeDamageProcess = val;
					obj = (object)val;
				}
				HealthComponent.TakeDamageProcess += (hook_TakeDamageProcess)obj;
			}
			if (Handle_CharacterBodyStart_Actions != null)
			{
				object obj2 = <>O.<1>__CharacterBody_Start;
				if (obj2 == null)
				{
					hook_Start val2 = CharacterBody_Start;
					<>O.<1>__CharacterBody_Start = val2;
					obj2 = (object)val2;
				}
				CharacterBody.Start += (hook_Start)obj2;
			}
			if (Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions != null)
			{
				object obj3 = <>O.<2>__GlobalEventManager_OnCharacterHitGroundServer;
				if (obj3 == null)
				{
					hook_OnCharacterHitGroundServer val3 = GlobalEventManager_OnCharacterHitGroundServer;
					<>O.<2>__GlobalEventManager_OnCharacterHitGroundServer = val3;
					obj3 = (object)val3;
				}
				GlobalEventManager.OnCharacterHitGroundServer += (hook_OnCharacterHitGroundServer)obj3;
			}
			if (Handle_CharacterModelUpdateOverlays_Actions != null)
			{
				object obj4 = <>O.<3>__CharacterModel_UpdateOverlays;
				if (obj4 == null)
				{
					hook_UpdateOverlays val4 = CharacterModel_UpdateOverlays;
					<>O.<3>__CharacterModel_UpdateOverlays = val4;
					obj4 = (object)val4;
				}
				CharacterModel.UpdateOverlays += (hook_UpdateOverlays)obj4;
			}
			if (IL_Handle_EquipmentSlotOnEquipmentExecuted_Actions != null)
			{
				object obj5 = <>O.<4>__IL_EquipmentSlot_OnEquipmentExecuted;
				if (obj5 == null)
				{
					Manipulator val5 = IL_EquipmentSlot_OnEquipmentExecuted;
					<>O.<4>__IL_EquipmentSlot_OnEquipmentExecuted = val5;
					obj5 = (object)val5;
				}
				EquipmentSlot.OnEquipmentExecuted_byte_byte_EquipmentIndex += (Manipulator)obj5;
			}
			if (IL_Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions != null)
			{
				object obj6 = <>O.<5>__IL_GlobalEventManager_OnCharacterHitGroundServer;
				if (obj6 == null)
				{
					Manipulator val6 = IL_GlobalEventManager_OnCharacterHitGroundServer;
					<>O.<5>__IL_GlobalEventManager_OnCharacterHitGroundServer = val6;
					obj6 = (object)val6;
				}
				GlobalEventManager.OnCharacterHitGroundServer += (Manipulator)obj6;
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("mwmw.KatsuroItems", "KatsuroItems", "1.1.0")]
	public class KatsuroItems : BaseUnityPlugin
	{
		public const string PluginGUID = "mwmw.KatsuroItems";

		public const string PluginAuthor = "mwmw";

		public const string PluginName = "KatsuroItems";

		public const string PluginVersion = "1.1.0";

		public static ConfigFile config;

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			config = ((BaseUnityPlugin)this).Config;
			RegisterNetMessages();
			Buffs.Init();
			Assets.Init();
			Options.Init();
			BloodVial.Init();
			FreeSpinTicket.Init();
			SelfDestructDevice.Init();
			Snowboard.Init();
			new ContentPacks().Init();
			Hooks.AddHooks();
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(OnLoadFinished));
		}

		private void OnLoadFinished()
		{
			Options.OnLoadFinished();
		}

		private void RegisterNetMessages()
		{
			NetworkingAPI.RegisterMessageType<SDDComponent.SyncRedOverlay>();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class Options
	{
		private static bool? _rooEnabled;

		public static bool rooEnabled
		{
			get
			{
				if (!_rooEnabled.HasValue)
				{
					_rooEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _rooEnabled.Value;
			}
		}

		public static ConfigEntry<float> selfDestructBaseDamage { get; set; }

		public static ConfigEntry<float> selfDestructStackingDamage { get; set; }

		private static void OnSelfDestructDamageChanged()
		{
			SelfDestructDevice.baseDamageCoefficient = selfDestructBaseDamage.Value / 100f;
			SelfDestructDevice.stackingDamageCoefficient = selfDestructStackingDamage.Value / 100f;
		}

		public static void Init()
		{
			selfDestructBaseDamage = KatsuroItems.config.Bind<float>("Self Destruct Device", "Base Damage", 2000f, "The damage percentage of the first stack of Self Destruct Device.");
			selfDestructBaseDamage.SettingChanged += delegate
			{
				OnSelfDestructDamageChanged();
			};
			selfDestructStackingDamage = KatsuroItems.config.Bind<float>("Self Destruct Device", "Stacking Damage", 2000f, "The damage percentage of additional stacks of Self Destruct Device.");
			selfDestructStackingDamage.SettingChanged += delegate
			{
				OnSelfDestructDamageChanged();
			};
			if (rooEnabled)
			{
				RoOInit();
			}
		}

		public static void OnLoadFinished()
		{
			OnSelfDestructDamageChanged();
		}

		private static void RoOInit()
		{
			//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_0016: 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_0031: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0067: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(selfDestructBaseDamage, new StepSliderConfig
			{
				min = 0f,
				max = 20000f,
				increment = 10f
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(selfDestructStackingDamage, new StepSliderConfig
			{
				min = 0f,
				max = 20000f,
				increment = 10f
			}));
			ModSettingsManager.SetModDescription("Config options for KatsuroItems.");
			ModSettingsManager.SetModIcon(Assets.assetBundle.LoadAsset<Sprite>("icon"));
		}
	}
}
namespace KatsuroItems.Items
{
	public abstract class BaseItem<T> where T : BaseItem<T>
	{
		protected static string prefix = "DEFAULT_DEFAULT";

		protected static string name = "DEFAULT NAME";

		protected static string desc = "DEFAULT DESC";

		protected static string pickup = "DEFAULT PICKUP";

		protected static string lore = "<style=cMono>///EMPTY TRANSMISSION///</style>";

		protected static Func<ItemTierDef> itemTierDef;

		protected static Func<Sprite> pickupIconSprite;

		protected static Func<GameObject> pickupModelPrefab;

		protected static bool canRemove = true;

		protected static bool hidden = false;

		protected static Func<ItemDisplayRuleDict> itemDisplayRuleDict;

		protected static ItemDef itemDef;

		protected static void CreateItem()
		{
			//IL_00a8: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)itemDef).name = prefix + "_NAME";
			itemDef.nameToken = prefix + "_NAME";
			itemDef.pickupToken = prefix + "_PICKUP";
			itemDef.descriptionToken = prefix + "_DESC";
			itemDef.loreToken = prefix + "_LORE";
			itemDef._itemTierDef = itemTierDef?.Invoke() ?? Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			itemDef.pickupIconSprite = pickupIconSprite?.Invoke() ?? Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			itemDef.pickupModelPrefab = pickupModelPrefab?.Invoke() ?? Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			LanguageAPI.Add(prefix + "_NAME", name);
			LanguageAPI.Add(prefix + "_DESC", desc);
			LanguageAPI.Add(prefix + "_PICKUP", pickup);
			LanguageAPI.Add(prefix + "_LORE", lore);
			itemDef.canRemove = canRemove;
			itemDef.hidden = hidden;
			ItemDisplayRuleDict val = (ItemDisplayRuleDict)(((object)itemDisplayRuleDict?.Invoke()) ?? ((object)new ItemDisplayRuleDict((ItemDisplayRule[])null)));
			ItemAPI.Add(new CustomItem(itemDef, val));
		}

		public static void Init()
		{
			CreateItem();
		}
	}
	public class BloodVial : BaseItem<BloodVial>
	{
		public new static void Init()
		{
			BaseItem<BloodVial>.prefix = "KATSUROITEMS_BLOODVIAL";
			BaseItem<BloodVial>.name = "Blood Vial";
			BaseItem<BloodVial>.desc = "After dealing damage to an enemy above <style=cIsDamage>95% health</style>, heal for <style=cIsHealing>2%</style> <style=cStack>(+2% per stack)</style> of your <style=cIsHealing>maximum health</style>.";
			BaseItem<BloodVial>.pickup = "Heal when hitting enemies above 95% health.";
			BaseItem<BloodVial>.itemTierDef = () => Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			BaseItem<BloodVial>.pickupIconSprite = () => Assets.assetBundle.LoadAsset<Sprite>("texInfusionIcon");
			BaseItem<BloodVial>.pickupModelPrefab = () => Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Infusion.PickupInfusion_prefab).WaitForCompletion();
			BaseItem<BloodVial>.canRemove = true;
			BaseItem<BloodVial>.hidden = false;
			Hooks.Handle_HealthComponentTakeDamageProcess_Actions = (Hooks.Handle_HealthComponentTakeDamageProcess)Delegate.Combine(Hooks.Handle_HealthComponentTakeDamageProcess_Actions, new Hooks.Handle_HealthComponentTakeDamageProcess(HealOnHighVictimHealth));
			BaseItem<BloodVial>.Init();
		}

		private static void HealOnHighVictimHealth(HealthComponent self, DamageInfo damageInfo)
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = (Object.op_Implicit((Object)(object)damageInfo?.attacker) ? damageInfo.attacker.GetComponent<CharacterBody>() : null);
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				CharacterMaster master = val.master;
				obj = ((master != null) ? master.inventory : null);
			}
			Inventory val2 = (Inventory)obj;
			HealthComponent val3 = ((val != null) ? val.healthComponent : null);
			if (!(damageInfo.damage <= 0f) && Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val2) && ((self != null) ? new float?(self.combinedHealth) : null) + damageInfo.damage >= ((self != null) ? new float?(self.fullCombinedHealth * 0.95f) : null))
			{
				int itemCountEffective = val2.GetItemCountEffective(BaseItem<BloodVial>.itemDef.itemIndex);
				if (itemCountEffective > 0)
				{
					val3.HealFraction(0.02f * (float)itemCountEffective, default(ProcChainMask));
				}
			}
		}
	}
	public class FreeSpinTicket : BaseItem<FreeSpinTicket>
	{
		public new static void Init()
		{
			BaseItem<FreeSpinTicket>.prefix = "KATSUROITEMS_FREESPINTICKET";
			BaseItem<FreeSpinTicket>.name = "Free Spin Ticket";
			BaseItem<FreeSpinTicket>.desc = "<style=cIsUtility>40%</style> <style=cStack>(+10% per stack)</style> chance to <style=cIsUtility>ignore the cooldown</style> of a skill or equipment after it's used.";
			BaseItem<FreeSpinTicket>.pickup = "Chance to ignore skill and equipment cooldowns.";
			BaseItem<FreeSpinTicket>.itemTierDef = () => Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
			BaseItem<FreeSpinTicket>.pickupIconSprite = () => Assets.assetBundle.LoadAsset<Sprite>("texIncreaseDamageOnMultiKillIcon");
			BaseItem<FreeSpinTicket>.pickupModelPrefab = () => Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_Items_IncreaseDamageOnMultiKill.PickupIncreaseDamageOnMultiKill_prefab).WaitForCompletion();
			BaseItem<FreeSpinTicket>.canRemove = true;
			BaseItem<FreeSpinTicket>.hidden = false;
			Hooks.Handle_CharacterBodyStart_Actions = (Hooks.Handle_CharacterBodyStart)Delegate.Combine(Hooks.Handle_CharacterBodyStart_Actions, new Hooks.Handle_CharacterBodyStart(ResetSkillCooldownChance));
			Hooks.IL_Handle_EquipmentSlotOnEquipmentExecuted_Actions = (Hooks.IL_Handle_EquipmentSlotOnEquipmentExecuted)Delegate.Combine(Hooks.IL_Handle_EquipmentSlotOnEquipmentExecuted_Actions, new Hooks.IL_Handle_EquipmentSlotOnEquipmentExecuted(ResetEquipmentCooldownChance));
			BaseItem<FreeSpinTicket>.Init();
		}

		private static IEnumerator WaitForStockChange(GenericSkill skill)
		{
			for (int _ = 0; _ < 2; _++)
			{
				yield return null;
			}
			if (skill.stock <= skill.maxStock)
			{
				skill.stock += 1;
			}
		}

		private static void ResetSkillCooldownChance(CharacterBody body)
		{
			Action<GenericSkill> action = delegate(GenericSkill skill)
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				CharacterBody val = ((skill != null) ? skill.characterBody : null);
				if (!((Object)(object)((val != null) ? val.inventory : null) == (Object)null))
				{
					int itemCountEffective = val.inventory.GetItemCountEffective(BaseItem<FreeSpinTicket>.itemDef.itemIndex);
					if (itemCountEffective > 0 && Util.CheckRoll(100f * (1f - 0.6f * Mathf.Pow(0.8f, (float)itemCountEffective - 1f)), val.master))
					{
						((MonoBehaviour)val).StartCoroutine(WaitForStockChange(skill));
					}
				}
			};
			body.onSkillActivatedAuthority += action;
		}

		private static void ResetEquipmentCooldownChance(ILContext il)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Func<EquipmentSlot, bool> func = delegate(EquipmentSlot equipmentSlot)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				CharacterBody val3 = ((equipmentSlot != null) ? equipmentSlot.characterBody : null);
				if ((Object)(object)((val3 != null) ? val3.inventory : null) == (Object)null)
				{
					return false;
				}
				int itemCountEffective = val3.inventory.GetItemCountEffective(BaseItem<FreeSpinTicket>.itemDef.itemIndex);
				return (itemCountEffective > 0 && Util.CheckRoll(100f * (1f - 0.6f * Mathf.Pow(0.8f, (float)itemCountEffective - 1f)), val3.master)) ? true : false;
			};
			ILCursor val = new ILCursor(il);
			int num4 = default(int);
			int num3 = default(int);
			int num2 = default(int);
			int num = default(int);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num4),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<EquipmentSlot>(x, "inventory"),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num3),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num2),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "DeductEquipmentCharges")
			}))
			{
				ILLabel val2 = val.DefineLabel();
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<EquipmentSlot, bool>>(func);
				val.Emit(OpCodes.Brtrue, (object)val2);
				val.Emit(OpCodes.Ldarg_0);
				val.Index += 5;
				val.MarkLabel(val2);
			}
			else
			{
				Log.Error("ResetEquipmentCooldownChance ILHook failed. Free Spin Ticket will not work on equipment.");
			}
		}
	}
	public class SelfDestructDevice : BaseItem<SelfDestructDevice>
	{
		public static float baseDamageCoefficient;

		public static float stackingDamageCoefficient;

		public new static void Init()
		{
			BaseItem<SelfDestructDevice>.prefix = "KATSUROITEMS_SELFDESTRUCTDEVICE";
			BaseItem<SelfDestructDevice>.name = "Self-Destruct Device";
			BaseItem<SelfDestructDevice>.desc = "Enemies left alive for <style=cIsUtility>3</style> <style=cStack>(-50% per stack)</style> seconds after reaching <style=cIsDamage>35% health</style> <style=cStack>(15% for boss enemies) explode for <style=cIsDamage>2000%</style> <style=cStack>(+2000% per stack)</style> base damage in a <style=cIsDamage>30m</style> radius.";
			BaseItem<SelfDestructDevice>.pickup = "Enemies detonate when left on low health.";
			BaseItem<SelfDestructDevice>.itemTierDef = () => Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
			BaseItem<SelfDestructDevice>.pickupIconSprite = () => Assets.assetBundle.LoadAsset<Sprite>("texTeleportOnLowHealthIcon");
			BaseItem<SelfDestructDevice>.pickupModelPrefab = () => Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_Items_TeleportOnLowHealth.PickupTeleportOnLowHealth_prefab).WaitForCompletion();
			BaseItem<SelfDestructDevice>.canRemove = true;
			BaseItem<SelfDestructDevice>.hidden = false;
			GlobalEventManager.onServerDamageDealt += AddExplosionComponent;
			BaseItem<SelfDestructDevice>.Init();
		}

		private static void AddExplosionComponent(DamageReport damageReport)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			object obj;
			if (damageReport == null)
			{
				obj = null;
			}
			else
			{
				CharacterBody attackerBody = damageReport.attackerBody;
				obj = ((attackerBody != null) ? attackerBody.inventory : null);
			}
			if ((Object)obj == (Object)null)
			{
				return;
			}
			object obj2;
			if (damageReport == null)
			{
				obj2 = null;
			}
			else
			{
				CharacterBody victimBody = damageReport.victimBody;
				obj2 = ((victimBody != null) ? victimBody.healthComponent : null);
			}
			if (!((Object)obj2 == (Object)null))
			{
				float num = 0.35f;
				if (damageReport.victimBody.isBoss)
				{
					num = 0.15f;
				}
				int itemCountEffective = damageReport.attackerBody.inventory.GetItemCountEffective(BaseItem<SelfDestructDevice>.itemDef.itemIndex);
				float num3;
				if (damageReport.victimBody.isElite)
				{
					float num2 = damageReport.victim.fullCombinedHealth * damageReport.attackerBody.executeEliteHealthFraction;
					num3 = num2 + (damageReport.victim.fullCombinedHealth - num2) * num;
				}
				else
				{
					num3 = damageReport.victim.fullCombinedHealth * num;
				}
				if (itemCountEffective > 0 && damageReport.victim.combinedHealth <= num3 && (Object)(object)((Component)damageReport.victimBody).GetComponent<SDDComponent>() == (Object)null)
				{
					SDDComponent sDDComponent = ((Component)damageReport.victimBody).gameObject.AddComponent<SDDComponent>();
					sDDComponent.detonationDamage = damageReport.attackerBody.damage * (baseDamageCoefficient + stackingDamageCoefficient * (float)(itemCountEffective - 1));
					sDDComponent.attacker = damageReport.attacker;
					sDDComponent.attackerTeamIndex = damageReport.attackerTeamIndex;
					sDDComponent.itemStacks = itemCountEffective;
				}
			}
		}
	}
	public class Snowboard : BaseItem<Snowboard>
	{
		public new static void Init()
		{
			BaseItem<Snowboard>.prefix = "KATSUROITEMS_SNOWBOARD";
			BaseItem<Snowboard>.name = "Snowboard";
			BaseItem<Snowboard>.desc = "Fall damage is reduced by <style=cIsUtility>15%</style> <style=cStack>(+15% per stack)</style>. Landing on the ground increases <style=cIsUtility>movement speed</style> by <style=cIsUtility>50%-125%</style> <style=cStack>(+35% per stack)</style>, fading over <style=cIsUtility>1</style> second. Initial speed is proportional to the landing force.";
			BaseItem<Snowboard>.pickup = "Gain a burst of movement speed upon landing.";
			BaseItem<Snowboard>.itemTierDef = () => Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			BaseItem<Snowboard>.pickupIconSprite = () => Assets.assetBundle.LoadAsset<Sprite>("texGravBootsIcon");
			BaseItem<Snowboard>.pickupModelPrefab = () => Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_FallBoots.PickupGravBoots_prefab).WaitForCompletion();
			BaseItem<Snowboard>.canRemove = true;
			BaseItem<Snowboard>.hidden = false;
			Hooks.IL_Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions = (Hooks.IL_Handle_GlobalEventManagerOnCharacterHitGroundServer)Delegate.Combine(Hooks.IL_Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions, new Hooks.IL_Handle_GlobalEventManagerOnCharacterHitGroundServer(ReduceFallDamage));
			Hooks.Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions = (Hooks.Handle_GlobalEventManagerOnCharacterHitGroundServer)Delegate.Combine(Hooks.Handle_GlobalEventManagerOnCharacterHitGroundServer_Actions, new Hooks.Handle_GlobalEventManagerOnCharacterHitGroundServer(AddSpeedBuff));
			BaseItem<Snowboard>.Init();
		}

		private static void ReduceFallDamage(ILContext il)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			Func<CharacterBody, float> func = delegate(CharacterBody characterBody)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)((characterBody != null) ? characterBody.inventory : null) == (Object)null)
				{
					return 1f;
				}
				int itemCountEffective = characterBody.inventory.GetItemCountEffective(BaseItem<Snowboard>.itemDef.itemIndex);
				return (itemCountEffective > 0) ? Mathf.Pow(0.85f, (float)itemCountEffective) : 1f;
			};
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4)
			}) && val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 60f)
			}) && val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchDiv(x)
			}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 6)
			}))
			{
				val.Emit(OpCodes.Ldloc_S, (byte)6);
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Func<CharacterBody, float>>(func);
				val.Emit(OpCodes.Mul);
				val.Emit(OpCodes.Stloc_S, (byte)6);
			}
			else
			{
				Log.Error("ReduceFallDamage ILHook failed. Snowboard will not work as intended.");
			}
		}

		private static void AddSpeedBuff(GlobalEventManager self, CharacterBody characterBody, HitGroundInfo hitGroundInfo)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((characterBody != null) ? characterBody.inventory : null) == (Object)null)
			{
				return;
			}
			int itemCountEffective = characterBody.inventory.GetItemCountEffective(BaseItem<Snowboard>.itemDef.itemIndex);
			if (itemCountEffective <= 0)
			{
				return;
			}
			float num = 0.5f + 0.35f * (float)(itemCountEffective - 1);
			float num2 = 1.25f + 0.35f * (float)(itemCountEffective - 1);
			float num3 = Mathf.Min(Mathf.Abs(hitGroundInfo.velocity.y), 60f);
			float num4 = Mathf.InverseLerp(0f, 60f, num3) * (num2 - num) + num;
			int num5 = (int)(num4 / 0.05f);
			characterBody.ClearTimedBuffs(Buffs.snowboardBuff);
			for (int i = 0; i < num5; i++)
			{
				float num6 = 1f / (float)num5 * (float)(i + 1);
				characterBody.AddTimedBuff(Buffs.snowboardBuff, num6);
			}
			EffectData val = new EffectData();
			val.origin = characterBody.corePosition;
			CharacterMotor characterMotor = characterBody.characterMotor;
			bool flag = false;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				Vector3 moveDirection = characterMotor.moveDirection;
				if (moveDirection != Vector3.zero)
				{
					val.rotation = Util.QuaternionSafeLookRotation(moveDirection);
					flag = true;
				}
			}
			if (!flag)
			{
				val.rotation = characterBody.transform.rotation;
			}
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MoveSpeedOnKillActivate"), val, true);
		}
	}
}
namespace KatsuroItems.Items.Components
{
	public class SDDComponent : MonoBehaviour
	{
		public class SyncRedOverlay : INetMessage, ISerializableObject
		{
			private NetworkInstanceId bodyNetId;

			private float duration;

			public SyncRedOverlay()
			{
			}

			public SyncRedOverlay(NetworkInstanceId bodyNetId, float duration)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				this.bodyNetId = bodyNetId;
				this.duration = duration;
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(bodyNetId);
				writer.Write(duration);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				bodyNetId = reader.ReadNetworkId();
				duration = reader.ReadSingle();
			}

			public void OnReceived()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Expected O, but got Unknown
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Expected O, but got Unknown
				GameObject obj = Util.FindNetworkObject(bodyNetId);
				CharacterBody val = ((obj != null) ? obj.GetComponent<CharacterBody>() : null);
				object obj2;
				if (val == null)
				{
					obj2 = null;
				}
				else
				{
					ModelLocator modelLocator = val.modelLocator;
					if (modelLocator == null)
					{
						obj2 = null;
					}
					else
					{
						Transform modelTransform = modelLocator.modelTransform;
						obj2 = ((modelTransform != null) ? ((Component)modelTransform).gameObject : null);
					}
				}
				GameObject val2 = (GameObject)obj2;
				if (!((Object)(object)val2 != (Object)null) || val == null)
				{
					return;
				}
				HealthComponent healthComponent = val.healthComponent;
				if (((healthComponent != null) ? new bool?(healthComponent.alive) : null).GetValueOrDefault())
				{
					TemporaryOverlayInstance val3 = TemporaryOverlayManager.AddOverlay(val2);
					val3.duration = duration;
					val3.destroyComponentOnEnd = true;
					val3.originalMaterial = Assets.matSelfDestructOverlay;
					val3.inspectorCharacterModel = val2.GetComponent<CharacterModel>();
					AnimationCurve alphaCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(0f, 0f),
						new Keyframe(duration, 100f),
						new Keyframe(duration + 0.1f, 0f)
					});
					val3.alphaCurve = alphaCurve;
					val3.animateShaderAlpha = true;
					val3.AddToCharacterModel(val2.GetComponent<CharacterModel>());
					if ((Object)(object)((val != null) ? val.master : null) != (Object)null)
					{
						val.master.onBodyDeath.AddListener(new UnityAction(val3.RemoveFromCharacterModel));
					}
				}
			}
		}

		public int itemStacks = 1;

		public float detonationDamage = 0f;

		public GameObject attacker;

		public TeamIndex attackerTeamIndex;

		private const float repeatInterval = 0.25f;

		private float stopwatch = 0f;

		private float detonationThreshold;

		private CharacterBody characterBody;

		private bool detonated = false;

		private GameObject soundController;

		private void Start()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			characterBody = ((Component)this).GetComponent<CharacterBody>();
			CharacterBody obj = characterBody;
			if (obj != null)
			{
				obj.AddBuff(Buffs.selfDestructBuff);
			}
			detonationThreshold = 3f * Mathf.Pow(0.5f, (float)(itemStacks - 1));
			soundController = new GameObject("SelfDestructDevice");
			soundController.SetActive(false);
			AkGameObj val = soundController.AddComponent<AkGameObj>();
			val.isEnvironmentAware = true;
			LoopSound val2 = soundController.AddComponent<LoopSound>();
			val2.repeatInterval = 0.25f;
			val2.akSoundString = "Play_item_proc_stickyBomb_countdown";
			val2.soundOwner = soundController.transform;
			soundController.transform.parent = ((Component)this).transform;
			RTPCController val3 = soundController.AddComponent<RTPCController>();
			val3.playOnEnable = true;
			val3.akSoundString = "";
			val3.rtpcString = "stickyBomb_countdown";
			val3.rtpcValue = 0f;
			val3.useCurveInstead = true;
			AnimationCurve rtpcValueCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0f),
				new Keyframe(detonationThreshold, 100f)
			});
			val3.rtpcValueCurve = rtpcValueCurve;
			soundController.SetActive(true);
			NetMessageExtensions.Send((INetMessage)(object)new SyncRedOverlay(characterBody.networkIdentity.netId, detonationThreshold), (NetworkDestination)1);
		}

		private void Update()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)soundController != (Object)null)
			{
				soundController.transform.localPosition = Vector3.zero;
			}
			stopwatch += Time.deltaTime;
			CharacterBody obj = characterBody;
			if ((Object)(object)((obj != null) ? obj.healthComponent : null) == (Object)null || !characterBody.healthComponent.alive)
			{
				Object.Destroy((Object)(object)soundController);
				Object.Destroy((Object)(object)this);
			}
			else
			{
				if (!(stopwatch >= detonationThreshold) || detonated)
				{
					return;
				}
				detonated = true;
				Object.Destroy((Object)(object)soundController);
				CharacterBody component = attacker.GetComponent<CharacterBody>();
				float num = (Object.op_Implicit((Object)(object)component) ? attacker.GetComponent<CharacterBody>().crit : 0f);
				CharacterBody obj2 = characterBody;
				if (obj2 != null)
				{
					obj2.RemoveBuff(Buffs.selfDestructBuff);
				}
				GameObject val = Object.Instantiate<GameObject>(CommonAssets.explodeOnDeathPrefab, characterBody.corePosition, Quaternion.identity);
				DelayBlast component2 = val.GetComponent<DelayBlast>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.explosionEffect = Assets.selfDestructExplosionPrefab;
					component2.position = characterBody.corePosition;
					component2.baseDamage = detonationDamage;
					component2.baseForce = 2000f;
					component2.bonusForce = Vector3.up * 1000f;
					component2.radius = 30f;
					component2.attacker = attacker;
					component2.inflictor = null;
					CharacterBody component3 = attacker.GetComponent<CharacterBody>();
					component2.crit = Util.CheckRoll(num, (component3 != null) ? component3.master : null);
					component2.maxTimer = 0f;
					component2.damageColorIndex = (DamageColorIndex)3;
					component2.falloffModel = (FalloffModel)0;
				}
				TeamFilter component4 = val.GetComponent<TeamFilter>();
				if (Object.op_Implicit((Object)(object)component4))
				{
					component4.teamIndex = attackerTeamIndex;
				}
				CharacterBody obj3 = characterBody;
				if (obj3 != null)
				{
					HealthComponent healthComponent = obj3.healthComponent;
					if (healthComponent != null)
					{
						healthComponent.Suicide(attacker, (GameObject)null, default(DamageTypeCombo));
					}
				}
				NetworkServer.Spawn(val);
			}
		}
	}
}