Decompiled source of DMLR Upgrades v1.1.0
DMLR2.dll
Decompiled a week agousing 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 Unity.Netcode; 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 DMLRFirstShotExplosive { [BepInPlugin("com.coloron.DMLRFirstShotExplosive", "DMLR First Shot Explosive", "1.0.0")] [MycoMod(/*Could not decode attribute arguments.*/)] public class DMLRFirstShotExplosivePlugin : BaseUnityPlugin { public const string PluginGUID = "com.coloron.DMLRFirstShotExplosive"; public const string PluginName = "DMLR First Shot Explosive"; public const string PluginVersion = "1.0.0"; public const int ModUpgradeID = 88802; public static DMLRFirstShotExplosivePlugin Instance; public static Upgrade CustomUpgradeInstance; internal static ManualLogSource Logger; public const EffectType ExplosionEffect = (EffectType)4; 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 First Shot Explosive..."); new Harmony("com.coloron.DMLRFirstShotExplosive").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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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) IUpgradable val = PlayerData.FindGear("dmlr"); if (val == null) { Logger.LogError((object)"[DMLRFirstShotExplosive] PlayerData.FindGear(\"dmlr\") returned null - aborting registration."); return; } CustomUpgradeParams val2 = CustomUpgradeParams.Create(val, 88802, "Explosive Cycle", "The first DMR round fired after switching out of laser mode is overcharged: it detonates on impact.", (Rarity)2, (Sprite)null); try { UpgradeProperty_DMLR_FirstShotExplosive upgradeProperty_DMLR_FirstShotExplosive = new UpgradeProperty_DMLR_FirstShotExplosive { explosionRadius = new Range<float>(4f, 6f) }; CustomUpgradeInstance = PlayerData.CreateUpgrade("com.coloron.DMLRFirstShotExplosive", val2, (UpgradeProperty[])(object)new UpgradeProperty[1] { upgradeProperty_DMLR_FirstShotExplosive }); } catch (Exception arg) { Logger.LogError((object)$"[DMLRFirstShotExplosive] CreateUpgrade threw: {arg}"); return; } if ((Object)(object)CustomUpgradeInstance == (Object)null) { Logger.LogError((object)"[DMLRFirstShotExplosive] CustomUpgradeInstance is null after CreateUpgrade - aborting."); return; } try { ApplyCustomPattern(CustomUpgradeInstance); Logger.LogInfo((object)"[DMLRFirstShotExplosive] Explosive Cycle upgrade registered successfully."); } catch (Exception arg2) { Logger.LogError((object)$"[DMLRFirstShotExplosive] 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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, 1].enabled = true; val[0, 1].connections = (Direction)10; val[0, 2].enabled = true; val[0, 2].connections = (Direction)4; val[1, 0].enabled = true; val[1, 2].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; } public static bool GunHasFirstShotExplosive(ScoutLaserRifle gun) { if ((Object)(object)gun == (Object)null || (Object)(object)CustomUpgradeInstance == (Object)null) { return false; } List<UpgradeInstance> list = PlayerData.GetUpgradeInfo((IUpgradable)(object)gun, CustomUpgradeInstance)?.Instances; if (list == null) { return false; } foreach (UpgradeInstance item in list) { if (item.IsEquipped((IUpgradable)(object)gun)) { return true; } } return false; } } [Serializable] public class UpgradeProperty_DMLR_FirstShotExplosive : UpgradeProperty { public Range<float> explosionRadius; public override IEnumerator<StatData> 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("Explosion radius", explosionRadius, upgrade, ref rand, (OverrideType)1, (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 = explosionRadius.GetValue(ref rand, upgrade, default(BoostParams)); DMLRFirstShotState.SetExplosionRadius(val, value); } } } public static class DMLRFirstShotState { private static readonly Dictionary<ScoutLaserRifle, bool> armedForNextShot = new Dictionary<ScoutLaserRifle, bool>(); private static readonly Dictionary<ScoutLaserRifle, float> explosiveShotInFlight = new Dictionary<ScoutLaserRifle, float>(); private static readonly Dictionary<ScoutLaserRifle, float> explosionRadius = new Dictionary<ScoutLaserRifle, float>(); private const float DefaultExplosionRadius = 4f; public static void SetExplosionRadius(ScoutLaserRifle gun, float radius) { explosionRadius[gun] = radius; } public static float GetExplosionRadius(ScoutLaserRifle gun) { float value; return explosionRadius.TryGetValue(gun, out value) ? value : 4f; } public static void ArmNextShot(ScoutLaserRifle gun) { armedForNextShot[gun] = true; } public static bool ConsumeArmedForFiring(ScoutLaserRifle gun, float shotDamage) { if (armedForNextShot.TryGetValue(gun, out var value) && value) { armedForNextShot[gun] = false; explosiveShotInFlight[gun] = shotDamage; return true; } return false; } public static bool ConsumeExplosiveHit(ScoutLaserRifle gun, out float shotDamage) { if (explosiveShotInFlight.TryGetValue(gun, out shotDamage)) { explosiveShotInFlight.Remove(gun); return true; } shotDamage = 0f; return false; } public static void Clear(ScoutLaserRifle gun) { armedForNextShot.Remove(gun); explosiveShotInFlight.Remove(gun); explosionRadius.Remove(gun); } } [HarmonyPatch(typeof(ScoutLaserRifle), "OnUpgradesEnabled")] public static class DMLRFirstShotEnablePatch { [CompilerGenerated] private static class <>O { public static DamageCallback <0>__OnDamageTarget; } private static void Postfix(ScoutLaserRifle __instance) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0042: 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_004d: Expected O, but got Unknown __instance.OnModeChanged += delegate(bool value) { DMLRFirstShotModeHandler.OnModeChanged(__instance, value); }; ScoutLaserRifle obj = __instance; DamageCallback onDamageTarget = ((Gun)obj).OnDamageTarget; object obj2 = <>O.<0>__OnDamageTarget; if (obj2 == null) { DamageCallback val = DMLRFirstShotExplosionPatch.OnDamageTarget; <>O.<0>__OnDamageTarget = val; obj2 = (object)val; } ((Gun)obj).OnDamageTarget = (DamageCallback)Delegate.Combine((Delegate?)(object)onDamageTarget, (Delegate?)obj2); } } [HarmonyPatch(typeof(ScoutLaserRifle), "OnUpgradesDisabled")] public static class DMLRFirstShotDisablePatch { [CompilerGenerated] private static class <>O { public static DamageCallback <0>__OnDamageTarget; } private static void Postfix(ScoutLaserRifle __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown DamageCallback onDamageTarget = ((Gun)__instance).OnDamageTarget; object obj = <>O.<0>__OnDamageTarget; if (obj == null) { DamageCallback val = DMLRFirstShotExplosionPatch.OnDamageTarget; <>O.<0>__OnDamageTarget = val; obj = (object)val; } ((Gun)__instance).OnDamageTarget = (DamageCallback)Delegate.Remove((Delegate?)(object)onDamageTarget, (Delegate?)obj); DMLRFirstShotState.Clear(__instance); } } public static class DMLRFirstShotModeHandler { public static void OnModeChanged(ScoutLaserRifle gun, bool isLaserModeActive) { if (!isLaserModeActive && DMLRFirstShotExplosivePlugin.GunHasFirstShotExplosive(gun)) { DMLRFirstShotState.ArmNextShot(gun); } } } [HarmonyPatch(typeof(ScoutLaserRifle), "ModifyBulletData")] public static class DMLRFirstShotModifyPatch { private static void Postfix(ScoutLaserRifle __instance, ref BulletData data, BulletFlags flags) { if (!__instance.IsLaserModeActive && DMLRFirstShotExplosivePlugin.GunHasFirstShotExplosive(__instance)) { DMLRFirstShotState.ConsumeArmedForFiring(__instance, data.damage); } } } public static class DMLRFirstShotExplosionPatch { public static void OnDamageTarget(in DamageCallbackData data) { //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_0070: Unknown result type (might be due to invalid IL or missing references) IDamageSource source = data.source; IDamageSource obj = ((source != null) ? source.ParentSource : null); ScoutLaserRifle val = (ScoutLaserRifle)(object)((obj is ScoutLaserRifle) ? obj : null); if (!((Object)(object)val == (Object)null) && !val.IsLaserModeActive && DMLRFirstShotExplosivePlugin.GunHasFirstShotExplosive(val) && DMLRFirstShotState.ConsumeExplosiveHit(val, out var shotDamage)) { Vector3 position = data.position; float explosionRadius = DMLRFirstShotState.GetExplosionRadius(val); GameManager.Instance.SpawnExplosionVisual_ServerRpc(position, explosionRadius, (EffectType)4); if (NetworkManager.Singleton.IsServer) { DamageData val2 = default(DamageData); ((DamageData)(ref val2))..ctor(shotDamage, (EffectType)4, 0f); IDamageSource.DamageTargetsInSphere((IDamageSource)(object)val, ref position, explosionRadius, (TargetType)5, ref val2, 0f, 1f); } } } } }
DMLR3.dll
Decompiled a week agousing System; using System.Collections; 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 Unity.Netcode; using UnityEngine; using UnityEngine.Pool; [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 DMLRCondensedRounds { [BepInPlugin("com.coloron.DMLRCondensedRounds", "DMLR Condensed Rounds", "1.0.0")] [MycoMod(/*Could not decode attribute arguments.*/)] public class DMLRCondensedRoundsPlugin : BaseUnityPlugin { public const string PluginGUID = "com.coloron.DMLRCondensedRounds"; public const string PluginName = "DMLR Condensed Rounds"; public const string PluginVersion = "1.0.0"; public const int ModUpgradeID = 88803; public static DMLRCondensedRoundsPlugin 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 Condensed Rounds..."); new Harmony("com.coloron.DMLRCondensedRounds").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_0058: Unknown result type (might be due to invalid IL or missing references) IUpgradable val = PlayerData.FindGear("dmlr"); if (val == null) { Logger.LogError((object)"[DMLRCondensedRounds] PlayerData.FindGear(\"dmlr\") returned null - aborting registration."); return; } CustomUpgradeParams val2 = CustomUpgradeParams.Create(val, 88803, "Condensed Rounds", "Hyperdense DMR rounds, increased impact force at the cost of elevated power draw and thermal stress. Impacts have a chance to generate a localized vacuum field, pulling nearby enemies toward the point of impact.", (Rarity)3, (Sprite)null); ref UpgradeFlags flags = ref val2.flags; flags = (UpgradeFlags)((uint)flags | 0x2000u); try { CustomUpgradeInstance = PlayerData.CreateUpgrade("com.coloron.DMLRCondensedRounds", val2, (UpgradeProperty[])(object)new UpgradeProperty[1] { new UpgradeProperty_DMLR_CondensedRounds() }); } catch (Exception arg) { Logger.LogError((object)$"[DMLRCondensedRounds] CreateUpgrade threw: {arg}"); return; } if ((Object)(object)CustomUpgradeInstance == (Object)null) { Logger.LogError((object)"[DMLRCondensedRounds] CustomUpgradeInstance is null after CreateUpgrade - aborting pattern setup."); return; } try { ApplyCustomPattern(CustomUpgradeInstance); Logger.LogInfo((object)"[DMLRCondensedRounds] Condensed Rounds upgrade registered successfully."); } catch (Exception arg2) { Logger.LogError((object)$"[DMLRCondensedRounds] ApplyCustomPattern threw: {arg2}"); } } private static void ApplyCustomPattern(Upgrade upgrade) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)upgrade == (Object)null)) { HexMap val = new HexMap(3, 4); val[0, 1].enabled = true; val[0, 1].connections = (Direction)2; val[0, 2].enabled = true; val[0, 2].connections = (Direction)13; val[0, 3].enabled = true; val[0, 3].connections = (Direction)4; val[1, 0].enabled = true; val[1, 1].enabled = true; val[1, 1].connections = (Direction)57; val[1, 2].enabled = true; val[1, 2].connections = (Direction)24; val[1, 3].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; } public static bool GunHasCondensedRounds(ScoutLaserRifle gun) { if ((Object)(object)gun == (Object)null || (Object)(object)CustomUpgradeInstance == (Object)null) { return false; } List<UpgradeInstance> list = PlayerData.GetUpgradeInfo((IUpgradable)(object)gun, CustomUpgradeInstance)?.Instances; if (list == null) { return false; } foreach (UpgradeInstance item in list) { if (item.IsEquipped((IUpgradable)(object)gun)) { return true; } } return false; } } [Serializable] public class UpgradeProperty_DMLR_CondensedRounds : UpgradeProperty { public override IEnumerator<StatData> 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 new StatData("DMR damage: <b>x3</b>"); yield return new StatData("Ammo cost: <b>x10</b>"); yield return new StatData("Fire rate: <b>-30%</b>"); yield return new StatData("Bullets <b>pierce</b> targets"); if (upgrade != null && upgrade.IsTurbocharged) { StatData val = UpgradeProperty.AddTurbochargedProperty(upgrade); yield return ((StatData)(ref val)).PlaceAtEnd(true); val = new StatData("Vacuum field on impact: <b>15%</b>"); yield return ((StatData)(ref val)).PlaceAtEnd(true); } } public override string GetTurbochargedInfo(Random rand, IUpgradable gear, UpgradeInstance upgrade) { return "<color=red><b>Turbocharged</b></color>\nVacuum field on impact: <b>15%</b>"; } public override void Apply(IGear gear, UpgradeInstance upgrade, ref Random rand) { ScoutLaserRifle val = (ScoutLaserRifle)(object)((gear is ScoutLaserRifle) ? gear : null); if (!((Object)(object)val == (Object)null)) { float fireInterval = ((Gun)val).GunData.fireInterval; ((Gun)val).GunData.fireInterval *= 1.5f; } } } [HarmonyPatch(typeof(ScoutLaserRifle), "ModifyBulletData")] public static class DMLRCondensedRoundsPatch { private const float DamageMultiplier = 3f; private const float ExtraAmmoToConsume = 9f; private static void Postfix(ScoutLaserRifle __instance, ref BulletData data, BulletFlags flags) { if (DMLRCondensedRoundsPlugin.GunHasCondensedRounds(__instance) && !__instance.IsLaserModeActive) { data.damage *= 3f; float remainingAmmo = ((Gun)__instance).RemainingAmmo; ((Gun)__instance).RemainingAmmo = Math.Max(0f, ((Gun)__instance).RemainingAmmo - 9f); } } } [HarmonyPatch(typeof(ScoutLaserRifle), "OnFiredBullet")] public static class DMLRCondensedRoundsPiercePatch { private static void Postfix(ScoutLaserRifle __instance, IBullet bullet, BulletFlags flags, int shotIndex, ref BulletData bulletData) { if (DMLRCondensedRoundsPlugin.GunHasCondensedRounds(__instance) && !__instance.IsLaserModeActive) { RailBullet val = (RailBullet)(object)((bullet is RailBullet) ? bullet : null); if ((Object)(object)val != (Object)null) { val.PierceTargets = true; } } } } [HarmonyPatch(typeof(ScoutLaserRifle), "OnUpgradesEnabled")] public static class DMLRCondensedRoundsEnablePatch { [CompilerGenerated] private static class <>O { public static DamageCallback <0>__OnDamageTarget; } private static void Postfix(ScoutLaserRifle __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown DamageCallback onDamageTarget = ((Gun)__instance).OnDamageTarget; object obj = <>O.<0>__OnDamageTarget; if (obj == null) { DamageCallback val = DMLRCondensedRoundsPullInPatch.OnDamageTarget; <>O.<0>__OnDamageTarget = val; obj = (object)val; } ((Gun)__instance).OnDamageTarget = (DamageCallback)Delegate.Combine((Delegate?)(object)onDamageTarget, (Delegate?)obj); } } [HarmonyPatch(typeof(ScoutLaserRifle), "OnUpgradesDisabled")] public static class DMLRCondensedRoundsDisablePatch { [CompilerGenerated] private static class <>O { public static DamageCallback <0>__OnDamageTarget; } private static void Postfix(ScoutLaserRifle __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown DamageCallback onDamageTarget = ((Gun)__instance).OnDamageTarget; object obj = <>O.<0>__OnDamageTarget; if (obj == null) { DamageCallback val = DMLRCondensedRoundsPullInPatch.OnDamageTarget; <>O.<0>__OnDamageTarget = val; obj = (object)val; } ((Gun)__instance).OnDamageTarget = (DamageCallback)Delegate.Remove((Delegate?)(object)onDamageTarget, (Delegate?)obj); } } public static class DMLRCondensedRoundsPullInPatch { private const float PullInForce = 25f; private const float PullInRadius = 7f; private const float TriggerChance = 0.15f; private const float PullDuration = 1f; private const float PullInterval = 0.2f; public static void OnDamageTarget(in DamageCallbackData data) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0127: Unknown result type (might be due to invalid IL or missing references) IDamageSource source = data.source; IDamageSource obj = ((source != null) ? source.ParentSource : null); ScoutLaserRifle val = (ScoutLaserRifle)(object)((obj is ScoutLaserRifle) ? obj : null); if ((Object)(object)val == (Object)null || val.IsLaserModeActive) { return; } UpgradeInfo upgradeInfo = PlayerData.GetUpgradeInfo((IUpgradable)(object)val, DMLRCondensedRoundsPlugin.CustomUpgradeInstance); bool flag = false; if (upgradeInfo?.Instances != null) { foreach (UpgradeInstance instance in upgradeInfo.Instances) { if (instance.IsEquipped((IUpgradable)(object)val)) { flag = instance.IsTurbocharged; break; } } } if (flag && !(((Random)(ref Random.shared)).NextFloat() > 0.15f)) { Vector3 position = data.position; if ((Object)(object)Global.Instance?.VortexEffect != (Object)null) { BurstEffect.InitializeObjectPosition(Global.Instance.VortexEffect, position, 7f); } if (NetworkManager.Singleton.IsServer) { ((MonoBehaviour)val).StartCoroutine(PullCoroutine(val, position)); } } } private static IEnumerator PullCoroutine(ScoutLaserRifle gun, Vector3 hitPos) { //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) WaitForSeconds wait = new WaitForSeconds(0.2f); for (float elapsed = 0f; elapsed < 1f; elapsed += 0.2f) { ApplyPullTick(gun, hitPos); yield return wait; } } private unsafe static void ApplyPullTick(ScoutLaserRifle gun, Vector3 hitPos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) TargetEnumerator val = default(TargetEnumerator); try { HashSet<EnemyBrain> hashSet = CollectionPool<HashSet<EnemyBrain>, EnemyBrain>.Get(); int num = 345216; if (((TargetEnumerator)(ref val)).GetTargetsInSphere(hitPos, 7f, num, (TargetType)5)) { while (((TargetEnumerator)(ref val)).MoveNext()) { ITarget current = ((TargetEnumerator)(ref val)).Current; EnemyPart val2 = (EnemyPart)(object)((current is EnemyPart) ? current : null); IPullable val3; if ((Object)(object)val2 != (Object)null) { EnemyBrain brain = val2.Brain; val3 = (IPullable)(object)(((Object)(object)brain != (Object)null && (int)val2.Brain.EnemyType < 2 && hashSet.Add(brain)) ? brain : null); } else { val3 = (IPullable)(object)((current is IPullable) ? current : null); } if (val3 != null) { val3.AddImpulseForce_Client(Vector3Extension.NormalizedFast(hitPos - val3.transform.position) * 25f); } } } CollectionPool<HashSet<EnemyBrain>, EnemyBrain>.Release(hashSet); } finally { ((IDisposable)(*(TargetEnumerator*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } }
DMLR4.dll
Decompiled a week agousing 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<float> chargeCapacityBonus = new Range<float>(1.5f, 2f); public override IEnumerator<StatData> 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; } } } }
DMLR.dll
Decompiled a week agousing 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 DMLRAutoSwap { [BepInPlugin("com.coloron.dmlrAutoSwap", "DMLR AutoSwap", "1.0.0")] [MycoMod(/*Could not decode attribute arguments.*/)] public class DMLRAutoSwapPlugin : BaseUnityPlugin { public const string PluginGUID = "com.coloron.dmlrAutoSwap"; public const string PluginName = "DMLR AutoSwap"; public const string PluginVersion = "1.0.0"; public const int ModUpgradeID = 88801; public static DMLRAutoSwapPlugin 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 AutoSwap..."); new Harmony("com.coloron.dmlrAutoSwap").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_0058: Unknown result type (might be due to invalid IL or missing references) IUpgradable val = PlayerData.FindGear("dmlr"); if (val == null) { Logger.LogError((object)"[DMLRAutoSwap] PlayerData.FindGear(\"dmlr\") returned null - aborting registration."); return; } CustomUpgradeParams val2 = CustomUpgradeParams.Create(val, 88801, "AutoSwap", "Increases Laser Burst radius and damage. Automatically switches between Laser and DMR modes when out of ammo or charge.", (Rarity)3, (Sprite)null); ref UpgradeFlags flags = ref val2.flags; flags = (UpgradeFlags)((uint)flags | 0x2000u); try { CustomUpgradeInstance = PlayerData.CreateUpgrade("com.coloron.dmlrAutoSwap", val2, (UpgradeProperty[])(object)new UpgradeProperty[1] { new UpgradeProperty_DMLR_AutoSwap() }); } catch (Exception arg) { Logger.LogError((object)$"[DMLRAutoSwap] CreateUpgrade threw: {arg}"); return; } if ((Object)(object)CustomUpgradeInstance == (Object)null) { Logger.LogError((object)"[DMLRAutoSwap] CustomUpgradeInstance is null after CreateUpgrade - aborting pattern setup."); return; } try { ApplyCustomPattern(CustomUpgradeInstance); Logger.LogInfo((object)"[DMLRAutoSwap] AutoSwap upgrade registered successfully."); } catch (Exception arg2) { Logger.LogError((object)$"[DMLRAutoSwap] 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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[0, 1].enabled = true; val[0, 1].connections = (Direction)5; val[1, 0].enabled = true; val[1, 0].connections = (Direction)56; val[1, 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; } public static bool GunHasAutoSwap(ScoutLaserRifle gun) { if ((Object)(object)gun == (Object)null || (Object)(object)CustomUpgradeInstance == (Object)null) { return false; } List<UpgradeInstance> list = PlayerData.GetUpgradeInfo((IUpgradable)(object)gun, CustomUpgradeInstance)?.Instances; if (list == null) { return false; } foreach (UpgradeInstance item in list) { if (item.IsEquipped((IUpgradable)(object)gun)) { return true; } } return false; } } [HarmonyPatch(typeof(ScoutLaserRifle))] public static class DMLRAutoSwitchPatch { private static float _lastForcedSwitchTime = -999f; private const float ForcedSwitchCooldown = 0.25f; [HarmonyPatch("OnActiveUpdate")] [HarmonyPostfix] private static void OnActiveUpdate_Postfix(ScoutLaserRifle __instance) { if (DMLRAutoSwapPlugin.GunHasAutoSwap(__instance) && !(Time.time - _lastForcedSwitchTime < 0.25f)) { bool isLaserModeActive = __instance.IsLaserModeActive; float laserCharge = __instance.LaserCharge; float remainingAmmo = ((Gun)__instance).RemainingAmmo; if (!isLaserModeActive && remainingAmmo <= 0f && laserCharge > 0f) { ForceToggleLaserMode(__instance); _lastForcedSwitchTime = Time.time; } else if (isLaserModeActive && laserCharge <= 0f) { ForceToggleLaserMode(__instance); _lastForcedSwitchTime = Time.time; } } } private static bool ForceToggleLaserMode(ScoutLaserRifle instance) { MethodInfo method = typeof(ScoutLaserRifle).GetMethod("ToggleLaserMode", BindingFlags.Instance | BindingFlags.NonPublic); if (method == null) { ManualLogSource logger = DMLRAutoSwapPlugin.Logger; if (logger != null) { logger.LogError((object)"[DMLRAutoSwap] ToggleLaserMode method not found via reflection!"); } return false; } method.Invoke(instance, null); return true; } } [Serializable] public class UpgradeProperty_DMLR_AutoSwap : UpgradeProperty { public const float burstSizeBonus = 2f; private const float TurboBurstSizeBonus = 1f; public Range<float> burstDamageBonus = new Range<float>(12f, 16f); private const float TurboBurstDamageBonus = 10f; public override IEnumerator<StatData> 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(TextBlocks.GetString("maxsize"), new Range<float>(2f, 2f), upgrade, ref rand, (OverrideType)1, (LabelType)1, default(BoostParams)); yield return StatData.Create(TextBlocks.GetString("Burst damage"), burstDamageBonus, upgrade, ref rand, (OverrideType)1, (LabelType)1, default(BoostParams)); if (upgrade != null && upgrade.IsTurbocharged) { StatData val = UpgradeProperty.AddTurbochargedProperty(upgrade); yield return ((StatData)(ref val)).PlaceAtEnd(true); val = new StatData($"Max Size: <b>+{1f}</b>\nBurst Damage: <b>+{10f}</b>"); yield return ((StatData)(ref val)).PlaceAtEnd(true); } } public override string GetTurbochargedInfo(Random rand, IUpgradable gear, UpgradeInstance upgrade) { return $"<color=red><b>Turbocharged</b></color>\nMax Size: <b>+{1f}</b>\nBurst Damage: <b>+{10f}</b>"; } public override void Apply(IGear gear, UpgradeInstance upgrade, ref Random rand) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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)) { val.LaserData.laserBurstSize += 2f; float value = burstDamageBonus.GetValue(ref rand, upgrade, default(BoostParams)); val.LaserData.laserBurstDamage += value; if (upgrade.IsTurbocharged) { val.LaserData.laserBurstSize += 1f; val.LaserData.laserBurstDamage += 10f; } } } } }