Add button interaction system with event publishing and requirements handling

This commit is contained in:
2025-10-30 02:21:33 +01:00
parent 86afb57809
commit 3fcb31d92f
11 changed files with 240 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
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}");
}
}
}