Class ResourceBuildingFactory
java.lang.Object
com.deco2800.game.entities.factories.ResourceBuildingFactory
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 Summary
Modifier and TypeMethodDescriptionstatic Entity
createStoneQuarry
(String entityName) Creates a Stone Quarry entitystatic Entity
createWoodCutter
(String entityName) Creates a Wood Quarry entitystatic 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.static boolean
toggleBuildState
(boolean buildState) Toggles the build state of the playerstatic boolean
toggleResourceBuildState
(boolean resourceBuildState) Toggles resource building placement mode
-
Method Details
-
createStoneQuarry
Creates a Stone Quarry entity- Returns:
- stone quarry entity
-
createWoodCutter
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 cornerscreenY
- 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
-