CreationEngine

public final class CreationEngine

Class for unified and consistent GameEntity creation and removal.

By 'creation' we mean adding the entity to the game world:

  • adding the entity to all necessary engines

  • sending all necessary messages

  • starting entity's messaging coroutine

Parameters

physics

The PhysicsEngine that will be used with this CreationEngine.

fightEngine

The FightEngine that will be used with this CreationEngine.

Constructors

Link copied to clipboard
CreationEngine CreationEngine(PhysicsEngine physics, FightEngine fightEngine)

Creates a CreationEngine with no entities.

Functions

Link copied to clipboard
final Unit addAllToWorld(Set<GameEntity> entities, Function0<Unit> preStartAction)

Adds several entities to game world at once.

Link copied to clipboard
final Unit die(GameEntity entity)

Removes entity from game world. This method is basically an inverse of tryAddToWorld method.

Link copied to clipboard
final Unit removeAllAndJoin()

Removes all alive entities through stopping their coroutines. Waits for stop of each coroutine.

Link copied to clipboard
final Boolean tryAddToWorld(GameEntity entity)

Tries to add entity to the game world.