Decompiled source of Control Enemies Mod v1.0.3
UMM/Mods/Control Enemies Mod/Control Enemies Mod.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BitCode; using BroMakerLib; using BroMakerLib.CustomObjects; using BroMakerLib.Loaders; using HarmonyLib; using Localisation; using Networking; using Rewired; using RocketLib; using RocketLib.Utils; using TFBGames.Management.Asset; using UnityEngine; using UnityModManagerNet; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Control Enemies Mod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Control Enemies Mod")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("52724136-162b-41e7-94f7-ea1e65b59a0c")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")] namespace Control_Enemies_Mod; public enum GhostState { Idle, Attacking, Taunting, Resurrecting, Reviving } public class GhostPlayer : MonoBehaviour { public int playerNum; public Player player; public float spawnDelay = 0.25f; public GhostState state; public Vector3 overrideSpawnPoint = Vector3.zero; protected bool ableToRevive; protected float forceReviveTime; protected float startReviveFlashTime; public const float ghostSpawnOffset = 16f; public SpriteSM sprite; public float currentTransparency; protected const float finalTransparency = 0.75f; public Color playerColor = new Color(1f, 1f, 1f); public int frame; protected float frameCounter; protected const float idleFramerate = 0.11f; protected float attackingFramerate = 0.08f; protected float dancingFramerate = 0.11f; protected float resurrectingFramerate = 0.11f; protected float reviveFramerate = 0.11f; protected const float spriteWidth = 32f; protected const float spriteHeight = 32f; protected Color reviveColor = new Color(1f, 0.8431f, 0f); public static Color[] playerColors = (Color[])(object)new Color[4] { new Color(0f, 0.5f, 1f), new Color(1f, 0f, 0f), new Color(1f, 0.45f, 0f), new Color(0.55f, 0f, 1f) }; public static Color burningColor = new Color(0.53f, 0.05f, 0.15f); public bool up; public bool left; public bool down; public bool right; public bool fire; public bool buttonJump; public bool special; public bool highfive; public bool buttonGesture; public bool sprint; protected float yI; protected float xI; protected const float normalSpeed = 130f; protected const float sprintSpeed = 180f; protected const float accelerationFactor = 3.5f; protected const float decelerationFactor = 1.5f; protected float screenMinX; protected float screenMaxX; protected float screenMinY; protected float screenMaxY; protected bool usingController; protected int controllerNum; protected bool wasLeft; protected bool wasRight; protected float leftTapTime; protected float rightTapTime; protected const float minDashTapTime = 0.33f; protected bool dashing; private TestVanDammeAnim characterToPossess; private Vector3 frozenPosition = Vector3.zero; private float frozenXI; private float frozenYI; public void Setup() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) //IL_0095: 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_00f3: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) try { MeshRenderer component = ((Component)this).gameObject.GetComponent<MeshRenderer>(); Material material = ResourcesController.GetMaterial(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sprites"), "ghostSprite.png"); ((Renderer)component).material = material; sprite = ((Component)this).gameObject.GetComponent<SpriteSM>(); sprite.SetTextureDefaults(); ((SpriteBase)sprite).SetSize(32f, 32f); sprite.lowerLeftPixel = new Vector2(0f, 32f); sprite.pixelDimensions = new Vector2(32f, 32f); ((SpriteBase)sprite).plane = (SPRITE_PLANE)0; ((SpriteBase)sprite).width = 32f; ((SpriteBase)sprite).height = 32f; ((SpriteBase)sprite).color = new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency); ((SpriteBase)sprite).CalcUVs(); ((SpriteBase)sprite).UpdateUVs(); ((SpriteBase)sprite).offset = new Vector3(0f, 0f, 0f); ((Component)this).gameObject.layer = 28; } catch (Exception ex) { Main.Log("Exception creating ghost: " + ex.ToString()); } } public virtual void Start() { //IL_001e: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) player = HeroController.players[playerNum]; playerColor = playerColors[playerNum]; if (Main.isBurning && playerNum == 1) { playerColor = burningColor; } if (player.controllerNum > 3) { usingController = true; controllerNum = player.controllerNum - 4; } } public void SetSpawn() { //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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) Vector3 val; if (overrideSpawnPoint == Vector3.zero) { val = Map.FindStartLocation(); if (Mathf.Abs(SortOfFollow.GetScreenMinX() - val.x) < 100f) { val.y += 40f; val.x = SortOfFollow.GetScreenMinX() + 25f + (SortOfFollow.GetScreenMaxX() - SortOfFollow.GetScreenMinX() - 50f) / 4f * (float)(playerNum + 1); } else { val.y = SortOfFollow.GetScreenMinY() + 60f + (SortOfFollow.GetScreenMaxY() - SortOfFollow.GetScreenMinY()) / 2f; val.x = SortOfFollow.GetScreenMinX() + 25f + (SortOfFollow.GetScreenMaxX() - SortOfFollow.GetScreenMinX() - 50f) / 4f * (float)(playerNum + 1); } } else { val = overrideSpawnPoint; val.y += 16f; } ((Component)this).transform.position = val; } public virtual void Update() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (spawnDelay > 0f) { spawnDelay -= Time.deltaTime; if (spawnDelay <= 0f) { SetSpawn(); } return; } HandleTransparency(); HandleInput(); ConstrainToScreen(); ChangeFrame(); if (ableToRevive && state != GhostState.Reviving) { forceReviveTime -= Time.deltaTime; if (forceReviveTime <= 0f) { StartReviving(); } else { float num = 0.5f + Mathf.Sin((Time.time - startReviveFlashTime) * 15f) * 0.23f; Color val = default(Color); ((Color)(ref val))..ctor(num, num, num, 1f); ((Component)sprite).GetComponent<Renderer>().material.SetColor("_TintColor", val); } } if (state == GhostState.Attacking && ((Object)(object)characterToPossess == (Object)null || !((BroforceObject)characterToPossess).IsAlive() || ((BroforceObject)characterToPossess).health <= 0)) { if ((Object)(object)characterToPossess != (Object)null) { ((Object)characterToPossess).name = "enemy"; } characterToPossess = null; state = GhostState.Idle; frame = 0; SetFrame(); } } public virtual void LateUpdate() { if ((Object)(object)characterToPossess != (Object)null) { ((BroforceObject)characterToPossess).X = frozenPosition.x; ((BroforceObject)characterToPossess).Y = frozenPosition.y; ((BroforceObject)characterToPossess).xI = frozenXI; ((BroforceObject)characterToPossess).yI = frozenYI; } } public void HandleTransparency() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (currentTransparency < 0.75f) { currentTransparency += Time.deltaTime / 1.5f; if (currentTransparency > 0.75f) { currentTransparency = 0.75f; } ((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency)); } } public void HandleInput() { //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) player.GetInput(ref up, ref down, ref left, ref right, ref fire, ref buttonJump, ref special, ref highfive, ref buttonGesture, ref sprint); if (state == GhostState.Idle || state == GhostState.Reviving) { sprint = sprint || InputReader.GetDashStart(player.controllerNum); if (left && !wasLeft) { if (!dashing && !right && Time.time - leftTapTime < 0.33f) { dashing = true; } leftTapTime = Time.time; } if (right && !wasRight) { if (!dashing && !left && Time.time - rightTapTime < 0.33f) { dashing = true; } rightTapTime = Time.time; } if (!left && !right) { dashing = false; } sprint = sprint || dashing; if (usingController) { Player val = ReInput.players.GetPlayer(controllerNum); float num = val.GetAxis("Up") - val.GetAxis("Down"); float num2 = val.GetAxis("Right") - val.GetAxis("Left"); float num3 = (sprint ? 180f : 130f); if (Mathf.Abs(yI) < Mathf.Abs(num * num3)) { yI += num * num3 * Time.deltaTime * 3.5f; } if (yI > num3) { yI = num3; } else if (yI < 0f - num3) { yI = 0f - num3; } if (Mathf.Abs(xI) < Mathf.Abs(num2 * num3)) { xI += num2 * num3 * Time.deltaTime * 3.5f; } if (xI > num3) { xI = num3; } else if (xI < 0f - num3) { xI = 0f - num3; } if (!up && !down) { if (yI > 0f) { yI -= num3 * Time.deltaTime * 1.5f; if (yI < 0f) { yI = 0f; } } else if (yI < 0f) { yI += num3 * Time.deltaTime * 1.5f; if (yI > 0f) { yI = 0f; } } } if (right) { if (((Component)this).transform.localScale.x != 1f) { ((Component)this).transform.localScale = new Vector3(1f, 1f, 1f); } } else if (left) { if (((Component)this).transform.localScale.x != -1f) { ((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f); } } else if (xI > 0f) { xI -= num3 * Time.deltaTime * 1.5f; if (xI < 0f) { xI = 0f; } } else if (xI < 0f) { xI += num3 * Time.deltaTime * 1.5f; if (xI > 0f) { xI = 0f; } } } else { float num4 = (sprint ? 180f : 130f); if (up) { yI += num4 * Time.deltaTime * 3.5f; if (yI > num4) { yI = num4; } } else if (down) { yI -= num4 * Time.deltaTime * 3.5f; if (yI < 0f - num4) { yI = 0f - num4; } } else if (yI > 0f) { yI -= num4 * Time.deltaTime * 1.5f; if (yI < 0f) { yI = 0f; } } else if (yI < 0f) { yI += num4 * Time.deltaTime * 1.5f; if (yI > 0f) { yI = 0f; } } if (right) { if (((Component)this).transform.localScale.x != 1f) { ((Component)this).transform.localScale = new Vector3(1f, 1f, 1f); } xI += num4 * Time.deltaTime * 3.5f; if (xI > num4) { xI = num4; } } else if (left) { if (((Component)this).transform.localScale.x != -1f) { ((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f); } xI -= num4 * Time.deltaTime * 3.5f; if (xI < 0f - num4) { xI = 0f - num4; } } else if (xI > 0f) { xI -= num4 * Time.deltaTime * 1.5f; if (xI < 0f) { xI = 0f; } } else if (xI < 0f) { xI += num4 * Time.deltaTime * 1.5f; if (xI > 0f) { xI = 0f; } } } Vector3 position = ((Component)this).transform.position; position.x += xI * Time.deltaTime; position.y += yI * Time.deltaTime; ((Component)this).transform.position = position; if (state == GhostState.Reviving || ableToRevive) { ((BroforceObject)player.character).SetXY(position.x, position.y); } if (state != GhostState.Reviving) { if (fire) { if (!ableToRevive) { TryToAttack(); HeroController.SetAvatarAngry(playerNum, true); } else { StartReviving(); } } else { HeroController.SetAvatarCalm(playerNum, true); } if (buttonGesture && state != GhostState.Attacking) { frame = 0; state = GhostState.Taunting; } } } else if (state == GhostState.Taunting) { if (right) { if (((Component)this).transform.localScale.x != 1f) { ((Component)this).transform.localScale = new Vector3(1f, 1f, 1f); } } else if (left && ((Component)this).transform.localScale.x != -1f) { ((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f); } float num5 = (sprint ? 180f : 130f); if (yI > 0f) { yI -= num5 * Time.deltaTime * 1.5f; if (yI < 0f) { yI = 0f; } } else if (yI < 0f) { yI += num5 * Time.deltaTime * 1.5f; if (yI > 0f) { yI = 0f; } } if (xI > 0f) { xI -= num5 * Time.deltaTime * 1.5f; if (xI < 0f) { xI = 0f; } } else if (xI < 0f) { xI += num5 * Time.deltaTime * 1.5f; if (xI > 0f) { xI = 0f; } } if (!buttonGesture) { frame = 0; state = GhostState.Idle; } } wasLeft = left; wasRight = right; } public void ConstrainToScreen() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) SetResolutionCamera.GetScreenExtents(ref screenMinX, ref screenMaxX, ref screenMinY, ref screenMaxY); Vector3 position = ((Component)this).transform.position; if (position.x < screenMinX + 5f) { position.x = screenMinX + 5f; } else if (position.x > screenMaxX - 5f) { position.x = screenMaxX - 5f; } if (position.y < screenMinY + 10f) { position.y = screenMinY + 10f; } else if (position.y > screenMaxY - 10f) { position.y = screenMaxY - 10f; } ((Component)this).transform.position = position; } public void ChangeFrame() { frameCounter += Time.deltaTime; switch (state) { case GhostState.Idle: if (frameCounter > 0.11f) { frameCounter -= 0.11f; frame++; if (frame > 7) { frame = 0; } sprite.SetLowerLeftPixel((float)frame * 32f, 32f); } break; case GhostState.Attacking: if (frameCounter > attackingFramerate) { frameCounter -= attackingFramerate; frame++; if (frame > 13) { frame = 0; FinishAttack(); } sprite.SetLowerLeftPixel((float)frame * 32f, 64f); } break; case GhostState.Taunting: if (frameCounter > dancingFramerate) { frameCounter -= dancingFramerate; frame++; if (frame > 21) { frame = 4; } sprite.SetLowerLeftPixel((float)frame * 32f, 96f); } break; case GhostState.Resurrecting: if (frameCounter > resurrectingFramerate) { frameCounter -= resurrectingFramerate; frame++; if (frame > 15) { frame = 0; state = GhostState.Idle; sprite.SetLowerLeftPixel((float)frame * 32f, 32f); } else { sprite.SetLowerLeftPixel((float)frame * 32f, 128f); } } break; case GhostState.Reviving: if (frameCounter > reviveFramerate) { frameCounter -= reviveFramerate; frame++; if (frame > 14) { ReviveCharacter(); frame = 0; } sprite.SetLowerLeftPixel((float)frame * 32f, 160f); } break; } } public void SetFrame() { switch (state) { case GhostState.Idle: sprite.SetLowerLeftPixel((float)frame * 32f, 32f); break; case GhostState.Attacking: sprite.SetLowerLeftPixel((float)frame * 32f, 64f); break; case GhostState.Taunting: sprite.SetLowerLeftPixel((float)frame * 32f, 96f); break; case GhostState.Resurrecting: sprite.SetLowerLeftPixel((float)frame * 32f, 128f); break; case GhostState.Reviving: sprite.SetLowerLeftPixel((float)frame * 32f, 32f); break; } } public static TestVanDammeAnim GetNextClosestUnit(int playerNum, float xRange, float yRange, float x, float y) { if (Map.units == null) { return null; } float num = xRange; TestVanDammeAnim val = null; for (int num2 = Map.units.Count - 1; num2 >= 0; num2--) { Unit obj = Map.units[num2]; TestVanDammeAnim val2 = (TestVanDammeAnim)(object)((obj is TestVanDammeAnim) ? obj : null); if ((Object)(object)val2 != (Object)null && Main.AvailableToPossess(val2)) { float num3 = ((BroforceObject)val2).Y + ((Unit)val2).height / 2f + 3f - y; if (Mathf.Abs(num3) - yRange < ((Unit)val2).height && Mathf.Abs(((BroforceObject)val2).X - x) - num < ((Unit)val2).width) { val = val2; num = Mathf.Abs(num3); } } } if ((Object)(object)val != (Object)null) { return val; } return null; } public void TryToAttack() { //IL_0025: 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_007f: 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) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0125: Unknown result type (might be due to invalid IL or missing references) if (player.Lives > 0) { TestVanDammeAnim nextClosestUnit = GetNextClosestUnit(playerNum, 15f, 10f, ((Component)this).transform.position.x, ((Component)this).transform.position.y); if ((Object)(object)nextClosestUnit != (Object)null) { characterToPossess = nextClosestUnit; ((Object)characterToPossess).name = "p"; ((Component)this).transform.localScale = new Vector3(Mathf.Sign(((BroforceObject)characterToPossess).X - ((Component)this).transform.position.x), 1f, 1f); frozenPosition = ((Component)characterToPossess).transform.position; frozenXI = ((BroforceObject)characterToPossess).xI; frozenYI = ((BroforceObject)characterToPossess).yI; ((Component)this).transform.position = new Vector3(((BroforceObject)characterToPossess).X - ((Component)this).transform.localScale.x * 11f, ((BroforceObject)characterToPossess).Y + ((Unit)characterToPossess).height + 3f, 0f); state = GhostState.Attacking; frame = 0; xI = 0f; yI = 0f; } } } public void FinishAttack() { if ((Object)(object)characterToPossess != (Object)null && ((BroforceObject)characterToPossess).IsAlive() && ((BroforceObject)characterToPossess).health > 0) { Main.StartControllingUnit(playerNum, characterToPossess); characterToPossess = null; state = GhostState.Idle; ((Component)this).gameObject.SetActive(false); return; } if ((Object)(object)characterToPossess != (Object)null) { ((Object)characterToPossess).name = "enemy"; } characterToPossess = null; state = GhostState.Idle; frame = 0; SetFrame(); } public void SetCanReviveCharacter() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) state = GhostState.Idle; if ((Object)(object)characterToPossess != (Object)null) { ((Object)characterToPossess).name = "enemy"; characterToPossess = null; } ableToRevive = true; forceReviveTime = 1.5f; startReviveFlashTime = Time.time; ((SpriteBase)sprite).SetColor(new Color(reviveColor.r, reviveColor.g, reviveColor.b, currentTransparency)); } public void StartReviving() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ableToRevive = false; state = GhostState.Reviving; frame = 0; ((Component)sprite).GetComponent<Renderer>().material.SetColor("_TintColor", Color.gray); } public void ReviveCharacter() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) ((Component)player.character).transform.position = ((Component)this).transform.position; ((BroforceObject)player.character).SetXY(((Component)this).transform.position.x, ((Component)this).transform.position.y - 15f); ((Component)player.character).transform.localScale = ((Component)this).transform.localScale; ((Component)this).gameObject.SetActive(false); ((BroforceObject)player.character).xI = xI; ((BroforceObject)player.character).yI = yI; ((Component)player.character).gameObject.SetActive(true); Main.SwitchToHeroAvatar(playerNum); state = GhostState.Idle; currentTransparency = 0.75f; ((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency)); } public void StartResurrecting() { frame = 0; state = GhostState.Resurrecting; SetFrame(); } public void ReActivate() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (HeroController.players[playerNum].Lives <= 0) { playerColor = new Color(1f, 1f, 1f, 1f); ((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency)); } ((Component)this).gameObject.SetActive(true); } } public static class HarmonyPatches { [HarmonyPatch(typeof(PolymorphicAI), "Update")] public static class PolymorphicAI_Update_Patch { public static bool Prefix(PolymorphicAI __instance) { //IL_0040: 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) if (!Main.enabled) { return true; } if (Main.IsControlledAI(__instance)) { if (Main.settings.competitiveModeEnabled && !Main.revealed[((NetworkedUnit)((Component)__instance).gameObject.GetComponent<TestVanDammeAnim>()).playerNum]) { __instance.mentalState = (MentalState)0; } else { __instance.mentalState = (MentalState)2; } return false; } return true; } } [HarmonyPatch(typeof(PolymorphicAI), "LateUpdate")] public static class PolymorphicAI_LateUpdate_Patch { public static bool Prefix(PolymorphicAI __instance) { //IL_0040: 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) if (!Main.enabled) { return true; } if (Main.IsControlledAI(__instance)) { if (Main.settings.competitiveModeEnabled && !Main.revealed[((NetworkedUnit)((Component)__instance).gameObject.GetComponent<TestVanDammeAnim>()).playerNum]) { __instance.mentalState = (MentalState)0; } else { __instance.mentalState = (MentalState)2; } return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "GetEnemyMovement")] public static class TestVanDammeAnim_GetEnemyMovement_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } if (((Object)__instance).name == "p") { __instance.left = (__instance.right = false); return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "SetGestureAnimation")] public static class TestVanDammeAnim_SetGestureAnimation_Patch { public static bool Prefix(TestVanDammeAnim __instance, ref Gestures gesture) { if (!Main.enabled || !Main.settings.disableTaunting) { return true; } if ((int)gesture == 4 && Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "Death", new Type[] { typeof(float), typeof(float), typeof(DamageObject) })] public static class TestVanDammeAnim_Death_Patch { public static bool outOfBounds; public static void Prefix(TestVanDammeAnim __instance, ref float xI, ref float yI, ref DamageObject damage) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance) && damage != null) { outOfBounds = (int)damage.damageType == 5; } } public static void Postfix(TestVanDammeAnim __instance, ref float xI, ref float yI, ref DamageObject damage) { if (!Main.enabled) { return; } try { if (Main.settings.competitiveModeEnabled) { if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4) { Main.PlayerDiedInCompetitiveMode(__instance, damage); } } else if (Main.IsControlledUnit((Unit)(object)__instance) && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && (!Main.settings.respawnFromCorpse || HeroController.players[((NetworkedUnit)__instance).playerNum].Lives <= 0 || outOfBounds || !((Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null))) { SatanMiniboss val = (SatanMiniboss)(object)((__instance is SatanMiniboss) ? __instance : null); if ((Object)(object)val == (Object)null || val.IsInStage2()) { Main.LeaveUnit(__instance, ((NetworkedUnit)__instance).playerNum, onlyLeaveUnit: true); } } } catch (Exception ex) { Main.Log("Exception in death: " + ex.ToString()); } } } [HarmonyPatch(typeof(TestVanDammeAnim), "Gib")] public static class TestVanDammeAnim_Gib_Patch { public static void Prefix(TestVanDammeAnim __instance, ref DamageType damageType) { if (!Main.enabled) { return; } try { if (((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode(__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } catch (Exception ex) { Main.Log("Exception in gib: " + ex.ToString()); } } } [HarmonyPatch(typeof(TestVanDammeAnim), "ReduceLives")] public static class TestVanDammeAnim_ReduceLives_Patch { public static bool ignoreNextLifeLoss; public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (!Main.settings.competitiveModeEnabled && Main.IsControlledUnit((Unit)(object)__instance) && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && Main.currentlyEnemy[((NetworkedUnit)__instance).playerNum]) { bool flag = false; AlienFaceHugger val = (AlienFaceHugger)(object)((__instance is AlienFaceHugger) ? __instance : null); if (val != null && val.insemenationCompleted && val.layEggsInsideBros) { flag = true; AlienXenomorph_Start_Patch.controlNextAlien = true; AlienXenomorph_Start_Patch.controllerPlayerNum = ((NetworkedUnit)val).playerNum; } if ((Main.settings.respawnFromCorpse && !TestVanDammeAnim_Death_Patch.outOfBounds && (Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null) || flag) { if (Main.settings.loseLifeOnDeath && !flag && ((int)Main.previousDeathType[((NetworkedUnit)__instance).playerNum] != 2 || !Main.settings.noLifeLossOnSuicide)) { HeroController.players[((NetworkedUnit)__instance).playerNum].RemoveLife(); } if (HeroController.players[((NetworkedUnit)__instance).playerNum].Lives > 0) { Main.countdownToRespawn[((NetworkedUnit)__instance).playerNum] = (flag ? 10f : 0.6f); return false; } return true; } if (!Main.settings.loseLifeOnDeath && (Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null) { ignoreNextLifeLoss = true; } } return true; } } [HarmonyPatch(typeof(Mook), "NotifyDeathType")] public static class Mook_NotifyDeathType_Patch { public static void Prefix(Mook __instance, DeathType ___deathType) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance) && (int)Main.previousDeathType[((NetworkedUnit)__instance).playerNum] != 2) { Main.previousDeathType[((NetworkedUnit)__instance).playerNum] = (DeathType)(int)___deathType; } } } [HarmonyPatch(typeof(Player), "RemoveLife")] public static class Player_RemoveLife_Patch { public static bool allowLifeLoss; public static bool Prefix(Player __instance) { if (!Main.enabled) { return true; } if (TestVanDammeAnim_ReduceLives_Patch.ignoreNextLifeLoss) { TestVanDammeAnim_ReduceLives_Patch.ignoreNextLifeLoss = false; Main.previousDeathType[__instance.playerNum] = (DeathType)1; return false; } if (Main.settings.noLifeLossOnSuicide && (Object)(object)__instance.character != (Object)null && Main.IsControlledUnit((Unit)(object)__instance.character) && UnitTypes.IsSuicideUnit(Main.currentUnitType[__instance.playerNum]) && (int)Main.previousDeathType[__instance.playerNum] == 2) { Main.previousDeathType[__instance.playerNum] = (DeathType)1; return false; } Main.previousDeathType[__instance.playerNum] = (DeathType)1; if (Main.settings.competitiveModeEnabled) { if (Main.settings.ghostLives == 0 && __instance.playerNum != Main.currentHeroNum) { allowLifeLoss = false; return false; } if (Main.settings.heroLives == 0 && __instance.playerNum == Main.currentHeroNum) { allowLifeLoss = false; return false; } if (allowLifeLoss) { allowLifeLoss = false; return true; } return false; } return true; } } [HarmonyPatch(typeof(Player), "IsAlive")] public static class Player_IsAlive_Patch { public static bool Prefix(Player __instance, ref bool __result) { if (!Main.enabled) { return true; } if (Main.everyoneDead) { __result = false; return false; } if (Main.countdownToRespawn[__instance.playerNum] > 0f) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(PlayerHUD), "SetAvatarDead")] public static class PlayerHUD_SetAvatarDead_Patch { public static bool Prefix(PlayerHUD __instance, int ___playerNum, ref bool ___SetToDead) { if (!Main.enabled) { return true; } if (Main.countdownToRespawn[___playerNum] > 0f) { ___SetToDead = true; return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "IsOverFinish")] public static class TestVanDammeAnim_IsOverFinish_Patch { public static readonly LayerMask victoryLayer = LayerMask.op_Implicit(1 << LayerMask.NameToLayer("Finish")); public static float AttachToHelicopter(TestVanDammeAnim __instance, Helicopter helicopter) { //IL_0012: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) helicopter.attachedHeroes.Add(__instance); float result = ((Component)helicopter).transform.position.x + 13f; helicopter.Leave(); ((Component)__instance).transform.parent = helicopter.ladderHolder; float x = ((Component)helicopter).transform.position.x; if (((BroforceObject)__instance).X > x) { ((Component)__instance).transform.localScale = new Vector3(-1f, 1f, 1f); ((BroforceObject)__instance).X = x + 5f; } else { ((Component)__instance).transform.localScale = new Vector3(1f, 1f, 1f); ((BroforceObject)__instance).X = x - 5f; } ((Component)__instance).transform.position = new Vector3(Mathf.Round(((BroforceObject)__instance).X), Mathf.Round(((BroforceObject)__instance).Y), -50f); return result; } public static void IsOverFinish(TestVanDammeAnim character, ref float ladderXPos, ref bool __result, bool canTakePortal = true) { //IL_0011: 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_00e7: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(new Vector3(((BroforceObject)character).X, ((BroforceObject)character).Y, 0f), 4f, LayerMask.op_Implicit(victoryLayer)); if (array.Length == 0) { return; } HeroLevelExitPortal component = ((Component)array[0]).GetComponent<HeroLevelExitPortal>(); if ((Object)(object)component != (Object)null && !canTakePortal) { __result = false; return; } ((Unit)character).invulnerable = true; if ((Object)(object)((Component)character).GetComponent<AudioSource>() != (Object)null) { ((Component)character).GetComponent<AudioSource>().Stop(); } ((Behaviour)character).enabled = false; if ((Object)(object)((Component)array[0]).transform.parent != (Object)null) { if ((Object)(object)((Component)((Component)array[0]).transform.parent).GetComponent<HelicopterFake>() != (Object)null || Map.MapData.onlyTriggersCanWinLevel) { Helicopter component2 = ((Component)((Component)array[0]).transform.parent).GetComponent<Helicopter>(); ladderXPos = AttachToHelicopter(character, component2); Networking.RPC<Vector3, float, TestVanDammeAnim, Helicopter, bool>(PID.TargetAll, (RpcSignature<Vector3, float, TestVanDammeAnim, Helicopter, bool>)HeroController.Instance.AttachHeroToHelicopter, ((Component)character).transform.localPosition, ((Component)character).transform.localScale.x, character, component2, false, false); __result = true; } Helicopter component3 = ((Component)((Component)array[0]).transform.parent).GetComponent<Helicopter>(); if ((Object)(object)component3 != (Object)null) { ladderXPos = AttachToHelicopter(character, component3); Networking.RPC<Vector3, float, TestVanDammeAnim, Helicopter, bool>(PID.TargetAll, (RpcSignature<Vector3, float, TestVanDammeAnim, Helicopter, bool>)HeroController.Instance.AttachHeroToHelicopter, ((Component)character).transform.localPosition, ((Component)character).transform.localScale.x, character, component3, true, false); } } Traverse obj = Traverse.Create((object)character); obj.Field("jumpTime").SetValue((object)0.07f); obj.Field("doubleJumpsLeft").SetValue((object)0); if ((Object)(object)component != (Object)null) { typeof(TestVanDammeAnim).GetMethod("SuckIntoPortal", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(character, null); } GameModeController.LevelFinish((LevelResult)1); Map.StartLevelEndExplosionsOverNetwork(); character.isOnHelicopter = true; ((NetworkedUnit)character).playerNum = 5; __result = true; } public static bool Prefix(TestVanDammeAnim __instance, ref float ladderXPos, ref bool __result) { if (!Main.enabled) { return true; } if (!Main.settings.competitiveModeEnabled) { if (Main.IsControlledUnit((Unit)(object)__instance) && ((Unit)__instance).IsHeavy()) { __result = false; if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4) { IsOverFinish(__instance, ref ladderXPos, ref __result); } return false; } } else { if (((NetworkedUnit)__instance).playerNum != Main.currentHeroNum || !((Component)__instance).gameObject.activeSelf) { return false; } if (Main.openedPortal && ((NetworkedUnit)__instance).playerNum == Main.currentHeroNum && !ScoreManager.CanWin(((NetworkedUnit)__instance).playerNum)) { IsOverFinish(__instance, ref ladderXPos, ref __result, canTakePortal: false); return false; } } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "RecallBro")] public static class TestVanDammeAnim_RecallBro_Patch { public static void Prefix(TestVanDammeAnim __instance) { if (Main.enabled && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4) { Main.previousCharacter[((NetworkedUnit)__instance).playerNum] = null; } } } [HarmonyPatch(typeof(TestVanDammeAnim), "ShowStartBubble")] public static class TestVanDammeAnim_ShowStartBubble_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } return !Main.IsControlledUnit((Unit)(object)__instance); } } [HarmonyPatch(typeof(TestVanDammeAnim), "RestartBubble", new Type[] { typeof(float) })] public static class TestVanDammeAnim_RestartBubble_float_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } return !Main.IsControlledUnit((Unit)(object)__instance); } } [HarmonyPatch(typeof(TestVanDammeAnim), "RestartBubble", new Type[] { })] public static class TestVanDammeAnim_RestartBubble_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } return !Main.IsControlledUnit((Unit)(object)__instance); } } [HarmonyPatch(typeof(HeroController), "SwitchAvatarMaterial")] public static class HeroController_SwitchAvatarMaterial_Patch { public static bool Prefix(ref SpriteSM sprite, ref bool __result) { if (!Main.enabled) { return true; } if (Main.settings.competitiveModeEnabled && Main.playerWon) { int num = -1; PlayerScoreDisplay component = ((Component)((Component)sprite).transform.parent.parent.parent).gameObject.GetComponent<PlayerScoreDisplay>(); if ((Object)(object)component != (Object)null && LevelOverScreen_Show_Patch.scoreDisplays.Length != 0) { for (int i = 0; i < LevelOverScreen_Show_Patch.scoreDisplays.Length; i++) { if ((Object)(object)LevelOverScreen_Show_Patch.scoreDisplays[i] == (Object)(object)component) { num = i; break; } } } if (num == -1) { return true; } if (num == Main.attemptingWin) { if (Main.isBroMakerInstalled && Main.SetAvatarToSwitch(HeroController.players[num].character, num)) { HeroController.SwitchAvatarMaterial(sprite, (HeroType)(-1)); return false; } return true; } ((Component)sprite).GetComponent<Renderer>().material = Main.ghostAvatarMat; return false; } PlayerHUD component2 = ((Component)sprite).gameObject.GetComponent<PlayerHUD>(); if ((Object)(object)component2 != (Object)null) { int num2 = (int)Traverse.Create((object)component2).Field("playerNum").GetValue(); if (Main.currentlyEnemy[num2]) { ((Component)sprite).GetComponent<Renderer>().material = Main.defaultAvatarMat; return false; } } return true; } } [HarmonyPatch(typeof(Map), "Start")] public static class Map_Start_Patch { public static void Prefix(Map __instance) { if (Main.enabled) { Main.ClearVariables(); if (Main.settings.competitiveModeEnabled && Main.currentHeroNum == -1) { Main.currentHeroNum = Random.Range(0, HeroController.NumberOfPlayers()); } } } } [HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallAnticipation")] public static class TestVanDammeAnim_AnimateWallAnticipation_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { ((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]); return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallClimb")] public static class TestVanDammeAnim_AnimateWallClimb_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { ((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]); return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallDrag")] public static class TestVanDammeAnim_AnimateWallDrag_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { ((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]); return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "PlayStunnedSound")] public static class TestVanDammeAnim_PlayStunnedSound_Patch { public static bool Prefix(TestVanDammeAnim __instance, ref float ___stunVocalDelay) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance) && Main.holdingGesture[((NetworkedUnit)__instance).playerNum]) { __instance.PlayLaughterSound(); ___stunVocalDelay = 0.4f + Random.Range(0.3f, 0.9f); return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "ThrowBackGrenade")] public static class TestVanDammeAnim_ThrowBackGrenade_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance) && (int)Main.currentUnitType[((NetworkedUnit)__instance).playerNum] == 13) { return false; } return true; } } [HarmonyPatch(typeof(Mook), "FallDamage")] public static class Mook_FallDamage_Patch { public static bool Prefix(Mook __instance) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookBigGuy), "FallDamage")] public static class MookBigGuy_FallDamage_Patch { public static bool Prefix(MookBigGuy __instance) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(Alien), "FallDamage")] public static class Alien_FallDamage_Patch { public static bool Prefix(Alien __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(AlienFaceHugger), "FallDamage")] public static class AlienFaceHugger_FallDamage_Patch { public static bool Prefix(AlienFaceHugger __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(AlienMelter), "FallDamage")] public static class AlienMelter_FallDamage_Patch { public static bool Prefix(AlienMelter __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(Animal), "FallDamage")] public static class Animal_FallDamage_Patch { public static bool Prefix(Animal __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookArmouredGuy), "FallDamage")] public static class MookArmouredGuy_FallDamage_Patch { public static bool Prefix(MookArmouredGuy __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookDog), "FallDamage")] public static class MookDog_FallDamage_Patch { public static bool Prefix(MookDog __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookHellBigGuy), "FallDamage")] public static class MookHellBigGuy_FallDamage_Patch { public static bool Prefix(MookHellBigGuy __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookHellBoomer), "FallDamage")] public static class MookHellBoomer_FallDamage_Patch { public static bool Prefix(MookHellBoomer __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(MookSuicide), "FallDamage")] public static class MookSuicide_FallDamage_Patch { public static bool Prefix(MookSuicide __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(SkinnedMook), "FallDamage")] public static class MSkinnedMook_FallDamage_Patch { public static bool Prefix(SkinnedMook __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(Villager), "FallDamage")] public static class Villager_FallDamage_Patch { public static bool Prefix(Villager __instance, ref float yI) { if (!Main.enabled || !Main.settings.disableFallDamage) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { return false; } return true; } } [HarmonyPatch(typeof(SetResolutionCamera), "IsItVisible")] public static class SetResolutionCamera_IsItVisible_Patch { public static bool Prefix(SetResolutionCamera __instance, ref bool __result) { if (!Main.enabled) { return true; } if (overrideNextVisibilityCheck) { __result = true; overrideNextVisibilityCheck = false; return false; } return true; } } [HarmonyPatch(typeof(SortOfFollow), "IsItSortOfVisible", new Type[] { typeof(float), typeof(float), typeof(float), typeof(float) })] public static class SortOfFollow_IsItSortOfVisible_Patch { public static bool Prefix(SortOfFollow __instance, ref bool __result) { if (!Main.enabled) { return true; } if (overrideNextVisibilityCheck) { __result = true; overrideNextVisibilityCheck = false; return false; } return true; } } [HarmonyPatch(typeof(Mook), "UseFire")] public static class Mook_UseFire_Patch { public static void Prefix(Mook __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookArmouredGuy), "UseFire")] public static class MookArmouredGuy_UseFire_Patch { public static void Prefix(MookArmouredGuy __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookBigGuy), "UseFire")] public static class MookBigGuy_UseFire_Patch { public static void Prefix(MookBigGuy __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookHellBoomer), "UseFire")] public static class MookHellBoomer_UseFire_Patch { public static void Prefix(MookHellBoomer __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookJetpackBazooka), "UseFire")] public static class MookJetpackBazooka_UseFire_Patch { public static void Prefix(MookJetpackBazooka __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookBigGuyElite), "UseFire")] public static class MookBigGuyElite_UseFire_Patch { public static void Prefix(MookBigGuyElite __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(MookBazooka), "UseFire")] public static class MookBazooka_UseFire_Patch { public static void Prefix(MookBazooka __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { overrideNextVisibilityCheck = true; } } } [HarmonyPatch(typeof(Mook), "CanPassThroughBarriers")] public static class Mook_CanPassThroughBarriers_Patch { public static bool Prefix(Mook __instance, ref bool __result) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(MookDog), "CanPassThroughBarriers")] public static class MookDog_CanPassThroughBarriers_Patch { public static bool Prefix(MookDog __instance, ref bool __result) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(MookSuicide), "Gib")] public static class MookSuicide_Gib_Patch { public static void Prefix(MookSuicide __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(MookJetpack), "Gib")] public static class MookJetpack_Gib_Patch { public static void Prefix(MookJetpack __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(AlienMelter), "Gib")] public static class AlienMelter_Gib_Patch { public static void Prefix(AlienMelter __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(AlienMosquito), "Gib")] public static class AlienMosquito_Gib_Patch { public static void Prefix(AlienMosquito __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(MookSuicideUndead), "Gib")] public static class MookSuicideUndead_Gib_Patch { public static void Prefix(MookSuicideUndead __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(Villager), "Death")] public static class Villager_Death_Patch { public static void Prefix(Villager __instance, ref DamageObject damage) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance, damage); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds && damage != null) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damage.damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(Villager), "Gib", new Type[] { typeof(DamageType), typeof(float), typeof(float) })] public static class Villager_Gib_Patch { public static void Prefix(Villager __instance, ref DamageType damageType) { if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)) { return; } if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!TestVanDammeAnim_Death_Patch.outOfBounds) { TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(Villager), "Gib", new Type[] { })] public static class Villager_Gib2_Patch { public static void Prefix(Villager __instance) { if (Main.enabled && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && (Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance) { if (Main.settings.competitiveModeEnabled) { Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance); } else if (Main.IsControlledUnit((Unit)(object)__instance)) { typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } } [HarmonyPatch(typeof(SatanMiniboss), "StartDeathRattle")] public static class SatanMiniboss_StartDeathRattle_Patch { public static void Prefix(SatanMiniboss __instance) { if (!Main.enabled || Main.settings.competitiveModeEnabled) { return; } if (Main.IsControlledUnit((Unit)(object)__instance)) { Main.LeaveUnit((TestVanDammeAnim)(object)__instance, ((NetworkedUnit)__instance).playerNum, onlyLeaveUnit: true); } else { if (!(((Object)__instance).name == "Enemy")) { return; } for (int i = 0; i < 4; i++) { if (HeroController.IsPlaying(i) && (Object)(object)HeroController.players[i].character == (Object)(object)__instance) { HeroController.players[i].character = null; } } } } } [HarmonyPatch(typeof(MookSuicide), "MakeEffects")] public static class MookSuicide_MakeEffects_Patch { public static bool Prefix(MookSuicide __instance, bool ___recalling) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance) && ___recalling) { return false; } return true; } } [HarmonyPatch(typeof(MookSuicideUndead), "MakeEffects")] public static class MookSuicideUndead_MakeEffects_Patch { public static bool Prefix(MookSuicideUndead __instance, bool ___recalling) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance) && ___recalling) { return false; } return true; } } [HarmonyPatch(typeof(HellLostSoul), "MakeEffects")] public static class HellLostSoul_MakeEffects_Patch { public static void Prefix(HellLostSoul __instance, bool ___diving) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance) && ___diving) { ((TestVanDammeAnim)__instance).fire = true; } } } [HarmonyPatch(typeof(AlienMosquito), "MakeEffects")] public static class AlienMosquito_MakeEffects_Patch { public static void Prefix(AlienMosquito __instance, bool ___diving) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance) && ___diving) { ((TestVanDammeAnim)__instance).fire = true; } } } [HarmonyPatch(typeof(TestVanDammeAnim), "AnimateClimbingLadder")] public static class TestVanDammeAnim_AnimateClimbingLadder_Patch { private static readonly FieldRef<TestVanDammeAnim, int> pixelWidthRef = AccessTools.FieldRefAccess<TestVanDammeAnim, int>("spritePixelWidth"); private static readonly FieldRef<TestVanDammeAnim, int> pixelHeightRef = AccessTools.FieldRefAccess<TestVanDammeAnim, int>("spritePixelHeight"); public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); CodeMatcher val = new CodeMatcher((IEnumerable<CodeInstruction>)list, generator); MethodInfo setLowerLeftPixel = AccessTools.Method(typeof(SpriteSM), "SetLowerLeftPixel", new Type[2] { typeof(float), typeof(float) }, (Type[])null); MethodInfo methodInfo = AccessTools.Method(typeof(TestVanDammeAnim_AnimateClimbingLadder_Patch), "SetLadderPixel", (Type[])null, (Type[])null); if ((object)setLowerLeftPixel == null || (object)methodInfo == null) { Main.mod.Logger.Log("AnimateClimbingLadder transpiler: method lookup failed"); return list; } for (int i = 0; i < 4; i++) { val.MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction inst) => CodeInstructionExtensions.Calls(inst, setLowerLeftPixel)), (string)null) }); if (!val.IsValid) { Main.mod.Logger.Log($"AnimateClimbingLadder transpiler: SetLowerLeftPixel call #{i} not found"); return list; } val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }); val.Advance(1); val.Set(OpCodes.Call, (object)methodInfo); val.Advance(1); } return val.InstructionEnumeration(); } public static void SetLadderPixel(SpriteSM sprite, float x, float y, TestVanDammeAnim instance) { //IL_0024: 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) //IL_0028: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if (!Main.enabled || !Main.IsControlledUnit((Unit)(object)instance)) { sprite.SetLowerLeftPixel(x, y); return; } UnitType val = Main.currentUnitType[((NetworkedUnit)instance).playerNum]; if ((int)val == 40 || val - 42 <= 1) { int num = 2; int num2 = pixelWidthRef.Invoke(instance); int num3 = pixelHeightRef.Invoke(instance); int num4 = ((Unit)instance).frame % 4; sprite.SetLowerLeftPixel((float)(num4 * num2), (float)(num3 * num)); } else { sprite.SetLowerLeftPixel(x, y); } } } [HarmonyPatch(typeof(HellDogEgg), "MakeEffects")] public static class HellDogEgg_MakeEffects_Patch { public static bool nextDogFriendly; public static int playerNum = -1; public static void Prefix(HellDogEgg __instance) { if (Main.enabled) { MonoBehaviour firedBy = ((Projectile)__instance).firedBy; Unit val = (Unit)(object)((firedBy is Unit) ? firedBy : null); if ((val != null && Main.IsControlledUnit(val)) || ((NetworkedUnit)/*isinst with value type is only supported in some contexts*/).playerNum >= 0) { nextDogFriendly = true; MonoBehaviour firedBy2 = ((Projectile)__instance).firedBy; playerNum = ((NetworkedUnit)((firedBy2 is Mook) ? firedBy2 : null)).playerNum; } } } } [HarmonyPatch(typeof(HellDog), "GrowFromEgg")] public static class HellDog_GrowFromEgg_Patch { public static void Prefix(HellDog __instance) { if (Main.enabled && HellDogEgg_MakeEffects_Patch.nextDogFriendly) { ((Mook)__instance).firingPlayerNum = HellDogEgg_MakeEffects_Patch.playerNum; ((NetworkedUnit)__instance).playerNum = HellDogEgg_MakeEffects_Patch.playerNum; HellDogEgg_MakeEffects_Patch.nextDogFriendly = false; } } } [HarmonyPatch(typeof(AlienXenomorph), "Start")] public static class AlienXenomorph_Start_Patch { public static int controllerPlayerNum = -1; public static bool controlNextAlien; public static void Postfix(AlienXenomorph __instance) { if (!Main.enabled) { return; } if (controlNextAlien) { if ((Object)(object)Main.previousCharacter[controllerPlayerNum] == (Object)null) { Main.StartControllingUnit(controllerPlayerNum, (TestVanDammeAnim)(object)__instance, gentleLeave: true, savePreviousCharacter: false); } else { Main.StartControllingUnit(controllerPlayerNum, (TestVanDammeAnim)(object)__instance, gentleLeave: true); } controlNextAlien = false; Main.countdownToRespawn[controllerPlayerNum] = -1f; } else if (Main.IsControlledUnit((Unit)(object)__instance)) { int num = Main.currentUnit.IndexOf((Unit)(object)__instance); if (num != ((NetworkedUnit)__instance).playerNum) { Main.ReaffirmControl(num); } ((TestVanDammeAnim)__instance).SpecialAmmo = 0; } } } [HarmonyPatch(typeof(MookJetpack), "StartJetPacks")] public static class MookJetpack_StartJetPacks_Patch { public static bool allowJetpack; public static bool Prefix(MookJetpack __instance, ref float ___jetpacksDelay) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { if (!allowJetpack) { ___jetpacksDelay = 1000000f; return false; } allowJetpack = false; ___jetpacksDelay = 0f; } return true; } } [HarmonyPatch(typeof(MookJetpack), "Land")] public static class MookJetpack_Land_Patch { public static void Postfix(MookJetpack __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { __instance.jetPackHeight = ((TestVanDammeAnim)__instance).groundHeight + 48f; } } } [HarmonyPatch(typeof(PolymorphicAI), "GetSeenPlayerNum")] public static class PolymorphicAI_GetSeenPlayerNum_Patch { public static void Postfix(PolymorphicAI __instance, ref int __result) { if (Main.enabled && Main.IsControlledAI(__instance) && __instance is MookWarlockAI) { if (Main.settings.competitiveModeEnabled) { __result = Main.currentHeroNum; } else { __result = ((NetworkedUnit)((Component)__instance).GetComponent<TestVanDammeAnim>()).playerNum; } } } } [HarmonyPatch(typeof(WarlockPortal), "SpawnUnit")] public static class WarlockPortal_SpawnUnit_Patch { public static void Postfix(WarlockPortal __instance) { if (Main.enabled && (Object)(object)__instance.owner != (Object)null && Main.IsControlledUnit((Unit)(object)__instance.owner)) { ((NetworkedUnit)__instance.unit).playerNum = ((NetworkedUnit)__instance.owner).playerNum; } } } [HarmonyPatch(typeof(MookArmouredGuy), "DisChargePilotRPC")] public static class MookArmouredGuy_DisChargePilotRPC_Patch { public static void Prefix(MookArmouredGuy __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { Unit pilotUnit = __instance.pilotUnit; TestVanDammeAnim val = (TestVanDammeAnim)(object)((pilotUnit is TestVanDammeAnim) ? pilotUnit : null); if ((Object)(object)val != (Object)null && Main.AvailableToPossess(val)) { int playerNum = ((NetworkedUnit)__instance).playerNum; Main.LeaveUnit((TestVanDammeAnim)(object)__instance, playerNum, onlyLeaveUnit: true); Main.countdownToRespawn[playerNum] = 1f; Main.StartControllingUnit(playerNum, val, gentleLeave: true, savePreviousCharacter: false); Main.countdownToRespawn[playerNum] = 0f; ((Component)val).transform.parent = ((Component)Map.Instance).transform; } } } } [HarmonyPatch(typeof(Mook), "DischargePilotingUnit")] public static class Mook_DischargePilotingUnit_Patch { public static bool Prefix(Mook __instance, ref float x, ref float y, ref float xI, ref float yI, ref bool stunUnit, ref float ___ignoreHighFivePressTime, ref float ___jumpTime, ref float ___stunTime) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { ((TestVanDammeAnim)__instance).SetInvulnerable(0.1f, false, false); if ((Object)(object)((TestVanDammeAnim)__instance).gunSprite != (Object)null) { ((Behaviour)((TestVanDammeAnim)__instance).gunSprite).enabled = true; ((Component)((TestVanDammeAnim)__instance).gunSprite).GetComponent<Renderer>().enabled = true; } ((Component)__instance).GetComponent<Renderer>().enabled = true; ___ignoreHighFivePressTime = 0.1f; ___jumpTime = 0.13f; ((Behaviour)__instance).enabled = true; ((BroforceObject)__instance).health = 1; ((TestVanDammeAnim)__instance).pilottedUnit = null; ((TestVanDammeAnim)__instance).SpecialAmmo = ((TestVanDammeAnim)__instance).SpecialAmmo; ((BroforceObject)__instance).SetXY(x, y); ((BroforceObject)__instance).yI = yI; if (!stunUnit) { ((TestVanDammeAnim)__instance).xIBlast = xI; } else { ((TestVanDammeAnim)__instance).xIBlast = xI * 0.5f; ((BroforceObject)__instance).xI = xI * 0.5f; } ((TestVanDammeAnim)__instance).ShowStartBubble(); ((Component)__instance).gameObject.SetActive(true); if (stunUnit) { ((Unit)__instance).Stun(1f); } else { ___stunTime = 0f; } ((BroforceObject)__instance).xI = xI; ((TestVanDammeAnim)__instance).xIBlast = 0f; return false; } return true; } } [HarmonyPatch(typeof(MookGeneral), "SpawnMook")] public static class MookGeneral_SpawnMook_Patch { public static bool Prefix(MookGeneral __instance, ref Mook prefab, ref float x, ref float y) { if (!Main.enabled) { return true; } if (Main.IsControlledUnit((Unit)(object)__instance)) { Mook obj = MapController.SpawnMook_Networked(prefab, x, y, 0f, 0f, false, false, true, false, true); ((NetworkedUnit)obj).playerNum = ((NetworkedUnit)__instance).playerNum; obj.firingPlayerNum = ((Mook)__instance).firingPlayerNum; return false; } return true; } } [HarmonyPatch(typeof(MookSuicide), "Start")] public static class MookSuicide_Start_Patch { public static void Postfix(MookSuicide __instance, ref float ___halfWidth) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { ___halfWidth = 6f; } } } [HarmonyPatch] public static class RemoteControlExplosiveCar_CheckInput_Patch { [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(TestVanDammeAnim), "CheckInput")] public static void CheckInput(RemoteControlExplosiveCar instance) { } [HarmonyPatch(typeof(RemoteControlExplosiveCar), "CheckInput")] public static void Prefix(RemoteControlExplosiveCar __instance) { if (Main.enabled) { if (Main.IsControlledUnit((Unit)(object)__instance)) { CheckInput(__instance); } if (((TestVanDammeAnim)__instance).fire || ((TestVanDammeAnim)__instance).special) { RemoteControlExplosiveCar_Explode_Patch.manualActivation = true; ((TestVanDammeAnim)__instance).fire = (((TestVanDammeAnim)__instance).special = false); __instance.Explode(); } } } } [HarmonyPatch(typeof(RemoteControlExplosiveCar), "Explode")] public static class RemoteControlExplosiveCar_Explode_Patch { public static bool manualActivation; public static void Prefix(RemoteControlExplosiveCar __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { if (manualActivation && Main.settings.noLifeLossOnSuicide) { manualActivation = false; return; } typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false }); } } } [HarmonyPatch(typeof(SkinnedMook), "Start")] public static class SkinnedMook_Start_Patch { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); CodeMatcher val = new CodeMatcher((IEnumerable<CodeInstruction>)list, generator); MethodInfo deathRPCMethod = AccessTools.Method(typeof(Unit), "DeathRPC", new Type[4] { typeof(float), typeof(float), typeof(float), typeof(float) }, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(NetworkedUnit), "_playerNum"); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0f, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0f, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, deathRPCMethod)), (string)null) }); if (!val.IsValid) { Main.mod.Logger.Log("SkinnedMook.Start transpiler: Could not find DeathRPC call"); return list; } Label label = generator.DefineLabel(); val.Insert((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Bge_S, (object)label) }); val.Advance(12); val.Labels.Add(label); return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(Player), "SpawnHero")] public static class Player_SpawnHero_Patch { public static void Prefix(Player __instance) { if (!Main.enabled) { return; } Main.currentlyEnemy[__instance.playerNum] = false; if ((Object)(object)Main.currentUnit[__instance.playerNum] != (Object)null) { Main.controlledUnits.Remove(Main.currentUnit[__instance.playerNum]); } if (Main.settings.spawnAsEnemyEnabled) { Main.willReplaceBro[__instance.playerNum] = Main.settings.spawnAsEnemyChance > 0f && Main.settings.spawnAsEnemyChance >= Random.value * 100f; if (Main.willReplaceBro[__instance.playerNum]) { Main.DisableBroMaker(__instance.playerNum); } } } public static void Postfix(Player __instance) { //IL_005c: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 if (!Main.enabled) { return; } try { if (Main.willReplaceBro[__instance.playerNum]) { Main.EnableBroMaker(); Main.willReplaceBro[__instance.playerNum] = false; if (!Main.settings.alwaysChosen) { Main.settings.selGridInt[__instance.playerNum] = Random.Range(0, Main.currentUnitList.Length); } TestVanDammeAnim component = Main.SpawnUnit(Main.GetSelectedUnit(__instance.playerNum), new Vector3(0f, 0f, 0f)).GetComponent<TestVanDammeAnim>(); Main.StartControllingUnit(__instance.playerNum, component, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true); Main.WorkOutSpawnPosition(__instance, component); if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38) { HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component), "flying", true); ((BroforceObject)component).yI = ((BroforceObject)component).yI + 30f; ((BroforceObject)component).xI = ((BroforceObject)component).xI + 30f; ((BroforceObject)component).Y = ((BroforceObject)component).Y + 10f; } } else { Main.previousCharacter[__instance.playerNum] = null; Main.currentlyEnemy[__instance.playerNum] = false; if ((Object)(object)Main.currentUnit[__instance.playerNum] != (Object)null) { Main.controlledUnits.Remove(Main.currentUnit[__instance.playerNum]); } } if (Main.settings.competitiveModeEnabled && __instance.playerNum != Main.currentHeroNum) { Main.HidePlayer(__instance.playerNum); } } catch (Exception ex) { Main.Log("Exception replacing bro: " + ex.ToString()); } } } [HarmonyPatch(typeof(Player), "InstantiateHero")] public static class Player_InstantiateHero_Patch { public static void Postfix(Player __instance, ref TestVanDammeAnim __result) { if (Main.enabled && Main.willReplaceBro[__instance.playerNum]) { ((Component)__result).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Map), "AddBroToHeroTransport")] public static class Map_AddBroToHeroTransport_Patch { public static bool Prefix(ref TestVanDammeAnim Bro) { if (Main.enabled) { if (((NetworkedUnit)Bro).playerNum >= 0 && ((NetworkedUnit)Bro).playerNum < 4) { return !Main.willReplaceBro[((NetworkedUnit)Bro).playerNum]; } return true; } return true; } } [HarmonyPatch(typeof(Player), "WorkOutSpawnPosition")] public static class Player_WorkOutSpawnPosition_Patch { public static void Prefix(Player __instance) { if (Main.enabled && Main.willReplaceBro[__instance.playerNum]) { Main.wasFirstDeployment[__instance.playerNum] = __instance.firstDeployment; } } } [HarmonyPatch(typeof(Player), "WorkOutSpawnScenario")] public static class Player_WorkOutSpawnScenario_Patch { public static bool forceCheckpointSpawn; public static void Postfix(Player __instance, ref SpawnType __result) { if (!Main.enabled) { return; } if (Main.settings.competitiveModeEnabled) { if (__instance.firstDeployment) { if (__instance.playerNum == Main.currentHeroNum) { if (Main.settings.heroLives == 0) { __instance.Lives = 10; } else if (Main.anyAttemptingWin) { __instance.Lives = Main.settings.heroLives + Main.settings.extraLiveOnBossLevel + Main.settings.livesHandicap[__instance.playerNum]; } else { __instance.Lives = Main.settings.heroLives + Main.settings.livesHandicap[__instance.playerNum]; } } else if (Main.settings.ghostLives == 0) { __instance.Lives = 10; } else { __instance.Lives = Main.settings.ghostLives + Main.settings.livesHandicap[__instance.playerNum]; } } if (forceCheckpointSpawn) { __result = (SpawnType)2; if (Main.isBroMakerInstalled) { Main.OverrideSpawn(__instance.playerNum); } forceCheckpointSpawn = false; } } if (Main.willReplaceBro[__instance.playerNum]) { Main.previousSpawnInfo[__instance.playerNum] = __result; } } } [HarmonyPatch(typeof(HeroTransport), "ReleaseBros")] public static class HeroTransport_ReleaseBros_Patch { public static void Postfix(HeroTransport __instance) { if (!Main.enabled) { return; } for (int i = 0; i < 4; i++) { if (HeroController.PlayerIsAlive(i) && Main.currentlyEnemy[i]) { TestVanDammeAnim character = HeroController.players[i].character; if ((Object)(object)((NetworkedUnit)character).enemyAI != (Object)null) { ((Behaviour)((NetworkedUnit)character).enemyAI).enabled = true; } } } } } [HarmonyPatch(typeof(Player), "GetInput")] public static class Player_GetInput_Patch { public static void Postfix(Player __instance, ref bool up, ref bool down, ref bool left, ref bool right, ref bool fire, ref bool buttonJump, ref bool special, ref bool highFive, ref bool buttonGesture, ref bool sprint) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Invalid comparison between Unknown and I4 //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Invalid comparison between Unknown and I4 if (!Main.enabled) { return; } int playerNum = __instance.playerNum; if (Main.settings.spawnAsEnemyEnabled) { bool flag = Main.swapEnemiesLeft.IsDown(playerNum); bool flag2 = Main.swapEnemiesRight.IsDown(playerNum); if ((((flag || flag2) && Main.currentSpawnCooldown[playerNum] <= 0f && __instance.IsAlive()) || (Main.settings.clickingSwapEnabled && Main.switched[playerNum])) && (Object)(object)__instance.character.pilottedUnit == (Object)null) { Vector3 characterPosition = __instance.GetCharacterPosition(); float x = characterPosition.x; float y = characterPosition.y; float num = (float)Traverse.Create((object)__instance.character).Field("xI").GetValue(); float num2 = (float)Traverse.Create((object)__instance.character).Field("yI").GetValue(); if (Main.settings.clickingSwapEnabled && Main.switched[playerNum]) { try { TestVanDammeAnim component = Main.SpawnUnit(Main.GetSelectedUnit(playerNum), characterPosition).GetComponent<TestVanDammeAnim>(); Main.StartControllingUnit(playerNum, component, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true); ((Unit)__instance.character).SetPositionAndVelocity(x, y, num, num2); __instance.character.SetInvulnerable(0f, false, false); if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38) { HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component), "flying", true); ((BroforceObject)component).yI = ((BroforceObject)component).yI + 30f; ((BroforceObject)component).xI = ((BroforceObject)component).xI + 30f; ((BroforceObject)component).Y = ((BroforceObject)component).Y + 10f; } Main.switched[playerNum] = false; return; } catch (Exception ex) { Main.Log("Exception switching unit: " + ex.ToString()); return; } } if (flag) { Main.settings.selGridInt[playerNum]--; if (Main.settings.selGridInt[playerNum] < 0) { Main.settings.selGridInt[playerNum] = Main.currentUnitList.Length - 1; } } else if (flag2) { Main.settings.selGridInt[playerNum]++; if (Main.settings.selGridInt[playerNum] > Main.currentUnitList.Length - 1) { Main.settings.selGridInt[playerNum] = 0; } } TestVanDammeAnim component2 = Main.SpawnUnit(Main.GetSelectedUnit(playerNum), characterPosition).GetComponent<TestVanDammeAnim>(); Main.StartControllingUnit(playerNum, component2, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true); ((Unit)__instance._character).SetPositionAndVelocity(x, y, num, num2); __instance.character.SetInvulnerable(0f, false, false); if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38) { HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component2), "flying", true); ((BroforceObject)component2).yI = ((BroforceObject)component2).yI + 30f; ((BroforceObject)component2).xI = ((BroforceObject)component2).xI + 30f; ((BroforceObject)component2).Y = ((BroforceObject)component2).Y + 10f; } Main.currentSpawnCooldown[playerNum] = Main.settings.spawnSwapCooldown; } } if (!Main.currentlyEnemy[playerNum]) { return; } TestVanDammeAnim character = __instance.character; bool down2 = Main.special2[playerNum].IsDown(); bool down3 = Main.special3[playerNum].IsDown(); Main.HandleSpecial(ref special, ref Main.specialWasDown[playerNum], ref Main.holdingSpecial[playerNum], character, playerNum); Main.HandleButton(down2, ref Main.holdingSpecial2[playerNum], ref Main.special2WasDown[playerNum], Main.PressSpecial2, Main.ReleaseSpecial2, character, playerNum); Main.HandleButton(down3, ref Main.holdingSpecial3[playerNum], ref Main.special3WasDown[playerNum], Main.PressSpecial3, Main.ReleaseSpecial3, character, playerNum); special = Main.holdingSpecial[playerNum]; if (buttonGesture && !Main.holdingGesture[playerNum] && UnitTypes.CanDance(Main.currentUnitType[playerNum])) { Main.holdingGesture[playerNum] = true; ((Unit)character).Dance(10000000f); } if (Main.settings.competitiveModeEnabled) { if (fire && Main.currentHeroNum != playerNum) { Main.revealed[playerNum] = true; } if (((Unit)character).IsIncapacitated() || ((Unit)character).IsBlind()) { up = (down = (left = (right = (fire = (buttonJump = (special = (highFive = (buttonGesture = (sprint = false))))))))); } } } } [HarmonyPatch(typeof(TestVanDammeAnim), "Start")] public static class TestVanDammeAnim_Start_Patch { public static void Postfix(TestVanDammeAnim __instance) { if (!Main.enabled) { return; } if (Main.settings.spawnAsEnemyEnabled) { if (Main.IsControlledUnit((Unit)(object)__instance)) { int num = Main.currentUnit.IndexOf((Unit)(object)__instance); if (num != ((NetworkedUnit)__instance).playerNum) { Main.ReaffirmControl(num); } __instance.SpecialAmmo = 0; } } else if (Main.settings.competitiveModeEnabled && Main.waitingToBecomeEnemy.Count > 0) { int num2 = Main.waitingToBecomeEnemy[Random.Range(0, Main.waitingToBecomeEnemy.Count)]; if (num2 == Main.currentHeroNum) { Main.waitingToBecomeEnemy.Remove(num2); } else if ((((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4) && !Main.IsControlledUnit((Unit)(object)__instance) && ((Object)__instance).name != "Hobro") { Main.StartControllingUnit(num2, __instance); } } } } [HarmonyPatch(typeof(Alien), "Start")] public static class Alien_Start_Patch { public static void Postfix(Alien __instance) { if (Main.enabled && Main.IsControlledUnit((Unit)(object)__instance)) { int num = Main.currentUnit.IndexOf((Unit)(object)__instance); if (num != ((NetworkedUnit)__instance).playerNum) { Main.ReaffirmControl(num); } ((TestVanDammeAnim)__instance).SpecialAmmo = 0; } } } [HarmonyPatch(typeof(GameModeController), "DoesPlayerNumDamage")] public static class GameModeController_DoesPlayerNumDamage_Patch { public static void Postfix(GameModeController __instance, ref int fromNum, ref int toNum, ref bool __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled || fromNum == toNum) { return; } if (toNum == Main.currentHeroNum) { if (fromNum < 4) { __result = true; } } else if (fromNum == Main.currentHeroNum) { if (toNum >= 0 && toNum < 4 && Main.currentlyEnemy[toNum]) { __result = true; } } else if (fromNum != Main.currentHeroNum) { if (toNum >= 0 && toNum < 4) { __result = false; } else { __result = false; } } } } [HarmonyPatch(typeof(Player), "HasFollowPosition")] public static class Player_HasFollowPosition_Patch { public static bool Prefix(Player __instance, ref bool __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if ((Object)(object)__instance != (Object)null && __instance.playerNum != Main.currentHeroNum && (!Main.settings.ghostControlledEnemiesAffectCamera || (Object)(object)__instance.character == (Object)null || ((BroforceObject)__instance.character).destroyed || !Main.IsControlledUnit((Unit)(object)__instance.character) || !((BroforceObject)__instance.character).IsAlive())) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "AlertNearbyMooks")] public static class TestVanDammeAnim_AlertNearbyMooks_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if (((NetworkedUnit)__instance).IsHero && ((NetworkedUnit)__instance).playerNum != Main.currentHeroNum) { return false; } return true; } } [HarmonyPatch(typeof(TestVanDammeAnim), "IsInStealthMode")] public static class TestVanDammeAnim_IsInStealthMode_Patch { public static bool Prefix(TestVanDammeAnim __instance, ref bool __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && ((NetworkedUnit)__instance).playerNum != Main.currentHeroNum) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Map), "DisturbWildLife")] public static class Map_DisturbWildLife_Patch { public static bool Prefix(Map __instance, ref int playerNum) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if (playerNum >= 0 && playerNum < 4 && playerNum != Main.currentHeroNum) { return false; } return true; } } [HarmonyPatch(typeof(Map), "BotherNearbyMooks")] public static class Map_BotherNearbyMooks_Patch { public static bool Prefix(Map __instance, ref int playerNum) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if (playerNum >= 0 && playerNum < 4 && playerNum != Main.currentHeroNum) { return false; } return true; } } [HarmonyPatch(typeof(Player), "Start")] public static class Player_Start_Patch { public static void Postfix(Player __instance) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return; } ScoreManager.SetupSprites(__instance.playerNum); if (__instance.playerNum == Main.currentHeroNum) { if (Main.settings.heroLives == 0) { __instance.Lives = 10; } else if (Main.anyAttemptingWin) { __instance.Lives = Main.settings.heroLives + Main.settings.extraLiveOnBossLevel + Main.settings.livesHandicap[__instance.playerNum]; } else { __instance.Lives = Main.settings.heroLives + Main.settings.livesHandicap[__instance.playerNum]; } } else if (Main.settings.ghostLives == 0) { __instance.Lives = 10; } else { __instance.Lives = Main.settings.ghostLives + Main.settings.livesHandicap[__instance.playerNum]; } } } [HarmonyPatch(typeof(HeroController), "FlashAvatar")] public static class HeroController_FlashAvatar_Patch { public static bool Prefix(ref int playerNum) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } return playerNum == Main.currentHeroNum; } } [HarmonyPatch(typeof(PlayerHUD), "FlashAvatar")] public static class PlayerHUD_FlashAvatar_Patch { public static bool Prefix(PlayerHUD __instance, int ___playerNum) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } return ___playerNum == Main.currentHeroNum; } } [HarmonyPatch(typeof(HeroController), "DropoutRPC")] public static class HeroController_DropoutRPC_Patch { public static void Prefix(ref int playerNum) { if (Main.enabled && Main.settings.competitiveModeEnabled && (Object)(object)Main.currentGhosts[playerNum] != (Object)null) { Object.Destroy((Object)(object)((Component)Main.currentGhosts[playerNum]).gameObject); Main.previousCharacter[playerNum] = null; Main.currentlyEnemy[playerNum] = false; if ((Object)(object)Main.currentUnit[playerNum] != (Object)null) { Main.controlledUnits.Remove(Main.currentUnit[playerNum]); } Main.currentGhosts[playerNum] = null; } } } [HarmonyPatch(typeof(TestVanDammeAnim), "CheckRescues")] public static class TestVanDammeAnim_CheckRescues_Patch { public static bool Prefix(TestVanDammeAnim __instance) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } return ((NetworkedUnit)__instance).playerNum == Main.currentHeroNum; } } [HarmonyPatch(typeof(HeroController), "IsAnotherPlayerNearby")] public static class HeroController_IsAnotherPlayerNearby_Patch { public static bool Prefix(HeroController __instance, ref bool __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Map), "GetNearbyMook")] public static class Map_GetNearbyMook_Patch { public static bool Prefix(Map __instance, ref float xRange, ref float yRange, ref float x, ref float y, ref int direction, ref bool canBeDead, ref Mook __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } __result = null; float num = Mathf.Max(xRange, yRange) + 1f; for (int num2 = Map.units.Count - 1; num2 >= 0; num2--) { Unit val = Map.units[num2]; if (!((Object)(object)val == (Object)null) && (((NetworkedUnit)val).playerNum < 0 || Main.IsControlledUnit(val)) && (canBeDead || ((BroforceObject)val).health > 0)) { float num3 = ((BroforceObject)val).X - x; if (Tools.FastAbsWithinRange(num3, xRange) && Mathf.Sign(num3) == (float)direction) { float num4 = ((BroforceObject)val).Y - y; if (Tools.FastAbsWithinRange(num4, yRange)) { Mook component = ((Component)val).GetComponent<Mook>(); if ((Object)(object)component != (Object)null) { float num5 = Mathf.Abs(num3) + Mathf.Abs(num4); if (num5 < num) { num = num5; __result = component; } } } } } } return false; } } [HarmonyPatch(typeof(Map), "GetNearbyMookVertical")] public static class Map_GetNearbyMookVertical_Patch { public static bool Prefix(Map __instance, ref float xRange, ref float yRange, ref float x, ref float y, ref int direction, ref bool canBeDead, ref Mook __result) { if (!Main.enabled || !Main.settings.competitiveModeEnabled) { return true; } if (Map.units == null) { __result = null; return false; } float num = Mathf.Max(xRange, yRange) + 1f; for (int num2 = Map.units.Count - 1; num2 >= 0; num2--) { Unit val = Map.units[num2]; if (!((Object)(object)val == (Object)null) && ((NetworkedUnit)val).playerNum < 0 && (canBeDead || ((BroforceObject)val).health > 0)) { float num3 = ((BroforceObject)val).X - x; if (Tools.FastAbsWithinRange(num3, xRange)) { float num4 = ((BroforceObject)val).Y - y; if (Tools.FastAbsWithinRange(num4, yRange) && Mathf.Sign(num4) == (float)direction) { Mook component = ((Component)val).GetComponent<Mook>(); if ((Object)(object)component != (Object)null) { float num5 = Mathf.Abs(num3) + Mathf.Abs(num4); if (num5 < num) { num = num5; __result = component; } } } } } } return false; } } [HarmonyPatch(typeof(HeroController), "MayIRescueThisBro")] public static class HeroController_MayIRescueThisBro_Patch { public static bool Prefix(HeroController __instance, ref