using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BITKit { public class PhysicsDoor : MonoBehaviour, IAction { public enum State { Close, Open, HalfOpen, Locked, } public Transform root; public Vector3 openEuler; public Vector3 closeEuler; public State state; void Start() { Set(); } public void Execute() { switch (state) { case State.Open: state = State.Close; Set(); break; case State.Close: state = State.Open; Set(); break; } } void Set(bool isClosed) { if (isClosed) { root.localEulerAngles = closeEuler; } else { root.localEulerAngles = openEuler; } } void Set() { var isClosed = state switch { State.Locked => true, State.Close => true, State.Open => false, _ => true }; Set(isClosed); } } }