Class Scene
java.lang.Object
gaiasky.scene.Scene
The main scene, which contains the engine, the index, the archetypes, and more.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSystemsToEngine(com.badlogic.gdx.utils.Array<?> systems) voidaddToIndex(com.badlogic.ashley.core.Entity entity) Inserts the given entity into the index by running the index initializer system on it.Access to the archetypes.voidConstructs the scene graph structure in theGraphNodecomponents of the current entities.voiddisable(com.badlogic.ashley.core.EntitySystem... systems) Disable the given entity systems.voiddisable(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Disable the given entity systems.voidenable(com.badlogic.ashley.core.EntitySystem... systems) Enable the given entity systems.voidenable(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Enable the given entity systems.voidextractEntity(com.badlogic.ashley.core.Entity entity) Runs the matching extract systems on the given entity.com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> Returns a list with all the entities in the scene.voidfindEntities(com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> result, boolean expandOctree) Finds all the entities in the scene and puts them in the result list.voidfindEntitiesByComponentType(ComponentTypes.ComponentType componentType, com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> list) com.badlogic.ashley.utils.ImmutableArray<com.badlogic.ashley.core.Entity> findEntitiesByFamily(com.badlogic.ashley.core.Family family) com.badlogic.ashley.core.EntityReturns the focus entity with the given name, if it exists.com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> Returns a list with all the focusable entities in the scene.com.badlogic.ashley.core.EntityReturns the entity with the given name, or null if it does not exist.com.badlogic.ashley.core.EntitygetLineCopy(com.badlogic.ashley.core.Entity entity) Gets a line copy of the given entity, and attaches aTagCopycomponent to all the entities in the line.com.badlogic.ashley.core.EntitygetLineCopy(com.badlogic.ashley.core.Entity entity, Map<String, com.badlogic.ashley.core.Entity> index) com.badlogic.ashley.core.EntitygetNonIndexEntity(String name) Gets an entity from this scene that is not in the index, and thus not focusable.intgetNumberObjects(com.badlogic.ashley.core.Entity entity) Returns the number of actual objects held by this entity.intgetNumberObjects(OctreeNode node) Computes the number of objects in the given octree node, recursively.double[]getObjectPosition(String name, double[] out) Gets the current position of the object identified by the given name.com.badlogic.ashley.core.EntitygetSimpleCopy(com.badlogic.ashley.core.Entity entity) Gets a simple copy of the given entity and its components.index()Access to the index.voidvoidSets up the initializing systems and runs them.voidinitializeEntity(com.badlogic.ashley.core.Entity entity) Runs the matching initialization systems on the given entity.voidInitializes the name and id index using the current entities.voidinsert(com.badlogic.ashley.core.Entity entity, boolean addToIndex) voidmatchingFocusableNodes(String name, SortedSet<String> results, int maxResults, AtomicBoolean abort) Returns focus entities matching the given string by name, to a maximum ofmaxResults.voidmatchingNodes(String name, SortedSet<String> results, int maxResults, AtomicBoolean abort) Returns focus entities matching the given string by name, to a maximum ofmaxResults.voidprepareUpdateSystems(ISceneRenderer sceneRenderer) Prepares the engine to start running update cycles.voidremove(com.badlogic.ashley.core.Entity entity, boolean removeFromIndex) Removes the given entity from the scene.voidvoidreturnCopyObject(com.badlogic.ashley.core.Entity copy) voidrunOnce(com.badlogic.ashley.core.EntitySystem... systems) Runs the given entity systems only once with a dummy delta time of 0.voidrunOnce(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Runs the given entity systems only once with a dummy delta time of 0.voidRuns the set up initialization stage for all entities.voidsetUpEntity(com.badlogic.ashley.core.Entity entity) Runs the matching setup systems on the given entity.voidupdate(ITimeFrameProvider time) Updates the scene.voidupdateEntity(com.badlogic.ashley.core.Entity entity, float deltaTime) Runs the matching update systems on the given entity.voidupdateEntityGraph(com.badlogic.ashley.core.Entity entity, ITimeFrameProvider time, Vector3Q parentTranslation, float opacity) Updates the entity graph for the given entity with the given parent translation vector.voidUpdates the localized names of all entities in the scene.
-
Field Details
-
ROOT_NAME
- See Also:
-
engine
public com.badlogic.ashley.core.Engine engineThe engine, containing all entities, components and systems.
-
-
Constructor Details
-
Scene
public Scene()
-
-
Method Details
-
index
Access to the index. -
archetypes
Access to the archetypes. -
initialize
public void initialize() -
runOnce
public void runOnce(com.badlogic.ashley.core.EntitySystem... systems) Runs the given entity systems only once with a dummy delta time of 0. Useful for running one-time initialization and loading tasks.- Parameters:
systems- The systems to run.
-
runOnce
public void runOnce(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Runs the given entity systems only once with a dummy delta time of 0. Useful for running one-time initialization and loading tasks.- Parameters:
array- The systems array to run.
-
enable
public void enable(com.badlogic.ashley.core.EntitySystem... systems) Enable the given entity systems.- Parameters:
systems- The systems.
-
enable
public void enable(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Enable the given entity systems.- Parameters:
array- The systems.
-
disable
public void disable(com.badlogic.ashley.core.EntitySystem... systems) Disable the given entity systems.- Parameters:
systems- The systems.
-
disable
public void disable(com.badlogic.gdx.utils.Array<? extends com.badlogic.ashley.core.EntitySystem> array) Disable the given entity systems.- Parameters:
array- The systems.
-
initializeEntities
public void initializeEntities()Sets up the initializing systems and runs them. These systems perform the initial entity initialization. -
setUpEntities
public void setUpEntities()Runs the set up initialization stage for all entities. This happens when all asset loading has finished. -
addSystemsToEngine
public void addSystemsToEngine(com.badlogic.gdx.utils.Array<?> systems) -
initializeIndex
public void initializeIndex()Initializes the name and id index using the current entities. -
addToIndex
public void addToIndex(com.badlogic.ashley.core.Entity entity) Inserts the given entity into the index by running the index initializer system on it.- Parameters:
entity- The entity.
-
buildSceneGraph
public void buildSceneGraph()Constructs the scene graph structure in theGraphNodecomponents of the current entities. -
prepareUpdateSystems
Prepares the engine to start running update cycles. This method initializes the engine with all the necessary update systems. -
initializeEntity
public void initializeEntity(com.badlogic.ashley.core.Entity entity) Runs the matching initialization systems on the given entity. The systems are matched using their families.- Parameters:
entity- The entity to initialize.
-
setUpEntity
public void setUpEntity(com.badlogic.ashley.core.Entity entity) Runs the matching setup systems on the given entity. The systems are matched using their families.- Parameters:
entity- The entity to set up.
-
updateEntity
public void updateEntity(com.badlogic.ashley.core.Entity entity, float deltaTime) Runs the matching update systems on the given entity. The systems are matched using their families.- Parameters:
entity- The entity to update.deltaTime- Delta time in seconds.
-
extractEntity
public void extractEntity(com.badlogic.ashley.core.Entity entity) Runs the matching extract systems on the given entity. The systems are matched using their families.- Parameters:
entity- The entity to update.
-
updateEntityGraph
public void updateEntityGraph(com.badlogic.ashley.core.Entity entity, ITimeFrameProvider time, Vector3Q parentTranslation, float opacity) Updates the entity graph for the given entity with the given parent translation vector. Use with caution, this may have unforeseen consequences, as the process usually updates the whole scene graph starting at the root. This by-passes the usual procedure to update a single entity and its subtree.- Parameters:
entity- The entity to update.time- The time object.parentTranslation- The parent translation.opacity- The opacity value.
-
update
Updates the scene. This causes an update to the engine.- Parameters:
time- The time frame provider object.
-
insert
public void insert(com.badlogic.ashley.core.Entity entity, boolean addToIndex) -
remove
public void remove(com.badlogic.ashley.core.Entity entity, boolean removeFromIndex) Removes the given entity from the scene.- Parameters:
entity- The entity.removeFromIndex- Whether to remove it from the index too.
-
updateLocalizedNames
public void updateLocalizedNames()Updates the localized names of all entities in the scene. -
getEntity
Returns the entity with the given name, or null if it does not exist.- Parameters:
name- The name of the entity to retrieve.- Returns:
- The entity.
-
getNonIndexEntity
Gets an entity from this scene that is not in the index, and thus not focusable.- Parameters:
name- The name of the entity.- Returns:
- The entity, if it exists. Null otherwise.
-
findFocus
Returns the focus entity with the given name, if it exists.- Parameters:
name- The name.- Returns:
- The entity.
-
matchingFocusableNodes
public void matchingFocusableNodes(String name, SortedSet<String> results, int maxResults, AtomicBoolean abort) Returns focus entities matching the given string by name, to a maximum ofmaxResults.- Parameters:
name- The name.results- The set where the results are to be stored.maxResults- The maximum number of results.abort- To enable abortion mid-computation.
-
findFocusableEntities
public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> findFocusableEntities()Returns a list with all the focusable entities in the scene. Focusable entities are entities that have theFocuscomponent. Check out the focus component section in the documentation for more information.- Returns:
- A list with all focusable entities in this scene.
-
matchingNodes
public void matchingNodes(String name, SortedSet<String> results, int maxResults, AtomicBoolean abort) Returns focus entities matching the given string by name, to a maximum ofmaxResults.- Parameters:
name- The name.results- The set where the results are to be stored.maxResults- The maximum number of results.abort- To enable abortion mid-computation.
-
findEntities
public com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> findEntities()Returns a list with all the entities in the scene.- Returns:
- A list with all the entities in the scene.
-
findEntities
public void findEntities(com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> result, boolean expandOctree) Finds all the entities in the scene and puts them in the result list.- Parameters:
result- The list to hold the entities.
-
findEntitiesByFamily
public com.badlogic.ashley.utils.ImmutableArray<com.badlogic.ashley.core.Entity> findEntitiesByFamily(com.badlogic.ashley.core.Family family) -
findEntitiesByComponentType
public void findEntitiesByComponentType(ComponentTypes.ComponentType componentType, com.badlogic.gdx.utils.Array<com.badlogic.ashley.core.Entity> list) -
getObjectPosition
Gets the current position of the object identified by the given name. The given position is in the internal reference system and corrects stars for proper motions and other objects for their specific motions as well.- Parameters:
name- The name of the objectout- The out double array- Returns:
- The out double array if the object exists, has a position and out has 3 or more slots. Null otherwise.
-
getFamilies
-
getLineCopy
public com.badlogic.ashley.core.Entity getLineCopy(com.badlogic.ashley.core.Entity entity) Gets a line copy of the given entity, and attaches aTagCopycomponent to all the entities in the line.- Parameters:
entity- The entity.- Returns:
- The line copied entity.
-
getLineCopy
-
getSimpleCopy
public com.badlogic.ashley.core.Entity getSimpleCopy(com.badlogic.ashley.core.Entity entity) Gets a simple copy of the given entity and its components. Additionally, it attaches theTagCopycomponent to the entity.- Parameters:
entity- The entity to copy.- Returns:
- The copy.
-
returnCopyObject
public void returnCopyObject(com.badlogic.ashley.core.Entity copy) -
reportDebugObjects
public void reportDebugObjects() -
getNumberObjects
public int getNumberObjects(com.badlogic.ashley.core.Entity entity) Returns the number of actual objects held by this entity. Most entities count as only one object, but some, such as particle and star sets, orbital element sets or octrees, actually hold and wrap many objects.- Parameters:
entity- The entity.- Returns:
- The number of objects it holds.
-
getNumberObjects
Computes the number of objects in the given octree node, recursively.- Parameters:
node- The node.- Returns:
- The number of objects.
-