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.Get the end day screen entity.com.badlogic.gdx.utils.Array
<Entity> Get the moral screen entity.Get the moral system entity.void
Register a new entity with the entity service.void
registerEndDay
(Entity endDayScreen) Register the end day screen entity.void
registerMoral
(Entity moralScreen) Register the moral screen entity.void
registerMoralSystem
(Entity moralSystem) Register the moral system entity.void
unregister
(Entity entity) Unregister an entity with the entity service.void
Unregister the end day screen entity.void
Unregister the moral screen entity.void
Unregister the moral system entity.void
update()
Update all registered entities.
-
Constructor Details
-
EntityService
public EntityService() -
EntityService
-
-
Method Details
-
getEntities
-
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.
-
getEvents
-
update
public void update()Update all registered entities. Should only be called from the main game loop. -
dispose
public void dispose()Dispose all entities. -
getMoralScreen
Get the moral screen entity.- Returns:
- the moral screen entity
-
getMoralSystem
Get the moral system entity.- Returns:
- the moral system entity
-
registerMoral
Register the moral screen entity.- Parameters:
moralScreen
- the moral screen entity
-
unregisterMoral
public void unregisterMoral()Unregister the moral screen entity. -
registerMoralSystem
Register the moral system entity.- Parameters:
moralSystem
- the moral system entity
-
unregisterMoralSystem
public void unregisterMoralSystem()Unregister the moral system entity. -
registerEndDay
Register the end day screen entity.- Parameters:
endDayScreen
- the end day screen entity
-
unregisterEndDay
public void unregisterEndDay()Unregister the end day screen entity. -
getEndDayScreen
Get the end day screen entity.- Returns:
-