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,35 @@
using GameCore.ECS;
using GameCore.Events;
using GameCore.Logic.Interfaces;
using GameCore.Math;
using GameCore.Physics;
namespace GameCore.Logic;
public class SpawnEntityAction(string archetypeId, string spawnerWorldId) : ITriggerAction
{
public void Execute(World world)
{
var spawnerEntity = world.FindEntityByWorldId(spawnerWorldId);
if (spawnerEntity == null)
{
world.Logger.Warn($"[SpawnEntityAction] Could not find spawner with WorldId: {spawnerWorldId}");
return;
}
var position = world.GetComponent<PositionComponent>(spawnerEntity.Value);
if (position == null)
{
world.Logger.Warn($"[SpawnEntityAction] Spawner '{spawnerWorldId}' does not have a PositionComponent.");
return;
}
world.PublishEvent(new SpawnEntityEvent(
archetypeId,
position.Position,
Vector3.Zero,
default));
world.Logger.Info($"[SpawnEntityAction] Spawning '{archetypeId}' at '{spawnerWorldId}'.");
}
}