java.lang.Object
technology.sola.ecs.World
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes entities that were queued for destruction.createEntity
(@Nullable String uniqueId, @Nullable String name, Component... components) Creates a newEntity
inside this World with a set unique id.createEntity
(@Nullable String name, Component... components) Creates a newEntity
inside this World with a random unique id.createEntity
(Component... components) Creates a newEntity
inside this World with a random unique id.final void
Drops a view with desiredComponent
s if it exists.findEntitiesWithComponents
(Class<? extends Component>... componentClasses) @Nullable Entity
findEntityByName
(String name) Searches for anEntity
by its name.@Nullable Entity
findEntityByUniqueId
(String uniqueId) Searches for anEntity
by its unique id.@Nullable Entity
getEntityAtIndex
(int index) Gets anEntity
by index or null if one is not present.int
Gets the current number ofEntity
in this World.int
Gets the maximumEntity
count for this world.
-
Constructor Details
-
World
public World(int maxEntityCount) Creates a new World instance with specified maxEntity
count.- Parameters:
maxEntityCount
- the maximum number ofEntity
in this World, must be greater than 0
-
-
Method Details
-
cleanupDestroyedEntities
public void cleanupDestroyedEntities()Removes entities that were queued for destruction. Should be called at the end of a frame. -
getMaxEntityCount
public int getMaxEntityCount()Gets the maximumEntity
count for this world.- Returns:
- the max
Entity
count
-
getEntityCount
public int getEntityCount()Gets the current number ofEntity
in this World.- Returns:
- the current number of
Entity
in this World
-
createEntity
Creates a newEntity
inside this World with a random unique id. It is initialized with a set of components.If the total entity count goes above the max number specified in this world then an exception will be thrown.
- Parameters:
components
- theComponent
s to initialize the Entity with- Returns:
- a new
Entity
-
createEntity
Creates a newEntity
inside this World with a random unique id. It is initialized with name and components.If the total entity count goes above the max number specified in this world then an exception will be thrown.
- Parameters:
name
- the name to initialize this Entity withcomponents
- theComponent
s to initialize the Entity with- Returns:
- a new
Entity
-
createEntity
public Entity createEntity(@Nullable String uniqueId, @Nullable String name, Component... components) Creates a newEntity
inside this World with a set unique id. It is initialized with name and components. If the provided unique id is null then one will be generated.If the total entity count goes above the max number specified in this world then an exception will be thrown.
- Parameters:
uniqueId
- the unique id to initialize this Entity with or null to generate one automaticallyname
- the name to initialize this Entity withcomponents
- theComponent
s to initialize the Entity with- Returns:
- a new
Entity
-
getEntityAtIndex
Gets anEntity
by index or null if one is not present.- Parameters:
index
- the index of theEntity
to retrieve- Returns:
- the
Entity
-
findEntityByName
Searches for anEntity
by its name. Returns null if not ofund- Parameters:
name
- the name of theEntity
- Returns:
- the
Entity
with desired name or null if not found
-
findEntityByUniqueId
Searches for anEntity
by its unique id. Returns null if not found.- Parameters:
uniqueId
- the unique id of theEntity
- Returns:
- the
Entity
with desired uniqueId or null if not found
-
getEntities
- Returns:
- a
List
of allEntity
-
getEnabledEntities
- Returns:
- a
List
of all enabledEntity
-
findEntitiesWithComponents
@SafeVarargs public final List<Entity> findEntitiesWithComponents(Class<? extends Component>... componentClasses) Gets aList
ofEntity
where eachEntity
has all of theComponent
classes searched for and is not disabled.- Parameters:
componentClasses
- array ofComponent
classes eachEntity
will have- Returns:
- a
List
ofEntity
each having the desiredComponent
s
-
createView
- Returns:
- the
ViewBuilder
instance
-
dropView
Drops a view with desiredComponent
s if it exists. Any previous instance of this view will no longer receive updates.- Parameters:
componentClasses
- the component classes for the view to drop
-