using System.Collections; using System.Collections.Generic; using UnityEngine; using InfallibleCode; using UnityEngine.Events; public class DoorTriggerAction : MonoBehaviour { public DoorBehaviour door; public bool LockDoor; public bool UnlockDoor; public bool OpenDoor; public bool CloseDoor; [Range(0, -90)] [Tooltip("The lerp angle of the door")] public float DoorOpenAngle = 0f; [Header("Door Speed")] [Range(0, 0.9f)] public float DoorSpeed = 0.5f; private bool ActionPerformed; private void Awake() { door._doorLerpOpenAngle = DoorOpenAngle; } private void OnTriggerEnter(Collider col) { if(col.gameObject.tag == "Player" && !ActionPerformed) { DoDoorAction(); } } public void DoDoorAction() { if (LockDoor) { door.LockDoor(); ActionPerformed = true; } else if (UnlockDoor) { door.UnlockDoor(); ActionPerformed = true; } if (OpenDoor) { door.OpenDoor(DoorSpeed); door.UnlockDoor(); ActionPerformed = true; } else if (CloseDoor) { door.CloseDoor(DoorSpeed); ActionPerformed = true; } } public void ActionPerformedReset() { ActionPerformed = false; } }