Class TroopContainerComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.friendly.TroopContainerComponent
Allows us to make use of an entity that contains other entities
i.e. an in-game 'unit'. Does so by binding them within a range of one another and propagating updates to its sub-entities.
This implementation does not assume that all Units are homogenous
Also, this slightly acts as a disgusting entity/component blend, unsure if it should just be an extension of the entity.-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the corresponding entity is created.void
dispose()
Called when the component is disposed.void
Early update called once per frame of the game, before update().static ArrayList<com.badlogic.gdx.math.Vector2>
getFormation
(com.badlogic.gdx.math.Vector2 centrePos, float boundingRadius, int n) Finds the formation of the troops around a pointvoid
update()
updates the components of troops, and pulls them back in line if they have managed to move too far from the center of the unitMethods inherited from class com.deco2800.game.components.Component
getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
TroopContainerComponent
-
-
Method Details
-
create
public void create()Called when the corresponding entity is created. Used to create all of the sub-entities, so that they do not need to be individually created. Note that this fails if the sub-entities are created on their own. -
earlyUpdate
public void earlyUpdate()Description copied from class:Component
Early update called once per frame of the game, before update(). Use this only for logic that must run before other updates, such as physics. Not called if component is disabled.- Overrides:
earlyUpdate
in classComponent
-
update
public void update()updates the components of troops, and pulls them back in line if they have managed to move too far from the center of the unit -
dispose
public void dispose()Description copied from class:Component
Called when the component is disposed. Dispose of any internal resources here. -
getFormation
public static ArrayList<com.badlogic.gdx.math.Vector2> getFormation(com.badlogic.gdx.math.Vector2 centrePos, float boundingRadius, int n) Finds the formation of the troops around a point- Parameters:
centrePos
- the position the unit is/will be centred onn
- the number of troops to form in the unit- Returns:
- the positions of the resultant troops
-