Bandidos
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
com.mygdx.game.components.GridUserComponent Class Reference
Inheritance diagram for com.mygdx.game.components.GridUserComponent:
com.mygdx.game.engine.entities.components.BaseEntityComponent com.mygdx.game.engine.events.EventDispatcher com.mygdx.game.components.BaseGridNavigationComponent com.mygdx.game.components.BaseEnemyAIComponent com.mygdx.game.components.BasicEnemyAIComponent

Public Member Functions

 GridUserComponent (Grid grid, String gridOccupyTag, int xSize, int ySize)
 
 GridUserComponent (Grid grid, String[] gridOccupyTags, int xSize, int ySize)
 
GridTile getCurrentLocatedTile ()
 
boolean isLocated ()
 
int getLocationX ()
 
int getLocationY ()
 
void placeSelfOnLocation (int x, int y)
 
void removeSelfFromLocation ()
 
Collection< String > getGridOccupyTags ()
 
void addGridOccupyTag (String tag)
 
void removeGridOccupyTag (String tag)
 
boolean hasGridOccupyTag (String tag)
 
void awake ()
 
- Public Member Functions inherited from com.mygdx.game.engine.entities.components.BaseEntityComponent
EngineTween startTweenOnComponent (Tween tween, TweenStartType tweenStartType)
 
Timeline startTimelineOnComponent (Timeline timeline, boolean updateInGameTime)
 
EngineTween doFloat (TweenableFloat floatToTween, float newValue, float duration, TweenStartType tweenStartType)
 
void stopAllComponentTweens ()
 
void initialize (BaseEntity parentEntity)
 
BaseEntity getParentOfComponent ()
 
boolean isActive ()
 
boolean isDestroyed ()
 
void setActiveState (boolean activeState)
 
void destroy ()
 
void update (float deltaTime)
 
abstract void awake ()
 
- Public Member Functions inherited from com.mygdx.game.engine.events.EventDispatcher
void addEventListener (String type, IEventReceiver listeningClass)
 
void dispatchEvent (Event event)
 
void removeEventListener (String type, IEventReceiver listener)
 
boolean hasEventListener (String type)
 
ArrayList< ListenerItemgetAllListeners ()
 
void destroyAllListeners ()
 
void clean ()
 

Static Public Attributes

static final int NOT_LOCATED_VALUE = -1337
 

Protected Member Functions

Grid getGrid ()
 
void destroyed ()
 
void updated (float deltaTime)
 
void activeStateChanged ()
 
- Protected Member Functions inherited from com.mygdx.game.engine.entities.components.BaseEntityComponent
abstract void updated (float deltaTime)
 
abstract void destroyed ()
 
abstract void activeStateChanged ()
 

Detailed Description

This class is a component which can be used to place the entity in grid data on 1 or multiple tiles depending on the given size. The way it represents something standing on a tile is by adding the grid occupy tags to the tile it is placed on. This way the tags can be used to determine their current occupy status.

Author
Ramses Di Perna

Constructor & Destructor Documentation

◆ GridUserComponent() [1/2]

com.mygdx.game.components.GridUserComponent.GridUserComponent ( Grid  grid,
String  gridOccupyTag,
int  xSize,
int  ySize 
)

Creates the grid user component. It needs a grid to be linked to, starter tags to represent its being and a size to know how many tiles to cover when located.

Parameters
gridto link with the grid user
gridOccupyTagtag it represents to indicate its id when placed on a tile.
xSizehow many tiles it should cover in the x axis. If the size x is > 1, then the tiles right to the given tile are also set.
ySizehow many tiles it should cover in the y axis. If the size y is > 1, then the tiles below the given tile are also set.

◆ GridUserComponent() [2/2]

com.mygdx.game.components.GridUserComponent.GridUserComponent ( Grid  grid,
String []  gridOccupyTags,
int  xSize,
int  ySize 
)

Creates the grid user component. It needs a grid to be linked to, starter tags to represent its being and a size to know how many tiles to cover when located.

Parameters
gridto link with the grid user
gridOccupyTagstags it represents to indicate its id when placed on a tile.
xSizehow many tiles it should cover in the x axis. If the size x is > 1, then the tiles right to the given tile are also set.
ySizehow many tiles it should cover in the y axis. If the size y is > 1, then the tiles below the given tile are also set.

Member Function Documentation

◆ activeStateChanged()

void com.mygdx.game.components.GridUserComponent.activeStateChanged ( )
protected

◆ addGridOccupyTag()

void com.mygdx.game.components.GridUserComponent.addGridOccupyTag ( String  tag)

Adds a grid occupy tag to the component and the tiles it is currently placed on.

Parameters
tagas occupy tag the component represents

◆ awake()

void com.mygdx.game.components.GridUserComponent.awake ( )

◆ destroyed()

void com.mygdx.game.components.GridUserComponent.destroyed ( )
protected

◆ getCurrentLocatedTile()

GridTile com.mygdx.game.components.GridUserComponent.getCurrentLocatedTile ( )

Returns the current tile this user is located on. If it was not placed, this will return null

Returns
The current tile this user is placed on.

◆ getGrid()

Grid com.mygdx.game.components.GridUserComponent.getGrid ( )
protected

Returns the instance of the grid this component is linked to by its constructor

Returns
The linked grid of the constructor

◆ getGridOccupyTags()

Collection<String> com.mygdx.game.components.GridUserComponent.getGridOccupyTags ( )

Returns all the grid occupy tags this component represents.

Returns
All grid occupy tags of component

◆ getLocationX()

int com.mygdx.game.components.GridUserComponent.getLocationX ( )

Grid space x axis location this entity stands on.

Returns
Grid space x axis location this entity stands on. (if not placed it has the value of 'NOT_LOCATED_VALUE')

◆ getLocationY()

int com.mygdx.game.components.GridUserComponent.getLocationY ( )

Grid space y axis location this entity stands on.

Returns
Grid space y axis location this entity stands on. (if not placed it has the value of 'NOT_LOCATED_VALUE')

◆ hasGridOccupyTag()

boolean com.mygdx.game.components.GridUserComponent.hasGridOccupyTag ( String  tag)

Returns whether this component represents the given tag

Parameters
tagto compare as occupy tag
Returns
true if this component represents the tag, else false

◆ isLocated()

boolean com.mygdx.game.components.GridUserComponent.isLocated ( )

Returns whether this component is placed on the grid, true if it is, else false.

Returns
True if it has been placed on the grid using the 'placeSelfOnLocation', else false

◆ placeSelfOnLocation()

void com.mygdx.game.components.GridUserComponent.placeSelfOnLocation ( int  x,
int  y 
)

Adds its tags to the tiles it covers and removes them from the one it covered before. This represents the starting location. If the size x is > 1, then the tiles right to the given tile are also set. If the size y is > 1, then the tiles below the given tile are also set.

Parameters
xof the tile to start the cover process.
yof the tile to start the cover process.

◆ removeGridOccupyTag()

void com.mygdx.game.components.GridUserComponent.removeGridOccupyTag ( String  tag)

Removes a grid occupy tag from the component and the tiles it is currently placed on.

Parameters
tagas occupy tag the component represents

◆ removeSelfFromLocation()

void com.mygdx.game.components.GridUserComponent.removeSelfFromLocation ( )

Removes its tags from the tile it is currently positioned on. This method will do nothing if this component has not been positioned yet.

◆ updated()

void com.mygdx.game.components.GridUserComponent.updated ( float  deltaTime)
protected

Member Data Documentation

◆ NOT_LOCATED_VALUE

final int com.mygdx.game.components.GridUserComponent.NOT_LOCATED_VALUE = -1337
static

The value of a location if it has not been located on the grid.


The documentation for this class was generated from the following file: