Class JoinableComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.rendering.AtlasRenderComponent
com.csse3200.game.components.structures.JoinableComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Placeable,Renderable,Comparable<Renderable>
This component is used to change the texture and collision bounds of an entity
depending on its neighbours.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionJoinableComponent(com.badlogic.gdx.graphics.g2d.TextureAtlas textures, JoinLayer layer, JoinableComponentShapes shapes) Creates a joinable component. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the layer which is being joined on.voidnotifyNeighbours(boolean isJoined) Notifies all the entities neighbours of a change in join status.voidplaced()Determines what connections the structure has, and notifies neighbouring structures of a change.voidupdateJoin(JoinDirection direction, boolean isJoined) Updates whether the entity should be joining in a given direction.voidupdateTextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas atlas) Changes the texture atlas being used to the atlas given.voidNotifies neighbouring structures that the structure is being removed.Methods inherited from class com.csse3200.game.rendering.AtlasRenderComponent
draw, scaleEntity, setRegion, updateTextureAtlasMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, create, dispose, getLayer, getZIndex, overrideZIndex, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
JoinableComponent
public JoinableComponent(com.badlogic.gdx.graphics.g2d.TextureAtlas textures, JoinLayer layer, JoinableComponentShapes shapes) Creates a joinable component.- Parameters:
textures- - the textures to use for each cardinalitylayer- - the layer to join onshapes- - the collision shapes to use for each cardinality
-
-
Method Details
-
updateJoin
Updates whether the entity should be joining in a given direction.- Parameters:
direction- - the direction the entity should / should not be joined in.isJoined- - whether the entity is joined in the given direction.
-
notifyNeighbours
public void notifyNeighbours(boolean isJoined) Notifies all the entities neighbours of a change in join status.- Parameters:
isJoined- - whether the neighbours should or should not be joined.
-
getJoinLayer
Retrieves the layer which is being joined on.- Returns:
- the layer being joined on.
-
updateTextureAtlas
public void updateTextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas atlas) Changes the texture atlas being used to the atlas given.- Parameters:
atlas- - new atlas.
-
placed
public void placed()Determines what connections the structure has, and notifies neighbouring structures of a change. -
willRemove
public void willRemove()Notifies neighbouring structures that the structure is being removed.- Specified by:
willRemovein interfacePlaceable
-