using 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 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 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: x3"); yield return new StatData("Ammo cost: x10"); yield return new StatData("Fire rate: -30%"); yield return new StatData("Bullets pierce 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: 15%"); yield return ((StatData)(ref val)).PlaceAtEnd(true); } } public override string GetTurbochargedInfo(Random rand, IUpgradable gear, UpgradeInstance upgrade) { return "Turbocharged\nVacuum field on impact: 15%"; } 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 hashSet = CollectionPool, 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, EnemyBrain>.Release(hashSet); } finally { ((IDisposable)(*(TargetEnumerator*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } }