Files
brick-framework/GameCore/Logic/UnlockDoorAction.cs

32 lines
998 B
C#

using GameCore.ECS;
using GameCore.Interaction;
using GameCore.Logic.Interfaces;
namespace GameCore.Logic;
public class UnlockDoorAction(string targetWorldId) : ITriggerAction
{
public void Execute(World world)
{
var doorEntity = world.FindEntityByWorldId(targetWorldId);
if (doorEntity == null)
{
world.Logger.Warn($"[UnlockDoorAction] Could not find entity with WorldId: {targetWorldId}");
return;
}
var door = world.GetComponent<DoorComponent>(doorEntity.Value);
if (door == null)
{
world.Logger.Warn($"[UnlockDoorAction] Entity '{targetWorldId}' does not have a DoorComponent.");
return;
}
if (door.CurrentState == DoorComponent.DoorState.Locked)
{
door.CurrentState = DoorComponent.DoorState.Closed;
door.Requirements.Clear();
world.Logger.Info($"[UnlockDoorAction] Unlocked door: {targetWorldId}");
}
}
}