Decompiled source of pants v1.0.0

plugins/pants/pants.dll

Decompiled 2 weeks ago
using System;
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.Logging;
using EntityStates;
using ExamplePlugin;
using ExamplePlugin.MyEntityStates;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Projectile;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("pants")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("pants")]
[assembly: AssemblyTitle("pants")]
[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;
		}
	}
}
public static class Asset
{
	public static AssetBundle mainBundle;

	public const string bundleName = "skillicons";

	public const string assetBundleFolder = "assetbundles";

	public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(CustomSkillTutorial.Pinfo.Location), "assetbundles", "skillicons");

	public static void Init()
	{
		mainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		if ((Object)(object)mainBundle == (Object)null)
		{
			Debug.LogError((object)("[Asset] Failed to load AssetBundle from path: " + AssetBundlePath));
		}
		else
		{
			Debug.Log((object)("[Asset] Successfully loaded AssetBundle from: " + AssetBundlePath));
		}
	}
}
public static class PassiveBehaviour
{
	[CompilerGenerated]
	private static class <>O
	{
		public static StatHookEventHandler <0>__ApplyBurnBonuses;

		public static hook_OnHitEnemy <1>__SpreadFire;
	}

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

		public static hook_Start <>9__0_0;

		internal void <Init>b__0_0(orig_Start orig, ProjectileController self)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			GameObject owner = self.owner;
			CharacterBody val = ((owner != null) ? owner.GetComponent<CharacterBody>() : null);
			if (Object.op_Implicit((Object)(object)val) && val.bodyIndex == BodyCatalog.FindBodyIndex("CommandoBody"))
			{
				int buffCount = val.GetBuffCount(Buffs.OnFire);
				if (buffCount > 0 && (Object)(object)((Component)self).GetComponent<ProjectileDamage>() != (Object)null)
				{
					self.procCoefficient *= 1f + 0.2f * (float)buffCount;
				}
			}
			orig.Invoke(self);
		}
	}

	public static void Init()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//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_003b: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		object obj = <>O.<0>__ApplyBurnBonuses;
		if (obj == null)
		{
			StatHookEventHandler val = ApplyBurnBonuses;
			<>O.<0>__ApplyBurnBonuses = val;
			obj = (object)val;
		}
		RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		object obj2 = <>O.<1>__SpreadFire;
		if (obj2 == null)
		{
			hook_OnHitEnemy val2 = SpreadFire;
			<>O.<1>__SpreadFire = val2;
			obj2 = (object)val2;
		}
		GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj2;
		object obj3 = <>c.<>9__0_0;
		if (obj3 == null)
		{
			hook_Start val3 = delegate(orig_Start orig, ProjectileController self)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				GameObject owner = self.owner;
				CharacterBody val4 = ((owner != null) ? owner.GetComponent<CharacterBody>() : null);
				if (Object.op_Implicit((Object)(object)val4) && val4.bodyIndex == BodyCatalog.FindBodyIndex("CommandoBody"))
				{
					int buffCount = val4.GetBuffCount(Buffs.OnFire);
					if (buffCount > 0 && (Object)(object)((Component)self).GetComponent<ProjectileDamage>() != (Object)null)
					{
						self.procCoefficient *= 1f + 0.2f * (float)buffCount;
					}
				}
				orig.Invoke(self);
			};
			<>c.<>9__0_0 = val3;
			obj3 = (object)val3;
		}
		ProjectileController.Start += (hook_Start)obj3;
	}

	private static int GetBurnStacks(CharacterBody body)
	{
		return body.GetBuffCount(Buffs.OnFire);
	}

	private static void ApplyBurnBonuses(CharacterBody body, StatHookEventArgs args)
	{
		//IL_0001: 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)
		if (body.bodyIndex == BodyCatalog.FindBodyIndex("CommandoBody"))
		{
			int burnStacks = GetBurnStacks(body);
			if (burnStacks > 0)
			{
				args.attackSpeedMultAdd += 0.2f * (float)burnStacks;
				args.moveSpeedMultAdd += 0.5f;
			}
		}
	}

	private static void SpreadFire(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
	{
		//IL_002c: 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)
		orig.Invoke(self, damageInfo, victim);
		if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
		{
			return;
		}
		CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
		if (!Object.op_Implicit((Object)(object)component) || component.bodyIndex != BodyCatalog.FindBodyIndex("CommandoBody"))
		{
			return;
		}
		int burnStacks = GetBurnStacks(component);
		if (burnStacks <= 0 || !Object.op_Implicit((Object)(object)victim))
		{
			return;
		}
		CharacterBody component2 = victim.GetComponent<CharacterBody>();
		if (Object.op_Implicit((Object)(object)component2) && !component2.HasBuff(Buffs.Immune))
		{
			for (int i = 0; i < burnStacks; i++)
			{
				DotController.InflictDot(((Component)component2).gameObject, ((Component)component).gameObject, (DotIndex)1, 4f, damageInfo.damage * 0.5f, (uint?)null);
			}
		}
	}
}
namespace ExamplePlugin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.elbowterror.LiarLiar", "LiarLiar", "1.0.0")]
	public class CustomSkillTutorial : BaseUnityPlugin
	{
		public static PluginInfo Pinfo { get; private set; }

		public void Awake()
		{
			//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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00bd: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			Pinfo = ((BaseUnityPlugin)this).Info;
			Asset.Init();
			PassiveBehaviour.Init();
			GameObject obj = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoBody.prefab").WaitForCompletion();
			LanguageAPI.Add("COMMANDO_SECONDARY_LIAR_NAME", "Liar, Liar...");
			LanguageAPI.Add("COMMANDO_SECONDARY_LIAR_DESCRIPTION", "Ignite yourself, taking damage equal to <style=cIsHealth>5% of your max health per second</style> or <style=cIsDamage>5 damage per second (whichever is higher)</style> over 5 seconds.");
			LanguageAPI.Add("COMMANDO_PASSIVE_FIRE_NAME", "Arsonist");
			LanguageAPI.Add("COMMANDO_PASSIVE_FIRE_DESCRIPTION", "Fire invigorates you and your attacks! Improves your movement speed, fire rate... and even your proc coefficients!");
			UnlockableDef val = ScriptableObject.CreateInstance<UnlockableDef>();
			val.cachedName = "JerrySkill";
			val.hidden = false;
			ScriptableObject.CreateInstance<UnlockableDef>();
			SkillDef val2 = ScriptableObject.CreateInstance<SkillDef>();
			EntityStateMachine obj2 = obj.AddComponent<EntityStateMachine>();
			obj2.customName = "Weapon2";
			obj2.initialStateType = new SerializableEntityStateType(typeof(Idle));
			obj2.mainStateType = new SerializableEntityStateType(typeof(Idle));
			val2.activationState = new SerializableEntityStateType(typeof(Lied));
			val2.activationStateMachineName = "Weapon2";
			val2.baseMaxStock = 1;
			val2.baseRechargeInterval = 0.1f;
			val2.canceledFromSprinting = false;
			val2.cancelSprintingOnActivation = false;
			val2.fullRestockOnAssign = true;
			val2.interruptPriority = (InterruptPriority)0;
			val2.isCombatSkill = false;
			val2.mustKeyPress = true;
			val2.rechargeStock = 1;
			val2.requiredStock = 1;
			val2.stockToConsume = 1;
			val2.resetCooldownTimerOnUse = false;
			val2.dontAllowPastMaxStocks = true;
			val2.beginSkillCooldownOnSkillEnd = false;
			Sprite icon = Asset.mainBundle.LoadAsset<Sprite>("jerryskill");
			val2.icon = icon;
			val2.skillDescriptionToken = "COMMANDO_SECONDARY_LIAR_DESCRIPTION";
			val2.skillName = "COMMANDO_SECONDARY_LIAR_NAME";
			val2.skillNameToken = "COMMANDO_SECONDARY_LIAR_NAME";
			Sprite icon2 = Asset.mainBundle.LoadAsset<Sprite>("jerrypassive");
			ContentAddition.AddSkillDef(val2);
			SkillLocator component = obj.GetComponent<SkillLocator>();
			SkillFamily skillFamily = component.secondary.skillFamily;
			component.passiveSkill.enabled = true;
			component.passiveSkill.skillDescriptionToken = "COMMANDO_PASSIVE_FIRE_DESCRIPTION";
			component.passiveSkill.skillNameToken = "COMMANDO_PASSIVE_FIRE_NAME";
			component.passiveSkill.icon = icon2;
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val3 = new Variant
			{
				skillDef = val2,
				unlockableDef = val
			};
			((Variant)(ref val3)).viewableNode = new Node(val2.skillNameToken, false, (Node)null);
			variants[num] = val3;
		}
	}
	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);
		}
	}
}
namespace ExamplePlugin.MyEntityStates
{
	public class Lied : BaseSkillState
	{
		public float FireDuration = 5f;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			((EntityState)this).characterBody.AddTimedBuff(Buffs.ArmorBoost, FireDuration - 2f);
			DotController.InflictDot(((EntityState)this).gameObject, ((EntityState)this).gameObject, (DotIndex)3, FireDuration, 1f, (uint?)null);
			((EntityState)this).outer.SetNextStateToMain();
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)1;
		}
	}
}