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(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}'."); } }