update tùm lum tùm la
This commit is contained in:
37
Assets/Scripts/Interactables/BaseInteractable.cs
Normal file
37
Assets/Scripts/Interactables/BaseInteractable.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public abstract class BaseInteractable : MonoBehaviour, IInteractable
|
||||
{
|
||||
[SerializeField] protected ObjectInteraction interactionData;
|
||||
|
||||
private float lastInteractTime;
|
||||
|
||||
public virtual string InteractionPrompt => interactionData != null ? interactionData.promptText : "Interact";
|
||||
|
||||
public virtual void OnInteract(PlayerStateMachine player)
|
||||
{
|
||||
if (Time.time < lastInteractTime + (interactionData != null ? interactionData.interactionCooldown : 0f))
|
||||
return;
|
||||
|
||||
lastInteractTime = Time.time;
|
||||
|
||||
// Play sound if assigned
|
||||
if (interactionData != null && interactionData.interactionSound != null)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(interactionData.interactionSound, transform.position);
|
||||
}
|
||||
|
||||
// Spawn VFX if assigned
|
||||
if (interactionData != null && interactionData.interactionVFX != null)
|
||||
{
|
||||
Instantiate(interactionData.interactionVFX, transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
PerformInteraction(player);
|
||||
}
|
||||
|
||||
protected abstract void PerformInteraction(PlayerStateMachine player);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user