Decompiled source of FalseSonSurvivorTweaks v1.0.2

FalseSonSurvivorTweaks.dll

Decompiled a month 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 EntityStates;
using EntityStates.FalseSon;
using HG.GeneralSerializer;
using Microsoft.CodeAnalysis;
using On.EntityStates.FalseSon;
using R2API;
using RoR2;
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("FalseSonSurvivorTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FalseSonSurvivorTweaks")]
[assembly: AssemblyTitle("FalseSonSurvivorTweaks")]
[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 FalseSonSurvivorTweaks
{
	[BepInPlugin("Jeffdev.FalseSonSurvivorTweaks", "FalseSonSurvivorTweaks", "1.0.2")]
	public class FalseSonSurvivorTweaks : BaseUnityPlugin
	{
		public const string PluginGUID = "Jeffdev.FalseSonSurvivorTweaks";

		public const string PluginAuthor = "Jeffdev";

		public const string PluginName = "FalseSonSurvivorTweaks";

		public const string PluginVersion = "1.0.2";

		public static ConfigEntry<int> laserBurstCooldown;

		public static ConfigEntry<float> laserBurstRefill;

		public static ConfigEntry<float> higherLaserProc;

		public static ConfigEntry<bool> agileStakes;

		public void Awake()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00cc: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			laserBurstCooldown = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Laser Burst Cooldown", 10, "Change the cooldown of the Laser Burst skill in seconds (8 is vanilla default)");
			laserBurstRefill = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Laser Burst Spike Refill %", 0.3f, "Sets the % amount of lunar spikes/stakes refilled from Laser Burst. (0.5, aka 50%, is vanilla default, keep between 0 and 1)");
			higherLaserProc = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Laser of the Father Proc Coefficient", 0.75f, "Sets the proc coefficient of the Laser of the Father skill (default is 0.45)");
			agileStakes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Agile Lunar Stakes", false, "Lets Lunar Stakes be used while sprinting (false is vanilla default)");
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			LaserFatherCharged.OnEnter += new hook_OnEnter(LaserFatherCharged_OnEnter1);
			LaserFatherBurstPrep.OnEnter += new hook_OnEnter(LaserFatherBurstPrep_OnEnter);
			if (!Addressables.LoadAssetAsync<EntityStateConfiguration>((object)"RoR2/DLC2/FalseSon/EntityStates.FalseSon.LaserFatherCharged.asset").WaitForCompletion().TryModifyFieldValue("procCoefficientPerTick", higherLaserProc.Value))
			{
				Log.Error("Could not patch LaserFatherCharged.procCoefficientPerTick");
			}
			SteppedSkillDef obj = Addressables.LoadAssetAsync<SteppedSkillDef>((object)"RoR2/DLC2/FalseSon/FalseSonBodyLaserBurst.asset").WaitForCompletion();
			int num = Mathf.RoundToInt(laserBurstRefill.Value * 100f);
			Log.Info(num);
			string text = "Fire a piercing laser for <style=cIsDamage>1250%</style> damage, " + $"refilling <style=cIsUtility>{num}%</style> Lunar Spikes. " + "Increases in stock by <style=cIsHealing>Growth</style>.";
			LanguageAPI.Add(((SkillDef)obj).skillDescriptionToken, text);
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/FalseSon/FalseSonLunarStake.asset").WaitForCompletion();
			if (agileStakes.Value)
			{
				List<string> list = val.keywordTokens.ToList();
				list.Add("KEYWORD_AGILE");
				val.cancelSprintingOnActivation = !agileStakes.Value;
				val.keywordTokens = list.ToArray();
				string text2 = "<style=cIsUtility>Lunar Ruin</style>. <style=cIsUtility>Agile</style>. Fire a <style=cIsDamage>piercing</style>, <style=cIsDamage>lightning</style> infused Lunar Stake for <style=cIsDamage>300% damage</style>. Gain more Lunar Stakes through <style=cIsHealing>Growth</style>. Counts as <style=cIsUtility>2</style> Lunar Spikes.";
				LanguageAPI.Add(val.skillDescriptionToken, text2);
			}
		}

		private void LaserFatherCharged_OnEnter1(orig_OnEnter orig, LaserFatherCharged self)
		{
			orig.Invoke(self);
			float num = ((EntityState)self).characterBody.attackSpeed - ((EntityState)self).characterBody.baseAttackSpeed;
			self.fireFrequency = LaserFatherCharged.baseFireFrequency + num * LaserFatherCharged.baseFireFrequency;
		}

		private void Run_onRunStartGlobal(Run obj)
		{
			SkillDef skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LaserBurst"));
			if ((Object)(object)skillDef == (Object)null)
			{
				Log.Error($"One or more SkillDefs could not be found! Check skill names. {skillDef}");
			}
			else
			{
				skillDef.baseRechargeInterval = laserBurstCooldown.Value;
			}
		}

		private void LaserFatherBurstPrep_OnEnter(orig_OnEnter orig, LaserFatherBurstPrep self)
		{
			self.secondaryRefillPercentage = laserBurstRefill.Value;
			orig.Invoke(self);
		}
	}
	public static class EntityStateConfigurationExtensions
	{
		public static bool TryModifyFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, T value)
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T)))
			{
				ref Object objectValue = ref orCreateField.fieldValue.objectValue;
				object obj = value;
				objectValue = (Object)((obj is Object) ? obj : null);
				return true;
			}
			if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T)))
			{
				orCreateField.fieldValue.stringValue = StringSerializer.Serialize(typeof(T), (object)value);
				return true;
			}
			Debug.LogError((object)("Failed to modify field " + fieldName));
			return false;
		}

		public static bool TryGetFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : Object
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T)))
			{
				value = (T)(object)orCreateField.fieldValue.objectValue;
				return true;
			}
			if (!string.IsNullOrEmpty(orCreateField.fieldValue.stringValue))
			{
				Debug.LogError((object)("Failed to return " + fieldName + " as an Object, try getting the string value instead."));
			}
			else
			{
				Debug.LogError((object)("Field is null " + fieldName));
			}
			value = default(T);
			return false;
		}

		public static bool TryGetFieldValueString<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : IEquatable<T>
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T)))
			{
				value = (T)StringSerializer.Deserialize(typeof(T), orCreateField.fieldValue.stringValue);
				return true;
			}
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue))
			{
				Debug.LogError((object)("Failed to return " + fieldName + " as a string, try getting the Object value instead."));
			}
			else
			{
				Debug.LogError((object)("Field is null " + fieldName));
			}
			value = default(T);
			return false;
		}
	}
	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);
		}
	}
}