Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FasterCharge v1.3.2
FasterCharge.dll
Decompiled 2 months agousing 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.Configuration; using EntityStates.DeepVoidPortalBattery; using EntityStates.Missions.Arena.NullWard; using EntityStates.Missions.Moon; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using On.EntityStates.DeepVoidPortalBattery; using On.EntityStates.Missions.Arena.NullWard; using On.EntityStates.Missions.Moon; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FasterCharge")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FasterCharge")] [assembly: AssemblyTitle("FasterCharge")] [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 FasterCharge { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Slendykray.FasterCharge", "FasterCharge", "1.3.1")] public class FasterCharge : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Instruction, bool> <>9__50_3; public static Func<float, float> <>9__50_2; public static Func<Instruction, bool> <>9__51_2; public static Func<float, float> <>9__51_1; public static hook_Awake <>9__52_0; internal bool <HalcyonShrine>b__50_3(Instruction x) { return ILPatternMatchingExt.MatchLdfld<GoldSiphonNearbyBodyController>(x, "tickRate"); } internal float <HalcyonShrine>b__50_2(float num) { return num + num * (HalcyonSpeed.Value / 100f); } internal bool <BloodPillar>b__51_2(Instruction x) { return ILPatternMatchingExt.MatchStloc(x, 2); } internal float <BloodPillar>b__51_1(float num) { return num + num * (PillarsSpeed.Value / 100f); } internal void <HalcyonBeacon>b__52_0(orig_Awake orig, PurchaseInteraction self) { if (self.displayNameToken == "GOLDTOTEM_NAME") { self.cost /= (int)(1f + HalcyonBeaconCostReduction.Value / 100f); } orig.Invoke(self); } } public const string PluginGUID = "Slendykray.FasterCharge"; public const string PluginAuthor = "Slendykray"; public const string PluginName = "FasterCharge"; public const string PluginVersion = "1.3.1"; public static ConfigEntry<bool> TimePenalty { get; set; } public static ConfigEntry<bool> TeleporterSpeedAfterBoss { get; set; } public static ConfigEntry<float> HalcyonBeaconCostReduction { get; set; } public static ConfigEntry<float> DischargeSpeed { get; set; } public static ConfigEntry<float> TeleporterSpeed { get; set; } public static ConfigEntry<float> HalcyonSpeed { get; set; } public static ConfigEntry<float> PillarsSpeed { get; set; } public static ConfigEntry<float> RescueShipSpeed { get; set; } public static ConfigEntry<float> DeepVoidSignalSpeed { get; set; } public static ConfigEntry<float> VoidFieldsSpeed { get; set; } private void SetConfig() { TimePenalty = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "TimePenalty?", true, "Speed up timer while charging"); TeleporterSpeedAfterBoss = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "TeleporterSpeedAfterBoss?", true, "Speed up teleporter only after killing the boss"); HalcyonBeaconCostReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "HalcyonBeaconCostReduction", 200f, "Reduce price of Gilded Coast beacons by x%"); DischargeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "DischargeSpeed", 200f, "Speed up Glass pillar discharge by x%"); TeleporterSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "TeleporterSpeed", 500f, "Speed up by x%"); HalcyonSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "HalcyonShrineSpeed", 500f, "Speed up by x%"); PillarsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "PillarsSpeed", 500f, "Speed up by x%"); RescueShipSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "RescueShipSpeed", 500f, "Speed up by x%"); DeepVoidSignalSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "DeepVoidSignalSpeed", 500f, "Speed up by x%"); VoidFieldsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SpeedValues", "VoidFieldsSpeed", 200f, "Speed up by x%"); } private void SetRiskOfOptions() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005e: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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 //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Sprite modIcon = LoadSprite(directoryName + "/icon.png"); ModSettingsManager.SetModIcon(modIcon); float min = 0f; float max = 2000f; ModSettingsManager.AddOption((BaseOption)new SliderOption(TeleporterSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(HalcyonSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(PillarsSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(RescueShipSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(DeepVoidSignalSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(VoidFieldsSpeed, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(TimePenalty)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(TeleporterSpeedAfterBoss)); ModSettingsManager.AddOption((BaseOption)new SliderOption(HalcyonBeaconCostReduction, new SliderConfig { min = min, max = max })); ModSettingsManager.AddOption((BaseOption)new SliderOption(DischargeSpeed, new SliderConfig { min = min, max = max })); } public static Sprite LoadSprite(string path) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, array); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } public void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown SetConfig(); HalcyonShrine(); BloodPillar(); HalcyonBeacon(); SetRiskOfOptions(); TeleporterInteraction.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, TeleporterInteraction self) { orig.Invoke(self); if ((self.monstersCleared || !TeleporterSpeedAfterBoss.Value) && self.chargePercent > 0) { Charge(self.holdoutZoneController, TeleporterSpeed.Value, TimePenalty.Value); } }; MoonBatteryActive.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, MoonBatteryActive self) { orig.Invoke(self); Charge(self.holdoutZoneController, PillarsSpeed.Value, TimePenalty.Value); }; HoldoutZoneController.Update += (hook_Update)delegate(orig_Update orig, HoldoutZoneController self) { orig.Invoke(self); if (self.inBoundsObjectiveToken == "OBJECTIVE_MOON_CHARGE_DROPSHIP") { Charge(self, RescueShipSpeed.Value, TimePenalty.Value); } }; Charging.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, Charging self) { orig.Invoke(self); Charge(self.holdoutZoneController, DeepVoidSignalSpeed.Value, TimePenalty.Value); }; Active.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, Active self) { orig.Invoke(self); Charge(self.holdoutZoneController, VoidFieldsSpeed.Value, skipTime: false); }; } private void Charge(HoldoutZoneController self, float speed, bool skipTime) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) if (self.displayChargePercent > 97) { return; } speed = Mathf.Clamp(speed / 100f, 0f, float.PositiveInfinity); int num = HoldoutZoneController.CountLivingPlayers(self.chargingTeam); int num2 = HoldoutZoneController.CountPlayersInRadius(self, ((Component)self).transform.position, self.currentRadius * self.currentRadius, self.chargingTeam); if (!NetworkServer.active) { return; } float baseChargeDuration = self.baseChargeDuration; float num3; if (self.isAnyoneCharging && num > 0) { num3 = Mathf.Pow((float)num2 / (float)num, self.playerCountScaling) / baseChargeDuration; if (skipTime) { SkipTime(num3 * Time.fixedDeltaTime * speed * baseChargeDuration); } } else { num3 = (0f - self.dischargeRate) * DischargeSpeed.Value / 100f; } self.charge = Mathf.Clamp01(self.charge + num3 * Time.fixedDeltaTime * speed); } private void SkipTime(float addVal) { float runStopwatch = Run.instance.GetRunStopwatch(); float runStopwatch2 = runStopwatch + addVal; Run.instance.SetRunStopwatch(runStopwatch2); } private void HalcyonShrine() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown GoldSiphonNearbyBodyController.FixedUpdate += (Manipulator)delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val2 = new ILCursor(il); if (!val2.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<GoldSiphonNearbyBodyController>(x, "tickRate") })) { ((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)(((MemberReference)il.Method).Name + " IL Hook success!")); int index = val2.Index; val2.Index = index + 1; val2.EmitDelegate<Func<float, float>>((Func<float, float>)((float num) => num + num * (HalcyonSpeed.Value / 100f))); } }; GoldSiphonNearbyBodyController.DrainGold += (hook_DrainGold)delegate(orig_DrainGold orig, GoldSiphonNearbyBodyController self) { FieldInfo field = typeof(GoldSiphonNearbyBodyController).GetField("parentShrineReference", BindingFlags.Instance | BindingFlags.NonPublic); object? value = field.GetValue(self); HalcyoniteShrineInteractable val = (HalcyoniteShrineInteractable)((value is HalcyoniteShrineInteractable) ? value : null); if (Object.op_Implicit((Object)(object)val) && TimePenalty.Value && val.NetworkisDraining && Object.op_Implicit((Object)(object)Run.instance)) { float num2 = 0.2f; float num3 = num2 / (1f + HalcyonSpeed.Value / 100f); SkipTime(num2 - num3); } orig.Invoke(self); }; } private void BloodPillar() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown BloodSiphonNearbyController.Tick += (Manipulator)delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 2) })) { ((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)(((MemberReference)il.Method).Name + " IL Hook success!")); val.EmitDelegate<Func<float, float>>((Func<float, float>)((float num) => num + num * (PillarsSpeed.Value / 100f))); } }; } private void HalcyonBeacon() { //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__52_0; if (obj == null) { hook_Awake val = delegate(orig_Awake orig, PurchaseInteraction self) { if (self.displayNameToken == "GOLDTOTEM_NAME") { self.cost /= (int)(1f + HalcyonBeaconCostReduction.Value / 100f); } orig.Invoke(self); }; <>c.<>9__52_0 = val; obj = (object)val; } PurchaseInteraction.Awake += (hook_Awake)obj; } } }