using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Pigeon.Math; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 DMLRChargeCapacity { [BepInPlugin("com.coloron.dmlrChargeCapacity", "DMLR Solid State Battery", "1.0.0")] [MycoMod(/*Could not decode attribute arguments.*/)] public class DMLRChargeCapacityPlugin : BaseUnityPlugin { public const string PluginGUID = "com.coloron.dmlrChargeCapacity"; public const string PluginName = "DMLR Solid State Battery"; public const string PluginVersion = "1.0.0"; public const int ModUpgradeID = 88804; public static DMLRChargeCapacityPlugin Instance; public static Upgrade CustomUpgradeInstance; internal static ManualLogSource Logger; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Loading DMLR Solid State Battery..."); new Harmony("com.coloron.dmlrChargeCapacity").PatchAll(); PlayerData.AddRegisterUpgradesCallback((Action)InitializeUpgrades); } private static void InitializeUpgrades() { //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_0054: Unknown result type (might be due to invalid IL or missing references) IUpgradable val = PlayerData.FindGear("dmlr"); if (val == null) { Logger.LogError((object)"[DMLRChargeCapacity] PlayerData.FindGear(\"dmlr\") returned null - aborting registration."); return; } CustomUpgradeParams val2 = CustomUpgradeParams.Create(val, 88804, "Solid State Battery", "Increases laser charge capacity.", (Rarity)0, (Sprite)null); ref UpgradeFlags flags = ref val2.flags; flags = (UpgradeFlags)((uint)flags | 0u); try { CustomUpgradeInstance = PlayerData.CreateUpgrade("com.coloron.dmlrChargeCapacity", val2, (UpgradeProperty[])(object)new UpgradeProperty[1] { new UpgradeProperty_ChargeCapacity() }); } catch (Exception arg) { Logger.LogError((object)$"[DMLRChargeCapacity] CreateUpgrade threw: {arg}"); return; } if ((Object)(object)CustomUpgradeInstance == (Object)null) { Logger.LogError((object)"[DMLRChargeCapacity] CustomUpgradeInstance is null after CreateUpgrade - aborting."); return; } try { ApplyCustomPattern(CustomUpgradeInstance); Logger.LogInfo((object)"[DMLRChargeCapacity] Solid State Battery upgrade registered successfully."); } catch (Exception arg2) { Logger.LogError((object)$"[DMLRChargeCapacity] ApplyCustomPattern threw: {arg2}"); } } private static void ApplyCustomPattern(Upgrade upgrade) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)upgrade == (Object)null)) { HexMap val = new HexMap(3, 3); val[0, 0].enabled = true; val[1, 0].enabled = true; val[1, 0].connections = (Direction)36; val[2, 1].enabled = true; SetPrivateField(upgrade, "pattern", val); } } public static bool SetPrivateField(object target, string name, object value) { Type type = target.GetType(); FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); while (field == null && type.BaseType != null) { type = type.BaseType; field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (field != null) { field.SetValue(target, value); return true; } return false; } } [Serializable] public class UpgradeProperty_ChargeCapacity : UpgradeProperty { public Range chargeCapacityBonus = new Range(1.5f, 2f); public override IEnumerator GetStatData(Random rand, IUpgradable gear, UpgradeInstance upgrade) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return StatData.Create("Laser charge capacity:", chargeCapacityBonus, upgrade, ref rand, (OverrideType)2, (LabelType)1, default(BoostParams)); } public override void Apply(IGear gear, UpgradeInstance upgrade, ref Random rand) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ScoutLaserRifle val = (ScoutLaserRifle)(object)((gear is ScoutLaserRifle) ? gear : null); if (!((Object)(object)val == (Object)null)) { float value = chargeCapacityBonus.GetValue(ref rand, upgrade, default(BoostParams)); val.LaserData.laserChargeCapacity *= 1f + value; } } } }