chore: Project Restructuring & Theatre
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff1685ec42b31a14085b5a638e78558a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
using UnityEngine;
|
||||
using Unheimlich.Core.Interaction;
|
||||
using Unheimlich.Features.Dialogue.UI;
|
||||
|
||||
namespace Unheimlich.Features.Items
|
||||
{
|
||||
/// <summary>
|
||||
/// Interactable item that can be picked up and examined closely by the player.
|
||||
/// Temporarily moves to inspection position and allows rotation via look input.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Collider), typeof(Rigidbody))]
|
||||
public class InspectableItem : InteractableBase
|
||||
{
|
||||
[Header("Inspection Settings")]
|
||||
[SerializeField] private float _inspectionDistance = 1f;
|
||||
[SerializeField] private float _rotationSpeed = 100f;
|
||||
|
||||
[Header("Animation Settings")]
|
||||
[SerializeField] private bool _blockInteractionDuringAnimation = true;
|
||||
|
||||
private Vector3 _originalPosition;
|
||||
private Quaternion _originalRotation;
|
||||
private Transform _originalParent;
|
||||
private Rigidbody _rigidbody;
|
||||
private bool _isAnimationPlaying = false;
|
||||
private ObjectDescriptionTrigger _objectDescriptionTrigger;
|
||||
private LevitatingObject _levitatingObject;
|
||||
|
||||
public bool IsAnimationPlaying => _isAnimationPlaying;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
_rigidbody.isKinematic = true;
|
||||
|
||||
_originalPosition = transform.position;
|
||||
_originalRotation = transform.rotation;
|
||||
_originalParent = transform.parent;
|
||||
|
||||
_objectDescriptionTrigger = GetComponent<ObjectDescriptionTrigger>();
|
||||
_levitatingObject = GetComponent<LevitatingObject>();
|
||||
}
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
if (_blockInteractionDuringAnimation)
|
||||
{
|
||||
if (_isAnimationPlaying)
|
||||
return;
|
||||
|
||||
if (_objectDescriptionTrigger != null &&
|
||||
_objectDescriptionTrigger.IsInMergeOnceMode &&
|
||||
_objectDescriptionTrigger.IsAnimationActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInspectionHandler.Instance != null)
|
||||
PlayerInspectionHandler.Instance.ToggleInspection(this);
|
||||
}
|
||||
|
||||
public void SetAnimationState(bool isPlaying)
|
||||
{
|
||||
_isAnimationPlaying = isPlaying;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepares the item for inspection by parenting it to the hold point and making it kinematic.
|
||||
/// </summary>
|
||||
public void PrepareForInspection(Transform holdPoint)
|
||||
{
|
||||
_originalPosition = transform.position;
|
||||
_originalRotation = transform.rotation;
|
||||
_originalParent = transform.parent;
|
||||
|
||||
_rigidbody.isKinematic = true;
|
||||
transform.SetParent(holdPoint);
|
||||
transform.localPosition = Vector3.forward * _inspectionDistance;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
|
||||
if (_levitatingObject != null)
|
||||
{
|
||||
_levitatingObject.UpdateBasePosition();
|
||||
}
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
transform.SetParent(_originalParent);
|
||||
transform.position = _originalPosition;
|
||||
transform.rotation = _originalRotation;
|
||||
|
||||
_rigidbody.isKinematic = true;
|
||||
|
||||
if (_levitatingObject != null)
|
||||
{
|
||||
_levitatingObject.UpdateBasePosition();
|
||||
}
|
||||
}
|
||||
|
||||
public float RotationSpeed => _rotationSpeed;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
LeanTween.cancel(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd19509bd29a28648a08eaf7f6146ef1
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unheimlich.Features.Items
|
||||
{
|
||||
public class LevitatingObject : MonoBehaviour
|
||||
{
|
||||
[Header("Levitation Settings")]
|
||||
[SerializeField] private float _levitationHeight = 0.5f;
|
||||
[SerializeField] private float _levitationSpeed = 1f;
|
||||
|
||||
[Header("Rotation Settings")]
|
||||
[SerializeField] private float _rotationSpeed = 30f;
|
||||
[SerializeField] private Vector3 _rotationAxis = Vector3.up;
|
||||
|
||||
private Vector3 _startLocalPosition;
|
||||
private float _timeOffset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_startLocalPosition = transform.localPosition;
|
||||
_timeOffset = Random.Range(0f, Mathf.PI * 2f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float yOffset = Mathf.Sin((Time.time + _timeOffset) * _levitationSpeed) * _levitationHeight;
|
||||
transform.localPosition = _startLocalPosition + new Vector3(0f, yOffset, 0f);
|
||||
|
||||
transform.Rotate(_rotationAxis.normalized, _rotationSpeed * Time.deltaTime, Space.World);
|
||||
}
|
||||
|
||||
public void UpdateBasePosition()
|
||||
{
|
||||
_startLocalPosition = transform.localPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 899101746b780fa4ca1a66d0af13173c
|
||||
Reference in New Issue
Block a user