Package gaiasky.data
Class JsonLoader
java.lang.Object
gaiasky.data.AbstractSceneLoader
gaiasky.data.JsonLoader
- All Implemented Interfaces:
ISceneLoader
-
Field Summary
Fields inherited from class gaiasky.data.AbstractSceneLoader
datasetDirectory, dataSource, filePaths, loggedArchetypes, parentName, scene -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertJsonToMap(com.badlogic.gdx.utils.JsonValue json) intdepth(com.badlogic.gdx.utils.JsonValue attribute) voidfillEntity(com.badlogic.gdx.utils.JsonValue json, com.badlogic.ashley.core.Entity entity, String className) findAttribute(String attributeName, String className) com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity>loadData()Performs the loading and returns an array with the entities loaded.voidprocessJson(com.badlogic.gdx.utils.JsonValue json, Functions.Function3<Class<?>, Object, com.badlogic.gdx.utils.JsonValue, Boolean> function) Processes the given JSON tree, extracting and converting the class and value of each attribute, and runs the given function on it.booleanvoidsetDescription(String description) voidvoidto1DoubleArray(com.badlogic.gdx.utils.JsonValue attribute) to2DoubleArray(com.badlogic.gdx.utils.JsonValue attribute) to3DoubleArray(com.badlogic.gdx.utils.JsonValue attribute) toMultidimDoubleArray(com.badlogic.gdx.utils.JsonValue attribute) Methods inherited from class gaiasky.data.AbstractSceneLoader
initialize, initialize, initialize, setParentName
-
Constructor Details
-
JsonLoader
public JsonLoader()Creates a new instance.
-
-
Method Details
-
loadData
public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> loadData() throws FileNotFoundExceptionDescription copied from interface:ISceneLoaderPerforms the loading and returns an array with the entities loaded.- Returns:
- The loaded entities.
- Throws:
FileNotFoundException
-
processJson
public void processJson(com.badlogic.gdx.utils.JsonValue json, Functions.Function3<Class<?>, Object, throws com.badlogic.gdx.utils.reflect.ReflectionExceptioncom.badlogic.gdx.utils.JsonValue, Boolean> function) Processes the given JSON tree, extracting and converting the class and value of each attribute, and runs the given function on it.- Parameters:
json- The JSON object.function- The function to run for each attribute. The parameters of the function are the value class, the value object and the JSON attribute. It returns a boolean.- Throws:
com.badlogic.gdx.utils.reflect.ReflectionException
-
fillEntity
public void fillEntity(com.badlogic.gdx.utils.JsonValue json, com.badlogic.ashley.core.Entity entity, String className) throws com.badlogic.gdx.utils.reflect.ReflectionException - Throws:
com.badlogic.gdx.utils.reflect.ReflectionException
-
findAttribute
-
set
public boolean set(Object instance, String fieldName, Object fieldValue) throws IllegalStateException - Throws:
IllegalStateException
-
depth
public int depth(com.badlogic.gdx.utils.JsonValue attribute) -
toMultidimDoubleArray
-
to1DoubleArray
-
to2DoubleArray
-
to3DoubleArray
-
convertJsonToMap
-
setName
-
setDescription
-
setParams
-