Files
Echo/Assets/_Project/Scripts/LLM Manager/Commands/DoorCommandReceiver.cs
T
2026-07-08 20:42:51 +08:00

47 lines
1.2 KiB
C#

using Interaction;
using UnityEngine;
namespace LLM.Commands
{
public class DoorCommandReceiver : LLMCommandReceiverBase
{
[SerializeField] private DoorController door;
private void Awake()
{
if (door == null)
{
door = GetComponentInParent<DoorController>();
}
}
public override bool TryExecute(LLMCommand command)
{
if (command == null) return false;
if (!string.Equals(command.type, "Door", System.StringComparison.OrdinalIgnoreCase)) return false;
if (door == null)
{
door = GetComponentInParent<DoorController>();
if (door == null) return false;
}
if (string.Equals(command.action, "Open", System.StringComparison.OrdinalIgnoreCase))
{
door.OpenDoor();
return true;
}
if (string.Equals(command.action, "Close", System.StringComparison.OrdinalIgnoreCase))
{
door.CloseDoor();
return true;
}
door.ToggleDoor();
return true;
}
}
}