Files
2026-07-08 20:42:51 +08:00

47 lines
1.3 KiB
C#

using Interaction;
using UnityEngine;
namespace LLM.Commands
{
public class UnlockStateCommandReceiver : LLMCommandReceiverBase
{
[SerializeField] private InteractUnlockState unlockState;
private void Awake()
{
if (unlockState == null)
{
unlockState = GetComponentInParent<InteractUnlockState>();
}
}
public override bool TryExecute(LLMCommand command)
{
if (command == null) return false;
if (!string.Equals(command.type, "UnlockState", System.StringComparison.OrdinalIgnoreCase)) return false;
if (unlockState == null)
{
unlockState = GetComponentInParent<InteractUnlockState>();
if (unlockState == null) return false;
}
if (string.Equals(command.action, "Unlock", System.StringComparison.OrdinalIgnoreCase))
{
unlockState.SetUnlocked(true);
return true;
}
if (string.Equals(command.action, "Lock", System.StringComparison.OrdinalIgnoreCase))
{
unlockState.SetUnlocked(false);
return true;
}
unlockState.SetUnlocked(command.value);
return true;
}
}
}