31 lines
984 B
C#
31 lines
984 B
C#
|
|
using Core.NarrationSystem;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace LLM.Commands
|
||
|
|
{
|
||
|
|
public class NarrationCommandReceiver : LLMCommandReceiverBase
|
||
|
|
{
|
||
|
|
[SerializeField] private NarrationSystem narrationSystem;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
if (narrationSystem == null) narrationSystem = NarrationSystem.Instance;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override bool TryExecute(LLMCommand command)
|
||
|
|
{
|
||
|
|
if (command == null) return false;
|
||
|
|
if (!string.Equals(command.type, "Narration", System.StringComparison.OrdinalIgnoreCase)) return false;
|
||
|
|
|
||
|
|
NarrationSystem system = narrationSystem != null ? narrationSystem : NarrationSystem.Instance;
|
||
|
|
if (system == null) return false;
|
||
|
|
|
||
|
|
string sequenceId = string.IsNullOrWhiteSpace(command.payload) ? command.action : command.payload;
|
||
|
|
if (string.IsNullOrWhiteSpace(sequenceId)) return false;
|
||
|
|
|
||
|
|
return system.PlayById(sequenceId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|