Class PowerBlockManager

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.api.restartable.Restartable
nl.pim16aap2.animatedarchitecture.core.managers.PowerBlockManager
All Implemented Interfaces:
IRestartable, StructureDeletionManager.IDeletionListener

@Singleton public final class PowerBlockManager extends Restartable implements StructureDeletionManager.IDeletionListener
Manages all power block interactions.
  • Method Details

    • unloadWorld

      public void unloadWorld(String worldName)
      Unloads a world from the cache.
      Parameters:
      worldName - The name of the world to unload.
    • loadWorld

      public void loadWorld(String worldName)
      Loads a world.
      Parameters:
      worldName - The name of the world.
    • structuresFromPowerBlockLoc

      public CompletableFuture<List<Structure>> structuresFromPowerBlockLoc(ILocation location)
      Gets all Structures that have a powerblock at a location in a world.
      Parameters:
      location - The location.
      Returns:
      All Structures that have a powerblock at a location in a world.
    • structuresFromPowerBlockLoc

      public CompletableFuture<List<Structure>> structuresFromPowerBlockLoc(Vector3Di loc, IWorld world)
      Gets all Structures that have a powerblock at a location in a world.
      Parameters:
      loc - The location.
      world - The world.
      Returns:
      All Structures that have a powerblock at a location in a world.
    • structuresFromPowerBlockLoc

      public CompletableFuture<List<Structure>> structuresFromPowerBlockLoc(Vector3Di loc, String worldName)
      Gets all Structures that have a powerblock at a location in a world.
      Parameters:
      loc - The location.
      worldName - The name of the world.
      Returns:
      All Structures that have a powerblock at a location in a world.
    • structuresInChunk

      public CompletableFuture<List<Structure>> structuresInChunk(Vector3Di loc, String worldName)
      Retrieves all structures whose powerblocks exist in the same chunk as a given location.
      Parameters:
      loc - The location.
      worldName - The name of the world to search in.
      Returns:
      The UIDs of the structures that whose powerblocks lie in the same chunk as the location.
    • isAnimatedArchitectureWorld

      public boolean isAnimatedArchitectureWorld(String worldName)
      Checks if a world is a AnimatedArchitecture world. In other words, it checks if a world contains more than 0 structures.
      Parameters:
      worldName - The name of the world.
      Returns:
      True if the world contains at least 1 structure.
    • updatePowerBlockLoc

      public void updatePowerBlockLoc(Structure structure, Vector3Di oldPos, Vector3Di newPos)
      Updates the position of the power block of a Structure in the database.
      Parameters:
      structure - The Structure.
      oldPos - The old position.
      newPos - The new position.
    • onStructureAddOrRemove

      public void onStructureAddOrRemove(String worldName, Vector3Di pos)
      Invalidates the cache for when a structure is either added to a world or removed from it.
      Parameters:
      worldName - The name of the world of the structure.
      pos - The position of the structure's power block.
    • invalidateChunk

      public void invalidateChunk(String worldName, Vector2Di chunk)
      Invalidates the cache of a chunk in a world.
      Parameters:
      worldName - The name of the world.
      chunk - The location (x,z) of the chunk in chunk-space.
    • shutDown

      public void shutDown()
      Description copied from interface: IRestartable
      Handles a shutdown.
      Specified by:
      shutDown in interface IRestartable
    • onStructureDeletion

      public void onStructureDeletion(IStructureConst structure)
      Description copied from interface: StructureDeletionManager.IDeletionListener
      Called when a structure is deleted.
      Specified by:
      onStructureDeletion in interface StructureDeletionManager.IDeletionListener
      Parameters:
      structure - The structure that was deleted.