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.
    • 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​(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.
      • 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​(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,
                                             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,
                                             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
      • 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*
      • 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!)
      • 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