Files
Cielonos/Assets/Scripts/MainGame/Characters/Player/PlayerInteractionSubcontroller.cs
SoulliesOfficial 50ee502684 完善
2026-02-13 09:22:11 -05:00

31 lines
859 B
C#

using System;
using System.Collections.Generic;
using Cielonos.Core.Interaction;
using UnityEngine;
namespace Cielonos.MainGame.Characters
{
public class PlayerInteractionSubcontroller : SubcontrollerBase<Player>
{
public Player player => owner;
public List<InteractionChoice> currentChoices = new List<InteractionChoice>();
public override void Initialize()
{
base.Initialize();
player.operationSc.OnInteract += () => ExecuteChoice(0);
}
public void ExecuteChoice(int index = 0)
{
if (index < 0 || index >= currentChoices.Count)
{
Debug.LogWarning("Invalid interaction choice index.");
return;
}
var choice = currentChoices[index];
choice.action?.Invoke();
}
}
}