Interface WorldManager
-
- All Known Subinterfaces:
ServerWorldManager
public interface WorldManager
WorldManager represents the game world. Composite entities are the units populating the game world, as the name suggests they are composites of several entities and also have own properties representing it to the outside.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
WorldManager.CollisionDetectionListener
Listener to operate on detected collisions between two composite entities on entity level.static class
WorldManager.PhysicalCompositeEntitiesPredicate
Predicate for area based findBy() methods to ignore non-physical composite entities
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends AbstractCompositeEntity>
Tconvert(AbstractCompositeEntity compositeEntity, Class<T> target)
Converts a composite entity to another type<T extends AbstractCompositeEntity>
Tcopy(AbstractCompositeEntity compositeEntity, boolean copyEntities)
Copies a composite entity<T extends AbstractCompositeEntity>
Tcreate(Class<T> clazz, CoordI2 position, CoordI2 dimension)
Creates a composite entity of type clazz.EntityManager
createEntityManager(AbstractCompositeEntity compositeEntity)
Creates an entity manager.void
dirty(AbstractCompositeEntity compositeEntity)
Sets dirty flag on a composite entity - it is important to set dirty flag on the server side after every change.void
executeAt(CoordI2 worldPos, Consumer<AbstractCompositeEntity> consumer)
Specialized and optimized alternative to #find*void
executeAt(CoordI2 worldPos, Consumer<AbstractCompositeEntity> consumer, Predicate<AbstractCompositeEntity> filter)
Specialized and optimized alternative to #find*boolean
existsAt(CoordI2 worldPos)
Specialized and optimized alternative to #find*boolean
existsAt(CoordI2 worldPos, Predicate<AbstractCompositeEntity> filter)
Specialized and optimized alternative to #find*List<AbstractCompositeEntity>
findAll()
Returns a view (shallow copy) of all entities in the game worldIterator<AbstractCompositeEntity>
findAllFast()
Returns an read-only iterator of all entities in the game worldList<AbstractCompositeEntity>
findBy(CoordI2 worldPos)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(CoordI2 worldPos, CoordI2 dimension)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(CoordI2 worldPos, CoordI2 dimension, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(CoordI2 worldPos, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(HasPositionAndDimension2 hasPositionAndDimension2)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(HasPositionAndDimension2 hasPositionAndDimension2, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(RectI2 rect)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(RectI2 rect, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteria<T extends AbstractCompositeEntity>
List<T>findBy(Class<T> clazz)
Find composite entities by certain criteriaList<AbstractCompositeEntity>
findBy(List<UUID> ids)
Find composite entities by certain criteriaAbstractCompositeEntity
findBy(UUID id)
Finds a composite entity by id<T extends AbstractCompositeEntity>
TfindBy(UUID id, Class<T> clazz)
Finds a composite entity by id, requires the composite to have a certain type (or a sub-class of it).List<AbstractCompositeEntity>
findBySceneTag(UUID sceneTag)
Find composite entities by certain criteria.Iterator<AbstractCompositeEntity>
findBySceneTagFast(UUID sceneTag)
Find composite entities by certain criteria See also SceneRegistryList<AbstractEntity>
findEntityLevelCollisions(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1)
Composite entities can overlap in the game world.List<AbstractCompositeEntity>
findShadowed()
Find composite entities by certain criteria Shadowed entities are already added to the world manager but are not spawned in the game world yet, for example a ship being still in lobbyIterator<AbstractCompositeEntity>
findShadowedFast()
Find composite entities by certain criteria Shadowed entities are already added to the world manager but are not spawned in the game world yet, for example a ship being still in lobbyboolean
hasEntityLevelCollision(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1)
Composite entities can overlap in the game world.void
move(AbstractCompositeEntity compositeEntity, CoordI2 position, CoordI2 dimension)
Moves a composite entity to a new spatial position position - It is VERY important to always use this method instead of setting the position property directly, because world manager holds indexes for faster spatial lookups.void
operateOnEntityLevelCollisions(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1, WorldManager.CollisionDetectionListener listener)
Composite entities can overlap in the game world.void
put(AbstractCompositeEntity compositeEntity)
Puts a composite entity to the world manager.void
put(AbstractCompositeEntity compositeEntity, Map<String,Object> properties)
Puts a composite entity to the world manager with given additional properties (usually coming from CompositeEntityDefinitionMessage) World manager distinguishes between new entities, local updates and external updates (e.g.void
registerInterceptor(WorldManagerInterceptor interceptor)
World manager interceptors are notified about changes in the game world.void
remove(AbstractCompositeEntity compositeEntity)
Removes a composite entity from the game worldvoid
remove(UUID id)
Removes a composite entity from the game worldvoid
reset()
Resets the game world to zerovoid
unregisterInterceptor(UUID uuid)
World manager interceptors are notified about changes in the game world.
-
-
-
Method Detail
-
reset
void reset()
Resets the game world to zero
-
create
<T extends AbstractCompositeEntity> T create(Class<T> clazz, CoordI2 position, CoordI2 dimension)
Creates a composite entity of type clazz. The usual process after creation is to set additional properties (this is the only case where you are allowed to set the position directly on a composite entity), then #put it to WorldManager
-
put
void put(AbstractCompositeEntity compositeEntity)
Puts a composite entity to the world manager. World manager distinguishes between new entities, local updates and external updates (e.g. from the game server) and handles them accordingly.
-
put
void put(AbstractCompositeEntity compositeEntity, Map<String,Object> properties)
Puts a composite entity to the world manager with given additional properties (usually coming from CompositeEntityDefinitionMessage) World manager distinguishes between new entities, local updates and external updates (e.g. from the game server) and handles them accordingly.
-
move
void move(AbstractCompositeEntity compositeEntity, CoordI2 position, CoordI2 dimension)
Moves a composite entity to a new spatial position position - It is VERY important to always use this method instead of setting the position property directly, because world manager holds indexes for faster spatial lookups.- Parameters:
position
- The new position (upper left corner)dimension
- You can optionally change the dimension of a composite entity. Just pass the existing dimension (#getDimension()) in case of no change.
-
remove
void remove(AbstractCompositeEntity compositeEntity)
Removes a composite entity from the game world
-
remove
void remove(UUID id)
Removes a composite entity from the game world
-
dirty
void dirty(AbstractCompositeEntity compositeEntity)
Sets dirty flag on a composite entity - it is important to set dirty flag on the server side after every change. Reason is the server only sends out incremental changes each turn to the clients.
-
copy
<T extends AbstractCompositeEntity> T copy(AbstractCompositeEntity compositeEntity, boolean copyEntities)
Copies a composite entity
-
convert
<T extends AbstractCompositeEntity> T convert(AbstractCompositeEntity compositeEntity, Class<T> target)
Converts a composite entity to another type
-
createEntityManager
EntityManager createEntityManager(AbstractCompositeEntity compositeEntity)
Creates an entity manager. This is usually handled by game core
-
findAll
List<AbstractCompositeEntity> findAll()
Returns a view (shallow copy) of all entities in the game world
-
findAllFast
Iterator<AbstractCompositeEntity> findAllFast()
Returns an read-only iterator of all entities in the game world
-
findBy
AbstractCompositeEntity findBy(UUID id)
Finds a composite entity by id
-
findBy
<T extends AbstractCompositeEntity> T findBy(UUID id, Class<T> clazz)
Finds a composite entity by id, requires the composite to have a certain type (or a sub-class of it). Returns null if the type does not match.
-
findBy
List<AbstractCompositeEntity> findBy(List<UUID> ids)
Find composite entities by certain criteria
-
findBy
List<AbstractCompositeEntity> findBy(RectI2 rect)
Find composite entities by certain criteria
-
findBy
List<AbstractCompositeEntity> findBy(RectI2 rect, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteria- Parameters:
filter
- Filter composites before returning a result. You might be interested of PhysicalCompositeEntitiesPredicate to filter out composites that are not physical, e.g. InfoCompositeEntity / Scripts
-
findBy
List<AbstractCompositeEntity> findBy(CoordI2 worldPos)
Find composite entities by certain criteria
-
findBy
List<AbstractCompositeEntity> findBy(CoordI2 worldPos, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteria- Parameters:
filter
- Filter composites before returning a result. You might be interested of PhysicalCompositeEntitiesPredicate to filter out composites that are not physical, e.g. InfoCompositeEntity / Scripts
-
findBy
List<AbstractCompositeEntity> findBy(HasPositionAndDimension2 hasPositionAndDimension2)
Find composite entities by certain criteria
-
findBy
List<AbstractCompositeEntity> findBy(HasPositionAndDimension2 hasPositionAndDimension2, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteria- Parameters:
filter
- Filter composites before returning a result. You might be interested of PhysicalCompositeEntitiesPredicate to filter out composites that are not physical, e.g. InfoCompositeEntity / Scripts
-
findBy
List<AbstractCompositeEntity> findBy(CoordI2 worldPos, CoordI2 dimension)
Find composite entities by certain criteria
-
findBy
List<AbstractCompositeEntity> findBy(CoordI2 worldPos, CoordI2 dimension, Predicate<AbstractCompositeEntity> filter)
Find composite entities by certain criteria- Parameters:
filter
- Filter composites before returning a result. You might be interested of PhysicalCompositeEntitiesPredicate to filter out composites that are not physical, e.g. InfoCompositeEntity / Scripts
-
findBy
<T extends AbstractCompositeEntity> List<T> findBy(Class<T> clazz)
Find composite entities by certain criteria
-
findBySceneTag
List<AbstractCompositeEntity> findBySceneTag(UUID sceneTag)
Find composite entities by certain criteria. See also SceneRegistry
-
findBySceneTagFast
Iterator<AbstractCompositeEntity> findBySceneTagFast(UUID sceneTag)
Find composite entities by certain criteria See also SceneRegistry
-
findShadowed
List<AbstractCompositeEntity> findShadowed()
Find composite entities by certain criteria Shadowed entities are already added to the world manager but are not spawned in the game world yet, for example a ship being still in lobby
-
findShadowedFast
Iterator<AbstractCompositeEntity> findShadowedFast()
Find composite entities by certain criteria Shadowed entities are already added to the world manager but are not spawned in the game world yet, for example a ship being still in lobby
-
existsAt
boolean existsAt(CoordI2 worldPos)
Specialized and optimized alternative to #find*
-
existsAt
boolean existsAt(CoordI2 worldPos, Predicate<AbstractCompositeEntity> filter)
Specialized and optimized alternative to #find*
-
executeAt
void executeAt(CoordI2 worldPos, Consumer<AbstractCompositeEntity> consumer)
Specialized and optimized alternative to #find*
-
executeAt
void executeAt(CoordI2 worldPos, Consumer<AbstractCompositeEntity> consumer, Predicate<AbstractCompositeEntity> filter)
Specialized and optimized alternative to #find*
-
hasEntityLevelCollision
boolean hasEntityLevelCollision(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1)
Composite entities can overlap in the game world. This method checks whether there are collisions (composite entities are usually not filled with entities at all positions!)
-
findEntityLevelCollisions
List<AbstractEntity> findEntityLevelCollisions(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1)
Composite entities can overlap in the game world. This method checks whether there are collisions (composite entities are usually not filled with entities at all positions!)
-
operateOnEntityLevelCollisions
void operateOnEntityLevelCollisions(AbstractCompositeEntity compositeEntity0, CoordI2 position0, AbstractCompositeEntity compositeEntity1, CoordI2 position1, WorldManager.CollisionDetectionListener listener)
Composite entities can overlap in the game world. This method checks whether there are collisions (composite entities are usually not filled with entities at all positions!)
-
registerInterceptor
void registerInterceptor(WorldManagerInterceptor interceptor)
World manager interceptors are notified about changes in the game world. Use rarely as this is performance sensitive
-
unregisterInterceptor
void unregisterInterceptor(UUID uuid)
World manager interceptors are notified about changes in the game world. Use rarely as this is performance sensitive
-
-