Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of Antigravity Ray v1.0.4
AntigravityMod.dll
Decompiled 34 minutes agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using UnityEngine; [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("AntigravityMod")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4")] [assembly: AssemblyProduct("AntigravityMod")] [assembly: AssemblyTitle("AntigravityMod")] [assembly: AssemblyVersion("1.0.4.0")] namespace AntigravityMod; [BepInPlugin("com.owen.bopl.antigravity", "Antigravity Mod", "1.0.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Antigravity Mod loading..."); new Harmony("com.owen.bopl.antigravity").PatchAll(); Log.LogInfo((object)"All patches applied."); } } public static class AntigravTracker { public static HashSet<int> FlippedPlayers = new HashSet<int>(); public static HashSet<int> FlippedObjects = new HashSet<int>(); } [HarmonyPatch(typeof(AbilityGrid), "Awake")] public class MenuInjectionPatch { private static bool hasInjected; public static void Prefix(AbilityGrid __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) //IL_0056: 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_0070: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (hasInjected) { return; } NamedSpriteList value = Traverse.Create((object)__instance).Field("abilityIcons").GetValue<NamedSpriteList>(); if (!((Object)(object)value != (Object)null) || value.sprites == null) { return; } NamedSprite val = default(NamedSprite); bool flag = false; foreach (NamedSprite sprite in value.sprites) { if (sprite.name.ToLower().Contains("grow")) { val = sprite; flag = true; break; } } if (flag) { GameObject val2 = Object.Instantiate<GameObject>(val.associatedGameObject); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).name = "antigravity"; Ability component = val2.GetComponent<Ability>(); if ((Object)(object)component != (Object)null) { component.Cooldown *= (Fix)4L; } Sprite val3 = CreateBlueArrowSprite(); NamedSprite item = default(NamedSprite); ((NamedSprite)(ref item))..ctor("antigravity", val3, val2, true); value.sprites.Add(item); hasInjected = true; Plugin.Log.LogInfo((object)"[ANTIGRAV] Weapon injected successfully."); } } private static Sprite CreateBlueArrowSprite() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0157: Unknown result type (might be due to invalid IL or missing references) int num = 256; int num2 = num / 2; Texture2D val = new Texture2D(num, num); Color[] array = (Color[])(object)new Color[num * num]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.55f, 0.27f, 0.07f, 1f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.4f, 0.4f, 0.4f, 1f); Color val5 = default(Color); ((Color)(ref val5))..ctor(0.2f, 0.8f, 1f, 1f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { int num3 = j - num2; int num4 = i - num2; float num5 = Mathf.Sqrt((float)(num3 * num3 + num4 * num4)); if (num5 > 120f) { array[i * num + j] = val2; } else if (num5 > 110f) { array[i * num + j] = val3; } else { array[i * num + j] = val4; } if (j >= 106 && j <= 150 && i >= 60 && i <= 150) { array[i * num + j] = val5; } if (i > 150 && i <= 210) { int num6 = 210 - i; if (j >= num2 - num6 && j <= num2 + num6) { array[i * num + j] = val5; } } } } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f)); } } [HarmonyPatch(typeof(ShootScaleChange), "ApplyScaleChange")] public class AntigravApplyScaleChangePatch { public static bool Prefix(ShootScaleChange __instance, RaycastInformation hit, Vec2 firepoint, Vec2 direction, ref bool hasFired, int playerId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (hit.layer == LayerMask.NameToLayer("Water")) { return true; } __instance.spawnRayCastEffect((Vector2)firepoint, (Vector2)direction, (float)hit.nearDist, true, false); FixTransform fixTrans = hit.pp.fixTrans; Plugin.Log.LogInfo((object)("[ANTIGRAV] Hit parentTrans=" + (((Object)(object)fixTrans == (Object)null) ? "NULL" : ((Object)((Component)fixTrans).gameObject).name))); if ((Object)(object)fixTrans != (Object)null) { int num = -1; IPlayerIdHolder component = ((Component)fixTrans).GetComponent<IPlayerIdHolder>(); if (component != null) { num = component.GetPlayerId(); } else { Ability component2 = ((Component)fixTrans).GetComponent<Ability>(); if ((Object)(object)component2 != (Object)null) { num = component2.GetPlayerId(); } else { SlimeController component3 = ((Component)fixTrans).GetComponent<SlimeController>(); if ((Object)(object)component3 != (Object)null) { num = component3.GetPlayerId(); } } } if (num != -1) { if (AntigravTracker.FlippedPlayers.Contains(num)) { AntigravTracker.FlippedPlayers.Remove(num); Plugin.Log.LogInfo((object)$"[ANTIGRAV] Player ID {num}: restored to normal gravity."); } else { AntigravTracker.FlippedPlayers.Add(num); Plugin.Log.LogInfo((object)$"[ANTIGRAV] Player ID {num}: flipped to anti-gravity."); } PlayerPhysics[] array = Object.FindObjectsOfType<PlayerPhysics>(true); foreach (PlayerPhysics val in array) { IPlayerIdHolder component4 = ((Component)val).GetComponent<IPlayerIdHolder>(); if (component4 != null && component4.GetPlayerId() == num) { val.gravity_modifier = (AntigravTracker.FlippedPlayers.Contains(num) ? ((Fix)(-1L)) : ((Fix)1L)); val.UnGround(false, true); } } } else { BoplBody component5 = ((Component)fixTrans).GetComponent<BoplBody>(); if ((Object)(object)component5 != (Object)null && (((Component)component5).gameObject.layer != LayerMask.NameToLayer("wall") || ((Component)component5).gameObject.CompareTag("boulder")) && component5.StartingMass != Fix.Zero) { int instanceID = ((Object)((Component)component5).gameObject).GetInstanceID(); if (AntigravTracker.FlippedObjects.Contains(instanceID)) { AntigravTracker.FlippedObjects.Remove(instanceID); component5.velocity += new Vec2(Fix.Zero, (Fix)(-5L)); Plugin.Log.LogInfo((object)$"[ANTIGRAV] Object {instanceID}: restored."); } else { AntigravTracker.FlippedObjects.Add(instanceID); component5.velocity += new Vec2(Fix.Zero, (Fix)5L); Plugin.Log.LogInfo((object)$"[ANTIGRAV] Object {instanceID}: flipped."); } } } } hasFired = true; return false; } } [HarmonyPatch(typeof(ShootScaleChange), "spawnRayCastEffect")] public class BeamColorPatch { public static void Prefix(ShootScaleChange __instance) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)((Component)__instance).gameObject).name.ToLower().Contains("antigrav")) { return; } Color val = default(Color); ((Color)(ref val))..ctor(0.7f, 0.2f, 1f, 1f); ParticleSystem value = Traverse.Create((object)__instance).Field("rayParticle").GetValue<ParticleSystem>(); if ((Object)(object)value != (Object)null) { ParticleSystem[] componentsInChildren = ((Component)value).GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val); } } ParticleSystem value2 = Traverse.Create((object)__instance).Field("hitParticle").GetValue<ParticleSystem>(); if ((Object)(object)value2 != (Object)null) { ParticleSystem[] componentsInChildren = ((Component)value2).GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main2 = componentsInChildren[i].main; ((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(val); } } } } [HarmonyPatch(typeof(PlayerPhysics), "UpdateSim")] [HarmonyPriority(600)] public class EnforceAntigravPatch { public static void Prefix(PlayerPhysics __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) IPlayerIdHolder component = ((Component)__instance).GetComponent<IPlayerIdHolder>(); if (component != null && AntigravTracker.FlippedPlayers.Contains(component.GetPlayerId())) { __instance.gravity_modifier = (Fix)(-1L); } } } [HarmonyPatch(typeof(PlayerPhysics), "Jump")] public class FixInvertedJumpPatch { public static bool Prefix(PlayerPhysics __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (__instance.gravity_modifier >= Fix.Zero) { return true; } __instance.jumpedThisFrame = true; PlayerBody playerBody = __instance.GetPlayerBody(); StickyRoundedRectangle attachedGround = __instance.getAttachedGround(); if (__instance.IsGrounded() && (Object)(object)attachedGround != (Object)null) { Vec2 val = attachedGround.currentNormal(playerBody); Vec2 val2 = new Vec2(val.y, -val.x) * __instance.groundedSpeed; if (val.y > Fix.Zero) { Vec2 val3 = default(Vec2); ((Vec2)(ref val3))..ctor(val.x * __instance.jumpExtraXStrength, Fix.Zero); playerBody.selfImposedVelocity = val2 * __instance.jumpKeptMomentum + val3; } else { Vec2 val4 = default(Vec2); ((Vec2)(ref val4))..ctor(val.x * __instance.jumpExtraXStrength, -__instance.jumpStrength); playerBody.selfImposedVelocity = val2 * __instance.jumpKeptMomentum + val4; } } playerBody.position += playerBody.selfImposedVelocity * __instance.extraJumpTeleportMultiplier; ((Component)__instance).transform.position = (Vector3)playerBody.position; __instance.UnGround(true, true); return false; } } [HarmonyPatch(typeof(PlayerPhysics), "AddGravityFactor")] public class FixInvertedDragPatch { public static bool Prefix(PlayerPhysics __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0099: Unknown result type (might be due to invalid IL or missing references) if (__instance.gravity_modifier >= Fix.Zero) { return true; } PlayerBody playerBody = __instance.GetPlayerBody(); Fix val = __instance.gravity_accel * __instance.gravity_modifier; playerBody.selfImposedVelocity += Vec2.down * val; Fix val2 = Fix.Abs(val) / __instance.gravity_maxFallSpeed; if (playerBody.selfImposedVelocity.y > Fix.Zero) { playerBody.selfImposedVelocity += Vec2.down * val2 * playerBody.selfImposedVelocity.y; } return false; } } [HarmonyPatch(typeof(BoplBody), "UpdateSim")] public class BoplBodyAntigravityPatch { public static void Postfix(BoplBody __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //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_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (AntigravTracker.FlippedObjects.Contains(((Object)((Component)__instance).gameObject).GetInstanceID())) { Fix val = (Constants.isSpaceLevel ? ((Fix)1.6f) : ((Fix)3.2f)); __instance.velocity += new Vec2(Fix.Zero, val); if (__instance.velocity.y > (Fix)27f) { __instance.velocity = new Vec2(__instance.velocity.x, (Fix)27f); } } } } [HarmonyPatch(typeof(PlayerHandler), "ResetForNextStage")] public class StageResetPatch { public static void Prefix() { Plugin.Log.LogInfo((object)"[ANTIGRAV] Round reset detected. Wiping tracking state."); AntigravTracker.FlippedPlayers.Clear(); AntigravTracker.FlippedObjects.Clear(); } } [HarmonyPatch(typeof(Player), "Kill")] public class PlayerDeathPatch { public static void Prefix(Player __instance) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"[ANTIGRAV] Player ID {__instance.Id} died. Checking antigravity state."); if (!AntigravTracker.FlippedPlayers.Contains(__instance.Id)) { return; } AntigravTracker.FlippedPlayers.Remove(__instance.Id); Plugin.Log.LogInfo((object)$"[ANTIGRAV] Removed antigravity state for player {__instance.Id}."); PlayerPhysics[] array = Object.FindObjectsOfType<PlayerPhysics>(true); foreach (PlayerPhysics val in array) { IPlayerIdHolder component = ((Component)val).GetComponent<IPlayerIdHolder>(); if (component != null && component.GetPlayerId() == __instance.Id) { val.gravity_modifier = (Fix)1L; } } } }