Simple interactable rework

This commit is contained in:
Michal Pikulski
2025-10-31 13:50:08 +01:00
parent 095f21908b
commit 917230e10a
15 changed files with 1897 additions and 103 deletions

View File

@@ -1,37 +1,21 @@
using UnityEngine;
using System;
using Input;
using Interactions;
/// <summary>
/// MonoBehaviour that immediately completes an interaction when started.
/// </summary>
public class OneClickInteraction : MonoBehaviour
namespace Interactions
{
private Interactable interactable;
void Awake()
/// <summary>
/// Interactable that immediately completes when the character arrives at the interaction point.
/// Useful for simple trigger interactions that don't require additional logic.
/// </summary>
public class OneClickInteraction : InteractableBase
{
interactable = GetComponent<Interactable>();
if (interactable != null)
/// <summary>
/// Override: Immediately completes the interaction with success when character arrives.
/// </summary>
protected override void OnCharacterArrived()
{
interactable.interactionStarted.AddListener(OnInteractionStarted);
}
}
void OnDestroy()
{
if (interactable != null)
{
interactable.interactionStarted.RemoveListener(OnInteractionStarted);
}
}
private void OnInteractionStarted(PlayerTouchController playerRef, FollowerController followerRef)
{
if (interactable != null)
{
interactable.BroadcastInteractionComplete(true);
CompleteInteraction(true);
}
}
}