file: EntityFactory.aus

class: EntityFactory

[43:7] extends: FxObj

Wraps FXGL's EntityFactory marker interface (com.almasb.fxgl.entity.EntityFactory). The upstream API is annotation-driven (@Spawns("name") on each spawner method); Aussom code cannot synthesize Java annotations, so the wrapper takes a different path:

  1. Construct via fxgl.entityFactory() — produces an empty AussomEntityFactory marker.
  2. Register per-name spawners with addSpawner(name, callback). The callback receives a SpawnData wrapper and must return an Entity wrapper.
  3. Attach to the running GameWorld with attachTo(world). The factory registers itself so GameWorld.create's entityFactories.isNotEmpty() check passes; AussomEntityFactoryHelper then installs each spawner directly into the GameWorld's spawner map. Spawners added after attachTo are installed immediately. Spawners added before are buffered and flushed during attachTo. Wiring: ef = fxgl.entityFactory(); ef.addSpawner("player", ::makePlayer); ef.addSpawner("enemy", ::makeEnemy); ef.attachTo(fxgl.getGameWorld()); ... fxgl.getGameWorld().spawn("player"); // calls makePlayer where makePlayer(spawnData) returns an Entity wrapper.

Members

Methods