public final class GameWorld extends com.almasb.ents.EntityWorld implements UpdateEventListener
| Type | Property and Description |
|---|---|
javafx.beans.property.ObjectProperty<GameDifficulty> |
gameDifficulty |
javafx.beans.property.ObjectProperty<com.almasb.ents.Entity> |
selectedEntity |
| Modifier | Constructor and Description |
|---|---|
protected |
GameWorld() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventTrigger(<any> trigger)
Add event trigger to the world.
|
javafx.beans.property.ObjectProperty<GameDifficulty> |
gameDifficultyProperty() |
Optional<com.almasb.ents.Entity> |
getClosestEntity(com.almasb.ents.Entity entity,
Predicate<com.almasb.ents.Entity> filter)
Returns the closest entity to the given entity with given
filter.
|
void |
getCollidingEntities(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
com.almasb.ents.Entity entity)
GC-friendly version of
getCollidingEntities(Entity). |
List<com.almasb.ents.Entity> |
getCollidingEntities(com.almasb.ents.Entity entity)
Returns a list of entities
which colliding with given entity.
|
void |
getEntitiesByLayer(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
RenderLayer layer)
GC-friendly version of
getEntitiesByLayer(RenderLayer). |
List<com.almasb.ents.Entity> |
getEntitiesByLayer(RenderLayer layer)
Returns a list of entities which have the given render layer index.
|
void |
getEntitiesByType(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
Enum<?>... types)
GC-friendly version of
getEntitiesByType(Enum[]). |
List<com.almasb.ents.Entity> |
getEntitiesByType(Enum<?>... types)
This query only works on entities with TypeComponent.
|
void |
getEntitiesFiltered(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
Predicate<com.almasb.ents.Entity> predicate)
GC-friendly version of
getEntitiesFiltered(Predicate). |
List<com.almasb.ents.Entity> |
getEntitiesFiltered(Predicate<com.almasb.ents.Entity> predicate)
Returns a list of entities which are filtered by
given predicate.
|
void |
getEntitiesInRange(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
double minX,
double minY,
double maxX,
double maxY)
GC-friendly version of
getEntitiesInRange(Rectangle2D). |
List<com.almasb.ents.Entity> |
getEntitiesInRange(javafx.geometry.Rectangle2D selection)
Returns a list of entities
which are partially or entirely
in the specified rectangular selection.
|
Optional<com.almasb.ents.Entity> |
getEntityAt(javafx.geometry.Point2D position)
Returns an entity at given position.
|
Optional<com.almasb.ents.Entity> |
getEntityByID(String name,
int id)
Returns an entity whose IDComponent matches given name and id.
|
GameDifficulty |
getGameDifficulty() |
Optional<com.almasb.ents.Entity> |
getSelectedEntity()
Returns last selected (clicked on by mouse) entity.
|
void |
onUpdateEvent(UpdateEvent event)
Called on each update tick.
|
void |
removeEventTrigger(<any> trigger)
Remove event trigger from the world.
|
void |
reset() |
javafx.beans.property.ObjectProperty<com.almasb.ents.Entity> |
selectedEntityProperty() |
void |
setLevel(Level level)
Set level to given.
|
public javafx.beans.property.ObjectProperty<GameDifficulty> gameDifficultyProperty
getGameDifficulty()public javafx.beans.property.ObjectProperty<com.almasb.ents.Entity> selectedEntityProperty
getSelectedEntity()public GameDifficulty getGameDifficulty()
public javafx.beans.property.ObjectProperty<GameDifficulty> gameDifficultyProperty()
getGameDifficulty()public void onUpdateEvent(UpdateEvent event)
UpdateEventListeneronUpdateEvent in interface UpdateEventListenerevent - the event datapublic void reset()
reset in class com.almasb.ents.EntityWorldpublic void addEventTrigger(<any> trigger)
trigger - the event triggerpublic void removeEventTrigger(<any> trigger)
trigger - the event triggerpublic Optional<com.almasb.ents.Entity> getSelectedEntity()
public javafx.beans.property.ObjectProperty<com.almasb.ents.Entity> selectedEntityProperty()
getSelectedEntity()public void setLevel(Level level)
level - the levelpublic List<com.almasb.ents.Entity> getEntitiesFiltered(Predicate<com.almasb.ents.Entity> predicate)
predicate - filterpublic void getEntitiesFiltered(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
Predicate<com.almasb.ents.Entity> predicate)
getEntitiesFiltered(Predicate).result - the array to collect entitiespredicate - filterpublic List<com.almasb.ents.Entity> getEntitiesByType(Enum<?>... types)
types - entity typespublic void getEntitiesByType(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
Enum<?>... types)
getEntitiesByType(Enum[]).result - the array to collect entitiestypes - entity typespublic List<com.almasb.ents.Entity> getEntitiesInRange(javafx.geometry.Rectangle2D selection)
selection - Rectangle2D that describes the selection boxpublic void getEntitiesInRange(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
double minX,
double minY,
double maxX,
double maxY)
getEntitiesInRange(Rectangle2D).result - the array to collect entitiesminX - min xminY - min ymaxX - max xmaxY - max ypublic List<com.almasb.ents.Entity> getCollidingEntities(com.almasb.ents.Entity entity)
entity - the entitypublic void getCollidingEntities(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
com.almasb.ents.Entity entity)
getCollidingEntities(Entity).result - the array to collect entitiesentity - the entitypublic List<com.almasb.ents.Entity> getEntitiesByLayer(RenderLayer layer)
layer - render layerpublic void getEntitiesByLayer(com.almasb.gameutils.collection.Array<com.almasb.ents.Entity> result,
RenderLayer layer)
getEntitiesByLayer(RenderLayer).result - the array to collect entitieslayer - render layerpublic Optional<com.almasb.ents.Entity> getClosestEntity(com.almasb.ents.Entity entity, Predicate<com.almasb.ents.Entity> filter)
If there no entities satisfying the requirement, Optional.empty()
is returned.
Warning: object allocation.
entity - selected entityfilter - requirementspublic Optional<com.almasb.ents.Entity> getEntityAt(javafx.geometry.Point2D position)
Returns Optional.empty() if no entity was found at
given position.
This query only works on entities with PositionComponent.
position - point in the worldpublic Optional<com.almasb.ents.Entity> getEntityByID(String name, int id)
Returns Optional.empty() if no entity was found with such combination.
This query only works on entities with IDComponent.
name - entity nameid - entity idOptional.empty()Copyright © 2016. All rights reserved.