Decompiled source of SmallSurvivorTweaks v1.1.0

Survivor.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Commando;
using EntityStates.Croco;
using EntityStates.Loader;
using EntityStates.Treebot;
using HG.Reflection;
using On.EntityStates.Commando;
using On.EntityStates.Croco;
using On.EntityStates.Loader;
using On.EntityStates.Treebot;
using On.RoR2.Skills;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Skills;
using UnityEngine;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Survivor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Survivor")]
[assembly: AssemblyTitle("Survivor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BenSurvivorSpace;

[R2APISubmoduleDependency(new string[] { "LanguageAPI", "RecalculateStatsAPI" })]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Ben.SmallSurvivorTweaks", "Small Survivor Tweaks", "1.1.0")]
public class SmallSurivivorTweaks : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_OnEnter <>9__48_0;

		internal void <CommandoChange>b__48_0(orig_OnEnter orig, DodgeState self)
		{
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, CommandoInvic.Value);
			}
		}
	}

	private bool RexBuffs = true;

	private bool Multbuffs = true;

	private bool AcridBuff = false;

	private bool CaptHealingBuff = true;

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

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

	public ConfigEntry<float> MultRecharge { get; private set; }

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

	public ConfigEntry<float> LoaderPylon { get; private set; }

	public ConfigEntry<float> AcridFrenzy { get; private set; }

	public ConfigEntry<float> RexDrill { get; private set; }

	public ConfigEntry<int> RexDisperse { get; private set; }

	public ConfigEntry<float> RexHarvest { get; private set; }

	public ConfigEntry<int> CaptainHealing { get; private set; }

	public void Awake()
	{
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogMessage((object)"Execute Order 69");
		CommandoInvic = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "CommandoInvic", 0.5f, "How long does commando get invicibility for on his combat roll. Vanilla is 0 seconds.");
		HuntressAgile = ((BaseUnityPlugin)this).Config.Bind<bool>("SmallSurvivorTweaks", "HuntressAgile", true, "Gives Huntresses glaive attack the agile attribute, allowing her to continue sprinting while using it. In vanilla this is false.");
		MultRecharge = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "MultRecharge", 2.5f, "Base time for Scrap Launcher to reload. In vanilla this is 1.5s.");
		MultResetCoolDown = ((BaseUnityPlugin)this).Config.Bind<bool>("SmallSurvivorTweaks", "MultResetCoolDown", false, "Allows scrap launcher to start recharging after the first stock is used and will refresh all when finished. In vanilla this is true, which means that firing would reset cooldown.");
		LoaderPylon = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "LoaderPylon", 2f, "Scaling of Loader's Pylon Damage. In vanilla this is 1, or 100% for each burst of electricity.");
		AcridFrenzy = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "AcridFrenzy", 0.5f, "Duration of the invicibility acrid gets when landing frenzy leap. In vanilla this is 0.");
		RexDrill = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "RexDrill", 4.5f, "Base recharge duration of Rex's Driective Drill Ability. In vanilla this is 6s.");
		RexDisperse = ((BaseUnityPlugin)this).Config.Bind<int>("SmallSurvivorTweaks", "RexDisperse", 2, "Base stock of Rex's Directive Disperse ablity. In vanilla this is 1.");
		RexHarvest = ((BaseUnityPlugin)this).Config.Bind<float>("SmallSurvivorTweaks", "RexHarvest", 4.2f, "Damage scale of Rex's Harvest / Fruiting ability. In vanilla this is 3.3.");
		CaptainHealing = ((BaseUnityPlugin)this).Config.Bind<int>("SmallSurvivorTweaks", "RexDispers", 2, "Base Stock of Captain's Healing Beacon. In Vanilla this is 1.");
		SkillCatalog.Init += new hook_Init(HuntressChange);
		TextChange();
		RexChange();
		CommandoChange();
		NewCrocoChange();
		LoaderChange();
	}

	private void TextChange()
	{
		float num = LoaderPylon.Value * 100f;
		float num2 = RexHarvest.Value * 100f;
		if (HuntressAgile.Value)
		{
			LanguageAPI.Add("HUNTRESS_SECONDARY_DESCRIPTION", $"<style=cIsUtility>Agile</style>. Throw a seeking glaive that bounces up to <style=cIsDamage>6</style> times for <style=cIsDamage>250% damage</style>. Damage increases by <style=cIsDamage>10%</style> per bounce.");
			LanguageAPI.Add("HUNTRESS_DESCRIPTION", $"The Huntress is an extremely mobile but fragile survivor with a high damage output. <style=cSub>\r\n\r\n< ! > Remember that Strafe can be uniquely used while sprinting, allowing you to move at high speeds while still taking out potential threats.\r\n\r\n< ! > Blink and Arrow Rain can be used to reposition closer or used as a dodge in a tight spot.\r\n\r\n< ! > Laser Glaive will take out pairs of tough targets quickly as it bounces between the two. \r\n\r\n< ! > Arrow Rain has extremely high damage output and also slows enemies inside, making it great for tough, fast enemies.</style>\r\n");
		}
		LanguageAPI.Add("COMMANDO_UTILITY_DESCRIPTION", $"<style=cIsUtility>Roll</style> a short distance while being <style=cIsHealing>invincible</style> for {CommandoInvic.Value} seconds");
		LanguageAPI.Add("LOADER_SPECIAL_DESCRIPTION", $"Throw a floating pylon that <style=cIsDamage>zaps</style> up to <style=cIsDamage>6</style> nearby enemies for <style=cIsDamage>{num}% damage</style>. Can be <style=cIsUtility>grappled</style>.");
		if (AcridFrenzy.Value > 0f)
		{
			LanguageAPI.Add("CROCO_UTILITY_ALT1_DESCRIPTION", $"<style=cIsDamage>Stunning</style> and <style=cIsHealing>Invincible</style> when landing. Leap in the air, dealing <style=cIsDamage>550% damage</style>. <style=cIsUtility>Reduce</style> the cooldown by <style=cIsUtility>2s</style> for every enemy hit.");
		}
		LanguageAPI.Add("TREEBOT_SPECIAL_ALT1_DESCRIPTION", $"Fire a bolt that deals <style=cIsDamage>{num2}% damage</style> and <style=cIsDamage>injects</style> an enemy. On death, drop multiple <style=cIsHealing>healing fruits</style> that heal for <style=cIsHealing>25% HP</style>.");
		if (CaptainHealing.Value > 1)
		{
			LanguageAPI.Add("CAPTAIN_SUPPLY_HEAL_DESCRIPTION", $"<style=cIsHealing>Heal</style> all nearby allies for <style=cIsHealing>10%</style></style> of their <style=cIsHealing>maximum health</style> every second. Base stock of <style=cIsUtility>{CaptainHealing.Value}</style>.");
		}
	}

	public void LoaderChange()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		ThrowPylon.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, ThrowPylon self)
		{
			float fieldValue = Reflection.GetFieldValue<float>((object)self, "damageCoefficient");
			bool flag = self != null;
			if (fieldValue != 0f && flag)
			{
				ThrowPylon.damageCoefficient = LoaderPylon.Value;
			}
			orig.Invoke(self);
		};
	}

	public void RexChange()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		TreebotFireFruitSeed.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, TreebotFireFruitSeed self)
		{
			float fieldValue = Reflection.GetFieldValue<float>((object)self, "damageCoefficient");
			bool flag = self != null;
			if (fieldValue != 0f && flag)
			{
				self.damageCoefficient = RexHarvest.Value;
			}
			orig.Invoke(self);
		};
	}

	public void CommandoChange()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		object obj = <>c.<>9__48_0;
		if (obj == null)
		{
			hook_OnEnter val = delegate(orig_OnEnter orig, DodgeState self)
			{
				orig.Invoke(self);
				if (NetworkServer.active)
				{
					((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, CommandoInvic.Value);
				}
			};
			<>c.<>9__48_0 = val;
			obj = (object)val;
		}
		DodgeState.OnEnter += (hook_OnEnter)obj;
	}

	public void NewCrocoChange()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		ChainableLeap.DoImpactAuthority += (hook_DoImpactAuthority)delegate(orig_DoImpactAuthority orig, ChainableLeap self)
		{
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, AcridFrenzy.Value);
			}
		};
	}

	public void HuntressChange(orig_Init orig)
	{
		orig.Invoke();
		if (HuntressAgile.Value)
		{
			SkillDef val = Resources.Load<SkillDef>("skilldefs/huntressbody/huntressbodyglaive");
			if (Object.op_Implicit((Object)(object)val))
			{
				val.canceledFromSprinting = false;
				val.cancelSprintingOnActivation = false;
			}
		}
		if (RexBuffs)
		{
			SkillDef val2 = Resources.Load<SkillDef>("skilldefs/treebotbody/treebotbodyaimmortarrain");
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.baseRechargeInterval = RexDrill.Value;
			}
			SkillDef val3 = Resources.Load<SkillDef>("skilldefs/treebotbody/treebotbodysonicboom");
			if (Object.op_Implicit((Object)(object)val3))
			{
				val3.baseMaxStock = RexDisperse.Value;
			}
		}
		if (Multbuffs)
		{
			SkillDef val4 = Resources.Load<SkillDef>("skilldefs/toolbotbody/toolbotbodyfiregrenadelauncher");
			if (Object.op_Implicit((Object)(object)val4))
			{
				val4.baseRechargeInterval = MultRecharge.Value;
				val4.resetCooldownTimerOnUse = MultResetCoolDown.Value;
			}
		}
		if (AcridBuff)
		{
			SkillDef val5 = Resources.Load<SkillDef>("skilldefs/crocobody/crocochainableleap");
			if (Object.op_Implicit((Object)(object)val5))
			{
				val5.baseMaxStock = 3;
			}
		}
		if (CaptHealingBuff)
		{
			SkillDef val6 = Resources.Load<SkillDef>("skilldefs/captainbody/callsupplydrophealing");
			if (Object.op_Implicit((Object)(object)val6))
			{
				val6.baseMaxStock = CaptainHealing.Value;
			}
		}
	}
}