Class MapConfigLoader
java.lang.Object
com.csse3200.game.areas.mapConfig.MapConfigLoader
Class to handle loading of game areas from config files
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TloadConfigFile(String configPath, Class<T> target) Loads a generic config file from a given .json path.static AreaEntityConfigloadEntities(String loadPath) Loads a directory containing entity .json files into an AreaEntityConfig objectstatic GameAreaConfigloadMapDirectory(String mapDirPath) Loads a folder containing various .json files that represent a given game area.static GameAreaConfigloadMapFile(String filePath) Loads a GameArea from a single .json file containing all game area data.
-
Constructor Details
-
MapConfigLoader
public MapConfigLoader()
-
-
Method Details
-
loadMapFile
Loads a GameArea from a single .json file containing all game area data. Note this may not have the best error messages- Parameters:
filePath- Path of file to be loaded- Returns:
- The GameAreaConfig class loaded from the .json file
- Throws:
InvalidConfigException- If the file is unable to be loaded to a GameAreaConfig
-
loadMapDirectory
Loads a folder containing various .json files that represent a given game area.- Parameters:
mapDirPath- Directory where files will be loaded from- Returns:
- The GameAreaConfig class loaded from the directory
- Throws:
InvalidConfigException- If any file is unable to be loaded to a GameAreaConfig
-
loadEntities
Loads a directory containing entity .json files into an AreaEntityConfig object- Parameters:
loadPath- Path of directory to be loaded from- Returns:
- Loaded AreaEntityConfig object
- Throws:
InvalidConfigException- If any file in the directory is unable to be loaded
-
loadConfigFile
public static <T> T loadConfigFile(String configPath, Class<T> target) throws InvalidConfigException Loads a generic config file from a given .json path.- Type Parameters:
T- Type of config file to be loaded to- Parameters:
configPath- Path of .json file to be loaded fromtarget- Class for data to be loaded to- Returns:
- Object of type T with loaded .json data
- Throws:
InvalidConfigException- If the file is unable to be loaded to Class of type T
-