31 lines
859 B
C#
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();
|
|
}
|
|
}
|
|
} |