2026-02-13 09:22:11 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using SickscoreGames.HUDNavigationSystem;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cielonos.Core.Interaction
|
|
|
|
|
|
{
|
2026-05-10 11:47:55 -04:00
|
|
|
|
public partial class InteractableObjectBase : SerializedMonoBehaviour
|
2026-02-13 09:22:11 -05:00
|
|
|
|
{
|
|
|
|
|
|
public InteractionTrigger interactionTrigger;
|
|
|
|
|
|
public HUDNavigationElement navigation;
|
|
|
|
|
|
|
|
|
|
|
|
[HideInInspector]
|
|
|
|
|
|
public List<InteractionChoice> choices;
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
choices = new List<InteractionChoice>();
|
|
|
|
|
|
InitializeChoices();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class InteractableObjectBase
|
|
|
|
|
|
{
|
|
|
|
|
|
protected virtual void InitializeChoices()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Override in derived classes to set up interaction choices
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void EnterTriggerAction()
|
|
|
|
|
|
{
|
|
|
|
|
|
navigation.showIndicator = true;
|
|
|
|
|
|
navigation.useIndicatorDistanceText = true;
|
|
|
|
|
|
navigation.indicatorOnscreenDistanceTextFormat = "[E]-Interact";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void ExitTriggerAction()
|
|
|
|
|
|
{
|
|
|
|
|
|
navigation.showIndicator = false;
|
|
|
|
|
|
}
|
2026-05-10 11:47:55 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 运行时启用或禁用此可交互对象。
|
|
|
|
|
|
/// 禁用后:触发区碰撞体关闭,HUD 指示器隐藏,choices 不再注册给玩家。
|
|
|
|
|
|
/// 用于单次使用节点(MechanicalTable、MedicalStation)使用完毕后的 Exhausted 状态。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetInteractable(bool enabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
interactionTrigger.GetComponent<Collider>().enabled = enabled;
|
|
|
|
|
|
navigation.showIndicator = enabled && navigation.showIndicator;
|
|
|
|
|
|
}
|
2026-02-13 09:22:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
public partial class InteractableObjectBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private void Reset()
|
|
|
|
|
|
{
|
|
|
|
|
|
Setup();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Button("Setup")]
|
|
|
|
|
|
private void Setup()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (interactionTrigger == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
interactionTrigger = GetComponentInChildren<InteractionTrigger>();
|
|
|
|
|
|
interactionTrigger.interactableObject = this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (navigation == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
navigation = GetComponentInChildren<HUDNavigationElement>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
public class InteractionChoice
|
|
|
|
|
|
{
|
|
|
|
|
|
public string choiceName;
|
|
|
|
|
|
public Action action;
|
|
|
|
|
|
|
|
|
|
|
|
public InteractionChoice(string name, Action action)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.choiceName = name;
|
|
|
|
|
|
this.action = action;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|