Package gaiasky.data
Class NewJsonLoader
java.lang.Object
gaiasky.data.AbstractSceneLoader
gaiasky.data.NewJsonLoader
- All Implemented Interfaces:
ISceneLoader
-
Field Summary
Fields inherited from class gaiasky.data.AbstractSceneLoader
dataSource, filePaths, loggedArchetypes, parentName, scene
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvertJsonToMap
(com.badlogic.gdx.utils.JsonValue json) int
depth
(com.badlogic.gdx.utils.JsonValue attribute) void
fillEntity
(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.void
processJson
(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.boolean
void
setDescription
(String description) void
void
to1DoubleArray
(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, setParentName
-
Constructor Details
-
NewJsonLoader
public NewJsonLoader()Creates a new instance.
-
-
Method Details
-
loadData
public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> loadData() throws FileNotFoundExceptionDescription copied from interface:ISceneLoader
Performs 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
-