Package com.xebisco.yield
Class Entity2DContainer
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.Entity2DContainer
- All Implemented Interfaces:
Behavior,Renderable,Closeable,AutoCloseable
This is a class that represents a container for
Entity2Ds, allowing for instantiation and removal of entities.-
Constructor Summary
ConstructorsConstructorDescriptionEntity2DContainer(Application application) Constructs a new instance ofEntity2DContainerwith the given application. -
Method Summary
Modifier and TypeMethodDescriptionReturns the application that thisEntity2DContainerbelongs to.voidclose()entities()Returns the list of entities in the container.instantiate(Entity2DPrefab prefab) This function instantiates a 2D entity using a prefab and returns it.instantiate(Entity2DPrefab prefab, EntityStarter entityStarter) This function instantiates aEntity2Dusing a prefab and its components, sets its tags and parent, adds it to a list of entities, and starts it.voidonStart()This method is called when the behavior is started.voidonUpdate(ContextTime time) This method is called when the behavior needs to be updated with the current time.booleanRemoves the specified entity from the container and adds it to the list of entities to be removed.voidRenders the object using the providedRenderer.setEntities(List<Entity2D> entities) Sets the list of entities in the container.Returns the set of entities to be added to the container.Returns the set of entities to be removed from the container.Methods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Constructor Details
-
Entity2DContainer
Constructs a new instance ofEntity2DContainerwith the given application.- Parameters:
application- the application that this Entity2DContainer belongs to
-
-
Method Details
-
instantiate
This function instantiates aEntity2Dusing a prefab and its components, sets its tags and parent, adds it to a list of entities, and starts it.- Parameters:
prefab- The prefab parameter is an instance of theEntity2DPrefabclass, which contains information about the components and children of the entity to be instantiated.entityStarter- entityStarter is an optional parameter of type EntityStarter, which is an interface that defines a method called "start" that takes anEntity2Dobject as a parameter. This parameter allows for additional functionality to be executed on the instantiated entity after it has been created.- Returns:
- The method is returning an instance of the
Entity2Dclass.
-
onStart
public void onStart()Description copied from interface:BehaviorThis method is called when the behavior is started. It is typically used to initialize any necessary state or resources. -
render
Description copied from interface:RenderableRenders the object using the providedRenderer.- Specified by:
renderin interfaceRenderable- Parameters:
renderer- The renderer to use for rendering the object.
-
onUpdate
Description copied from interface:BehaviorThis method is called when the behavior needs to be updated with the current time. It is typically used to perform any necessary calculations or updates based on the current time. -
instantiate
This function instantiates a 2D entity using a prefab and returns it.- Parameters:
prefab- The prefab parameter is an instance of theEntity2DPrefabclass, which contains information about the components and children of the entity to be instantiated.- Returns:
- The method is returning an instance of the
Entity2Dclass.
-
remove
Removes the specified entity from the container and adds it to the list of entities to be removed.- Parameters:
entity- The entity to be removed- Returns:
- true if the entity was successfully added to the list of entities to be removed, false otherwise
- Throws:
IOException- if an error occurs while closing the entity
-
application
Returns the application that thisEntity2DContainerbelongs to.- Returns:
- the application
-
entities
Returns the list of entities in the container.- Returns:
- the list of entities
-
setEntities
Sets the list of entities in the container.- Parameters:
entities- the list of entities to be set- Returns:
- this Entity2DContainer instance for method chaining.
-
toAddEntities
Returns the set of entities to be added to the container.- Returns:
- the set of entities to be added
-
toRemoveEntities
Returns the set of entities to be removed from the container.- Returns:
- the set of entities to be removed
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-