chore: Project Restructuring & Theatre
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using Unheimlich.Core.Interaction;
|
||||
using Unheimlich.Core.Utils;
|
||||
|
||||
namespace Unheimlich.World.Environment
|
||||
{
|
||||
public class DoorInteractable : InteractableBase
|
||||
{
|
||||
[Header("Door Settings")]
|
||||
public bool IsOpen = false;
|
||||
[SerializeField] private float _openAngle = 90f;
|
||||
[SerializeField] private float _animationDuration = 0.5f;
|
||||
[SerializeField] private LeanTweenType _easeType = LeanTweenType.easeInOutQuad;
|
||||
|
||||
private Quaternion _closedRotation;
|
||||
private Quaternion _openRotation;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
_closedRotation = transform.rotation;
|
||||
_openRotation = _closedRotation * Quaternion.Euler(0, _openAngle, 0);
|
||||
|
||||
InteractionText = IsOpen ? "Close" : "Open";
|
||||
}
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
ToggleDoor();
|
||||
}
|
||||
|
||||
public void ToggleDoor()
|
||||
{
|
||||
gameObject.CancelAllTweens();
|
||||
|
||||
if (!IsOpen)
|
||||
{
|
||||
TweenHelper.RotateLocal(gameObject, _openRotation.eulerAngles, _animationDuration, null, _easeType);
|
||||
IsOpen = true;
|
||||
InteractionText = "Close";
|
||||
}
|
||||
else
|
||||
{
|
||||
TweenHelper.RotateLocal(gameObject, _closedRotation.eulerAngles, _animationDuration, null, _easeType);
|
||||
IsOpen = false;
|
||||
InteractionText = "Open";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user