Class ResourceBuildingFactory

java.lang.Object
com.deco2800.game.entities.factories.ResourceBuildingFactory

public class ResourceBuildingFactory extends Object
Factory to create structure entities with predefined components.

Each structure entity type should have a creation method that returns a corresponding entity. Predefined entity properties can be loaded from configs stored as json files which are defined in "StructureConfigs".

If needed, this factory can be separated into more specific factories for entities with similar characteristics.

  • Method Details

    • createStoneQuarry

      public static Entity createStoneQuarry(String entityName)
      Creates a Stone Quarry entity
      Returns:
      stone quarry entity
    • createWoodCutter

      public static Entity createWoodCutter(String entityName)
      Creates a Wood Quarry entity
      Returns:
      Wood quarry entity
    • handleClickedStructures

      public static boolean[] handleClickedStructures(int screenX, int screenY, SortedMap<String,com.badlogic.gdx.math.Rectangle> structureRects, boolean resourceBuildState, boolean buildEvent)
      Checks if a structure on the map has been clicked. If it has been clicked then that structure gets removed from the game
      Parameters:
      screenX - The x coordinate, origin is in the upper left corner
      screenY - The y coordinate, origin is in the upper left corner
      Returns:
      true if the point (screenX, screenY) is clear of structures else return false
    • toggleBuildState

      public static boolean toggleBuildState(boolean buildState)
      Toggles the build state of the player
    • toggleResourceBuildState

      public static boolean toggleResourceBuildState(boolean resourceBuildState)
      Toggles resource building placement mode