Files
Echo/Assets/_Project/Scripts/LLM Manager/Commands/UnlockStateCommandReceiver.cs
T

47 lines
1.3 KiB
C#
Raw Normal View History

2026-07-08 19:53:15 +08:00
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;
}
}
}