Initial Unity project commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user