Package com.csse3200.game.entities
Class EntityService
java.lang.Object
com.csse3200.game.entities.EntityService
Provides a global access point for entities to register themselves. This allows for iterating
over entities to perform updates each loop. All game entities should be registered here.
Avoid adding additional state here! Global access is often the easy but incorrect answer to sharing data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Dispose all entities.com.badlogic.gdx.utils.Array<Entity>
Returns Array of entities of all entities in gameint
getSize()
Get number of entities registeredvoid
static boolean
void
void
void
Register a new entity with the entity service.void
void
unregister
(Entity entity) Unregister an entity with the entity service.void
update()
Update all registered entities.
-
Constructor Details
-
EntityService
public EntityService()
-
-
Method Details
-
pauseCheck
public static boolean pauseCheck() -
register
Register a new entity with the entity service. The entity will be created and start updating.- Parameters:
entity
- new entity.
-
unregister
Unregister an entity with the entity service. The entity will be removed and stop updating.- Parameters:
entity
- entity to be removed.
-
update
public void update()Update all registered entities. Should only be called from the main game loop. -
pauseAndResume
public void pauseAndResume() -
pauseGame
public void pauseGame() -
pauseGame2
public void pauseGame2() -
unpauseGame
public void unpauseGame() -
dispose
public void dispose()Dispose all entities. -
getSize
public int getSize()Get number of entities registered- Returns:
- number of entities
-
getEntities
Returns Array of entities of all entities in game- Returns:
- Array of entities in game
-