Deep RTS
Public Member Functions | Public Attributes | List of all members
Unit Class Reference

#include <Unit.h>

Inheritance diagram for Unit:
Footman

Public Member Functions

 Unit (Player &player)
 Constructor. More...
 
UnitgetBuiltBy () const
 
TilegetSpawnTile () const
 
TilegetTile (int tileID) const
 
std::set< int > getVisionTileIDs () const
 
UnitgetBuildEntity () const
 
UnitgetCombatTarget () const
 
TilegetNextTile ()
 
bool build (int idx)
 
bool build (int idx, bool ignoreCost)
 
void spawn (Tile &x, int initValue)
 
void despawn ()
 
void update ()
 
TilecenterTile () const
 
void enqueueState (const std::shared_ptr< BaseState > &state)
 
void transitionState ()
 
void transitionState (std::shared_ptr< BaseState > nextState)
 
void setPosition (Tile &tile)
 
void rightClick (Tile &tile)
 
void move (Tile &targetTile)
 
void attack (Tile &tile)
 
void harvest (Tile &tile)
 
int distance (Tile &tile) const
 
int distance (Unit &unit) const
 
Position distanceVector (Tile &target) const
 
void clearTiles ()
 
UnitclosestRecallBuilding () const
 
bool isDead ()
 
void afflictDamage (int dmg_)
 
int getDamage (Unit &target) const
 
void setDirection (int newX, int newY)
 
void setDirection (Position &dir)
 
void moveRelative (int x, int y)
 
void rightClickRelative (int x, int y)
 
bool operator== (int id) const
 
void tryMove (int16_t x, int16_t y)
 
void tryAttack ()
 
void tryHarvest ()
 
PlayergetPlayer ()
 
bool position_in_bounds (int x, int y) const
 
void setStateForTile (Tile *t)
 State alterations. More...
 
void clearStateForTile (Tile *t)
 

Public Attributes

Gamegame
 
const Configconfig
 
int id
 Unit ID. More...
 
std::string nameID
 Unit Name ID (i.e Peasant1) More...
 
Constants::Unit typeId
 Unit Type. More...
 
int health
 Unit Current Health. More...
 
int health_max
 Unit Max Health. More...
 
int direction
 Unit Direction. More...
 
int groundUnit
 
int waterUnit
 
int damageMin = -1
 
int damageMax = -1
 
int damageRange = -1
 
int damagePiercing = -1
 
int armor = -1
 
float lumberCarry = 0
 
float goldCarry = 0
 
float stoneCarry = 0
 
float carryCapacity = 10
 
std::vector< Constants::UnitbuildInventory
 
int speed
 
int sight
 
bool canHarvest
 
bool canAttack
 
bool canMove
 
bool military
 
bool structure
 
bool recallable = false
 
int lumberCost
 
int goldCost
 
int stoneCost
 
int foodProduction
 
int foodConsumption
 
int width
 
int height
 
std::string name
 
Playerplayer_
 
int spawnDuration
 
int spawnTileID = -1
 
int builtByID = -1
 
double harvestInterval = .5
 
int harvestTimer = 0
 
int harvestIterator {}
 
int harvestTargetID = -1
 
int spawnTimer = 0
 
int buildEntityID = -1
 
int buildTimer = 0
 
int combatTargetID = -1
 
double combatInterval = 1
 
double combatTimer = 0
 
int walking_timer = 0
 
std::vector< Tile * > walking_path
 
int walkingGoalID = -1
 
int stepsLeft = 0
 
double walking_interval = 1
 
int animationCounter = 0
 
Tiletile = nullptr
 
StateManagerstateManager
 
std::shared_ptr< BaseStatestate = nullptr
 
std::vector< Constants::StatestateList
 
Position worldPosition
 
bool removedFromGame = false
 

Constructor & Destructor Documentation

◆ Unit()

Unit::Unit ( Player player)
explicit

Constructor.

Member Function Documentation

◆ afflictDamage()

void Unit::afflictDamage ( int  dmg_)

◆ attack()

void Unit::attack ( Tile tile)

◆ build() [1/2]

bool Unit::build ( int  idx)

◆ build() [2/2]

bool Unit::build ( int  idx,
bool  ignoreCost 
)

◆ centerTile()

Tile * Unit::centerTile ( ) const

◆ clearStateForTile()

void Unit::clearStateForTile ( Tile t)

◆ clearTiles()

void Unit::clearTiles ( )

◆ closestRecallBuilding()

Unit * Unit::closestRecallBuilding ( ) const

◆ despawn()

void Unit::despawn ( )

◆ distance() [1/2]

int Unit::distance ( Tile tile) const

◆ distance() [2/2]

int Unit::distance ( Unit unit) const

◆ distanceVector()

Position Unit::distanceVector ( Tile target) const

◆ enqueueState()

void Unit::enqueueState ( const std::shared_ptr< BaseState > &  state)

◆ getBuildEntity()

Unit & Unit::getBuildEntity ( ) const

◆ getBuiltBy()

Unit & Unit::getBuiltBy ( ) const

◆ getCombatTarget()

Unit * Unit::getCombatTarget ( ) const

◆ getDamage()

int Unit::getDamage ( Unit target) const

◆ getNextTile()

Tile * Unit::getNextTile ( )

◆ getPlayer()

Player & Unit::getPlayer ( )

◆ getSpawnTile()

Tile & Unit::getSpawnTile ( ) const

◆ getTile()

Tile * Unit::getTile ( int  tileID) const

◆ getVisionTileIDs()

std::set< int > Unit::getVisionTileIDs ( ) const

◆ harvest()

void Unit::harvest ( Tile tile)

◆ isDead()

bool Unit::isDead ( )

◆ move()

void Unit::move ( Tile targetTile)

◆ moveRelative()

void Unit::moveRelative ( int  x,
int  y 
)

◆ operator==()

bool Unit::operator== ( int  id) const

◆ position_in_bounds()

bool Unit::position_in_bounds ( int  x,
int  y 
) const

◆ rightClick()

void Unit::rightClick ( Tile tile)

◆ rightClickRelative()

void Unit::rightClickRelative ( int  x,
int  y 
)

◆ setDirection() [1/2]

void Unit::setDirection ( int  newX,
int  newY 
)

◆ setDirection() [2/2]

void Unit::setDirection ( Position dir)

◆ setPosition()

void Unit::setPosition ( Tile tile)

◆ setStateForTile()

void Unit::setStateForTile ( Tile t)

State alterations.

◆ spawn()

void Unit::spawn ( Tile x,
int  initValue 
)

◆ transitionState() [1/2]

void Unit::transitionState ( )

◆ transitionState() [2/2]

void Unit::transitionState ( std::shared_ptr< BaseState nextState)

◆ tryAttack()

void Unit::tryAttack ( )

◆ tryHarvest()

void Unit::tryHarvest ( )

◆ tryMove()

void Unit::tryMove ( int16_t  x,
int16_t  y 
)

◆ update()

void Unit::update ( )

Member Data Documentation

◆ animationCounter

int Unit::animationCounter = 0

◆ armor

int Unit::armor = -1

◆ buildEntityID

int Unit::buildEntityID = -1

◆ buildInventory

std::vector<Constants::Unit> Unit::buildInventory

◆ buildTimer

int Unit::buildTimer = 0

◆ builtByID

int Unit::builtByID = -1

◆ canAttack

bool Unit::canAttack

◆ canHarvest

bool Unit::canHarvest

◆ canMove

bool Unit::canMove

◆ carryCapacity

float Unit::carryCapacity = 10

◆ combatInterval

double Unit::combatInterval = 1

◆ combatTargetID

int Unit::combatTargetID = -1

◆ combatTimer

double Unit::combatTimer = 0

◆ config

const Config& Unit::config

◆ damageMax

int Unit::damageMax = -1

◆ damageMin

int Unit::damageMin = -1

◆ damagePiercing

int Unit::damagePiercing = -1

◆ damageRange

int Unit::damageRange = -1

◆ direction

int Unit::direction

Unit Direction.

◆ foodConsumption

int Unit::foodConsumption

◆ foodProduction

int Unit::foodProduction

◆ game

Game* Unit::game

◆ goldCarry

float Unit::goldCarry = 0

◆ goldCost

int Unit::goldCost

◆ groundUnit

int Unit::groundUnit

◆ harvestInterval

double Unit::harvestInterval = .5

◆ harvestIterator

int Unit::harvestIterator {}

◆ harvestTargetID

int Unit::harvestTargetID = -1

◆ harvestTimer

int Unit::harvestTimer = 0

◆ health

int Unit::health

Unit Current Health.

◆ health_max

int Unit::health_max

Unit Max Health.

◆ height

int Unit::height

◆ id

int Unit::id

Unit ID.

Properties

◆ lumberCarry

float Unit::lumberCarry = 0

◆ lumberCost

int Unit::lumberCost

◆ military

bool Unit::military

◆ name

std::string Unit::name

◆ nameID

std::string Unit::nameID

Unit Name ID (i.e Peasant1)

◆ player_

Player& Unit::player_

◆ recallable

bool Unit::recallable = false

◆ removedFromGame

bool Unit::removedFromGame = false

◆ sight

int Unit::sight

◆ spawnDuration

int Unit::spawnDuration

◆ spawnTileID

int Unit::spawnTileID = -1

◆ spawnTimer

int Unit::spawnTimer = 0

◆ speed

int Unit::speed

◆ state

std::shared_ptr<BaseState> Unit::state = nullptr

◆ stateList

std::vector<Constants::State> Unit::stateList

◆ stateManager

StateManager* Unit::stateManager

◆ stepsLeft

int Unit::stepsLeft = 0

◆ stoneCarry

float Unit::stoneCarry = 0

◆ stoneCost

int Unit::stoneCost

◆ structure

bool Unit::structure

◆ tile

Tile* Unit::tile = nullptr

◆ typeId

Constants::Unit Unit::typeId

Unit Type.

◆ walking_interval

double Unit::walking_interval = 1

◆ walking_path

std::vector<Tile *> Unit::walking_path

◆ walking_timer

int Unit::walking_timer = 0

◆ walkingGoalID

int Unit::walkingGoalID = -1

◆ waterUnit

int Unit::waterUnit

◆ width

int Unit::width

◆ worldPosition

Position Unit::worldPosition

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