46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Core.TaskSystem;
|
|
using UnityEngine;
|
|
|
|
namespace LLM.Commands
|
|
{
|
|
public class TaskCommandReceiver : LLMCommandReceiverBase
|
|
{
|
|
[SerializeField] private TaskService taskService;
|
|
|
|
private void Awake()
|
|
{
|
|
if (taskService == null) taskService = TaskService.Instance;
|
|
}
|
|
|
|
public override bool TryExecute(LLMCommand command)
|
|
{
|
|
if (command == null) return false;
|
|
if (!string.Equals(command.type, "Task", System.StringComparison.OrdinalIgnoreCase)) return false;
|
|
|
|
TaskService service = taskService != null ? taskService : TaskService.Instance;
|
|
if (service == null) return false;
|
|
|
|
string taskId = string.IsNullOrWhiteSpace(command.payload) ? command.targetId : command.payload;
|
|
if (string.IsNullOrWhiteSpace(taskId)) return false;
|
|
|
|
if (string.Equals(command.action, "Remove", System.StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return service.RemoveTask(taskId);
|
|
}
|
|
|
|
if (string.Equals(command.action, "Todo", System.StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return service.SetTaskStatus(taskId, TaskStatus.Todo);
|
|
}
|
|
|
|
if (string.Equals(command.action, "Expired", System.StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return service.SetTaskStatus(taskId, TaskStatus.Expired);
|
|
}
|
|
|
|
return service.SetTaskStatus(taskId, TaskStatus.Completed);
|
|
}
|
|
}
|
|
}
|
|
|