using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; namespace LLM.Commands { public class UnityEventCommandReceiver : LLMCommandReceiverBase { [Serializable] private class ActionBinding { public string action; public UnityEvent onExecute = new UnityEvent(); } [SerializeField] private List bindings = new List(); [SerializeField] private bool debugLogs = true; public override bool TryExecute(LLMCommand command) { if (command == null) return false; if (!string.Equals(command.type, "Event", StringComparison.OrdinalIgnoreCase)) return false; if (string.IsNullOrWhiteSpace(command.action)) return false; for (int i = 0; i < bindings.Count; i++) { var b = bindings[i]; if (b == null) continue; if (!string.Equals(b.action, command.action, StringComparison.OrdinalIgnoreCase)) continue; b.onExecute?.Invoke(); if (debugLogs) Debug.Log($"[UnityEventCommandReceiver] Executed action='{command.action}' targetId='{TargetId}'", this); return true; } return false; } } }