public static bool Prefix(Vent __instance, PlayerControl NMEAPOJFNKA) { PlayerControl pc = NMEAPOJFNKA; if (!__instance.ExitVentAnim) { return(false); } var truePosition = PlayerControl.LocalPlayer.GetTruePosition(); Vector2 vector = pc.GetTruePosition() - truePosition; var magnitude = vector.magnitude; if (pc.AmOwner || magnitude < PlayerControl.LocalPlayer.myLight.LightRadius && !PhysicsHelpers.AnyNonTriggersBetween(truePosition, vector.normalized, magnitude, ShipAndObjectsMask)) { __instance.GetComponent <SpriteAnim>().Play(__instance.ExitVentAnim, 1f); } if (pc.AmOwner && Constants.Method_3()) //ShouldPlaySfx { SoundManager.Instance.StopSound(ShipStatus.Instance.VentEnterSound); SoundManager.Instance.PlaySound(ShipStatus.Instance.VentEnterSound, false, 1f).pitch = UnityEngine.Random.Range(0.8f, 1.2f); } return(false); }
public JackInTheBox(Vector2 p) { gameObject = new GameObject("JackInTheBox") { layer = 11 }; gameObject.AddSubmergedComponent(SubmergedCompatibility.Classes.ElevatorMover); Vector3 position = new Vector3(p.x, p.y, p.y / 1000f + 0.01f); position += (Vector3)PlayerControl.LocalPlayer.Collider.offset; // Add collider offset that DoMove moves the player up at a valid position // Create the marker gameObject.transform.position = position; boxRenderer = gameObject.AddComponent <SpriteRenderer>(); boxRenderer.sprite = getBoxAnimationSprite(0); // Create the vent var referenceVent = UnityEngine.Object.FindObjectOfType <Vent>(); vent = UnityEngine.Object.Instantiate <Vent>(referenceVent); vent.gameObject.AddSubmergedComponent(SubmergedCompatibility.Classes.ElevatorMover); vent.transform.position = gameObject.transform.position; vent.Left = null; vent.Right = null; vent.Center = null; vent.EnterVentAnim = null; vent.ExitVentAnim = null; vent.Offset = new Vector3(0f, 0.25f, 0f); vent.GetComponent <PowerTools.SpriteAnim>()?.Stop(); vent.Id = ShipStatus.Instance.AllVents.Select(x => x.Id).Max() + 1; // Make sure we have a unique id var ventRenderer = vent.GetComponent <SpriteRenderer>(); ventRenderer.sprite = null; vent.myRend = ventRenderer; var allVentsList = ShipStatus.Instance.AllVents.ToList(); allVentsList.Add(vent); ShipStatus.Instance.AllVents = allVentsList.ToArray(); vent.gameObject.SetActive(false); vent.name = "JackInTheBoxVent_" + vent.Id; // Only render the box for the Trickster var playerIsTrickster = PlayerControl.LocalPlayer == Trickster.trickster; gameObject.SetActive(playerIsTrickster); AllJackInTheBoxes.Add(this); }
/* There's a bug on Polus; the bottom of the vent in Admin (in the library) is right next to the bottom wall * of the room. This means that attempting to send the player there often ends up with them stuck in the wall, * unable to move. We need to instead use coordinates that put them in the middle of the vent instead. */ public static Vector3 GetCoordinatesToSendPlayerToVent(Vent vent) { Vector2 size = vent.GetComponent <BoxCollider2D>().size; Vector3 destination = vent.transform.position; destination.y += size.y / 2; return(destination); }
public JackInTheBox(Vector2 p) { gameObject = new GameObject("JackInTheBox"); Vector3 position = new Vector3(p.x, p.y, PlayerControl.LocalPlayer.transform.position.z + 1f); position += (Vector3)PlayerControl.LocalPlayer.Collider.offset; // add Player Collider offset as this gets subtracted again on Vent.DoMove // Create the marker gameObject.transform.position = position; var boxRenderer = gameObject.AddComponent <SpriteRenderer>(); boxRenderer.sprite = getJackInTheBoxSprite(); // Create the vent var referenceVent = UnityEngine.Object.FindObjectOfType <Vent>(); vent = UnityEngine.Object.Instantiate <Vent>(referenceVent); vent.transform.position = gameObject.transform.position; vent.Left = null; vent.Right = null; vent.Center = null; vent.EnterVentAnim = null; vent.ExitVentAnim = null; vent.GetComponent <PowerTools.SpriteAnim>()?.Stop(); vent.Id = ShipStatus.Instance.GJHKPDGJHJN.Select(x => x.Id).Max() + 1; // Make sure we have a unique id var ventRenderer = vent.GetComponent <SpriteRenderer>(); ventRenderer.sprite = getJackInTheBoxSprite(); vent.KJAENOGGEOK = ventRenderer; var allVentsList = ShipStatus.Instance.GJHKPDGJHJN.ToList(); allVentsList.Add(vent); ShipStatus.Instance.GJHKPDGJHJN = allVentsList.ToArray(); vent.gameObject.SetActive(false); vent.name = "JackInTheBoxVent_" + vent.Id; // Only render the box for the Trickster var playerIsTrickster = PlayerControl.LocalPlayer == Trickster.trickster; gameObject.SetActive(playerIsTrickster); AllJackInTheBoxes.Add(this); }
public static void sealVent(int ventId) { Vent vent = ShipStatus.Instance.AllVents.FirstOrDefault((x) => x != null && x.Id == ventId); if (vent == null) { return; } SecurityGuard.remainingScrews -= SecurityGuard.ventPrice; if (PlayerControl.LocalPlayer == SecurityGuard.securityGuard) { PowerTools.SpriteAnim animator = vent.GetComponent <PowerTools.SpriteAnim>(); animator?.Stop(); vent.EnterVentAnim = vent.ExitVentAnim = null; vent.myRend.sprite = animator == null?SecurityGuard.getStaticVentSealedSprite() : SecurityGuard.getAnimatedVentSealedSprite(); vent.myRend.color = new Color(1f, 1f, 1f, 0.5f); vent.name = "FutureSealedVent_" + vent.name; } MapOptions.ventsToSeal.Add(vent); }