using UnityEngine; public class RoomDoor : Interactable { public RoomDoor linkedDoor; public bool requiresInteraction; // Do we need to press a button to enter? TeleportHandler teleportHandler; // not required and only plays if interaction is required public Animation doorAnimator; public AnimationClip openDoor; public AnimationClip closeDoor; private void Start() { teleportHandler = GameObject.FindWithTag("Player").GetComponent(); } public override void Interact() { if (requiresInteraction) { if (doorAnimator && openDoor) { doorAnimator.clip = openDoor; doorAnimator.Play(); } teleportHandler.EnterRoom(this); } } public void CloseDoor() { if (doorAnimator && closeDoor) { doorAnimator.clip = closeDoor; doorAnimator.Play(); } } public override void MoveInsideRange() { if (!requiresInteraction) { teleportHandler.EnterRoom(this); } } public override void MoveOutsideRange() { // Do nothing } }