OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Public Member Functions | Static Public Attributes | List of all members
OpenXcom::Tile Class Reference

Basic element of which a battle map is build. More...

#include <Tile.h>

Classes

struct  SerializationKey
 

Public Member Functions

 Tile (const Position &pos)
 Creates a tile. More...
 
 ~Tile ()
 Cleans up a tile. More...
 
void load (const YAML::Node &node)
 Load the tile from yaml. More...
 
void loadBinary (Uint8 *buffer, Tile::SerializationKey &serializationKey)
 Load the tile from binary buffer in memory. More...
 
YAML::Node save () const
 Saves the tile to yaml. More...
 
void saveBinary (Uint8 **buffer) const
 Saves the tile to binary. More...
 
MapDatagetMapData (int part) const
 Get the MapData pointer of a part of the tile. More...
 
void setMapData (MapData *dat, int mapDataID, int mapDataSetID, int part)
 Sets the pointer to the mapdata for a specific part of the tile. More...
 
void getMapData (int *mapDataID, int *mapDataSetID, int part) const
 Gets the IDs to the mapdata for a specific part of the tile. More...
 
bool isVoid () const
 Gets whether this tile has no objects. More...
 
int getTUCost (int part, MovementType movementType) const
 Get the TU cost to walk over a certain part of the tile. More...
 
bool hasNoFloor (Tile *tileBelow) const
 Checks if this tile has a floor. More...
 
bool isBigWall () const
 Checks if this tile is a big wall. More...
 
int getTerrainLevel () const
 Get terrain level. More...
 
const PositiongetPosition () const
 Gets the tile's position. More...
 
int getFootstepSound (Tile *tileBelow) const
 Gets the floor object footstep sound. More...
 
int openDoor (int part, BattleUnit *Unit=0, BattleActionType reserve=BA_NONE)
 Open a door, returns the ID, 0(normal), 1(ufo) or -1 if no door opened. More...
 
bool isUfoDoorOpen (int part) const
 Check if the ufo door is open or opening. More...
 
int closeUfoDoor ()
 Close ufo door.
 
void setDiscovered (bool flag, int part)
 Sets the black fog of war status of this tile. More...
 
bool isDiscovered (int part) const
 Gets the black fog of war status of this tile. More...
 
void resetLight (int layer)
 Reset light to zero for this tile. More...
 
void addLight (int light, int layer)
 Add light to this tile. More...
 
int getShade () const
 Get the shade amount. More...
 
bool destroy (int part)
 Destroy a tile part. More...
 
bool damage (int part, int power)
 Damage a tile part. More...
 
void setExplosive (int power, bool force=false)
 Set a "virtual" explosive on this tile, to detonate later. More...
 
int getExplosive () const
 Get explosive power of this tile. More...
 
void animate ()
 Animated the tile parts. More...
 
SurfacegetSprite (int part) const
 Get object sprites. More...
 
void setUnit (BattleUnit *unit, Tile *tileBelow=0)
 Set a unit on this tile. More...
 
BattleUnitgetUnit () const
 Get the (alive) unit on this tile. More...
 
void setFire (int fire)
 Set fire, does not increment overlaps. More...
 
int getFire () const
 Get fire. More...
 
void addSmoke (int smoke)
 Add smoke, increments overlap. More...
 
void setSmoke (int smoke)
 Set smoke, does not increment overlaps. More...
 
int getSmoke () const
 Get smoke. More...
 
int getFlammability () const
 Get flammability.
 
int getFuel () const
 Get turns to burn.
 
void ignite (int power)
 attempt to set the tile on fire, sets overlaps to one if successful.
 
int getAnimationOffset () const
 Get fire and smoke animation offset. More...
 
void addItem (BattleItem *item, RuleInventory *ground)
 Add item. More...
 
void removeItem (BattleItem *item)
 Remove item. More...
 
int getTopItemSprite ()
 Get top-most item. More...
 
void prepareNewTurn ()
 New turn preparations. More...
 
std::vector< BattleItem * > * getInventory ()
 Get inventory on this tile. More...
 
void setMarkerColor (int color)
 Set the tile marker color. More...
 
int getMarkerColor ()
 Get the tile marker color. More...
 
void setVisible (int visibility)
 Set the tile visible flag. More...
 
int getVisible ()
 Get the tile visible flag. More...
 
void setPreview (int dir)
 set the direction (used for path previewing) More...
 
int getPreview () const
 retrieve the direction stored by the pathfinding. More...
 
void setTUMarker (int tu)
 set the number to be displayed for pathfinding preview. More...
 
int getTUMarker () const
 get the number to be displayed for pathfinding preview. More...
 
int getOverlaps () const
 how many times has this tile been overlapped with smoke/fire (runtime only) More...
 
void addOverlap ()
 increment the overlap value on this tile.
 
void setDangerous ()
 set the danger flag on this tile (so the AI will avoid it). More...
 
bool getDangerous ()
 check the danger flag on this tile. More...
 

Static Public Attributes

static struct
OpenXcom::Tile::SerializationKey 
serializationKey
 How many bytes various fields use in a serialized tile. See header.
 

Detailed Description

Basic element of which a battle map is build.

See also
http://www.ufopaedia.org/index.php?title=MAPS

Constructor & Destructor Documentation

OpenXcom::Tile::Tile ( const Position pos)

Creates a tile.

constructor

Parameters
posPosition.
OpenXcom::Tile::~Tile ( )

Cleans up a tile.

destructor

Member Function Documentation

void OpenXcom::Tile::addItem ( BattleItem item,
RuleInventory ground 
)

Add item.

Add an item on the tile.

Parameters
item
ground
void OpenXcom::Tile::addLight ( int  light,
int  layer 
)

Add light to this tile.

Add the light amount on the tile.

Only add light if the current light is lower.

Parameters
lightAmount of light to add.
layerLight is separated in 3 layers: Ambient, Static and Dynamic.
void OpenXcom::Tile::addSmoke ( int  smoke)

Add smoke, increments overlap.

Set the amount of turns this tile is smoking.

0 = no smoke.

Parameters
smoke: amount of turns this tile is smoking.
void OpenXcom::Tile::animate ( )

Animated the tile parts.

Animate the tile.

This means to advance the current frame for every object. Ufo doors are a bit special, they animated only when triggered. When ufo doors are on frame 0(closed) or frame 7(open) they are not animated further.

bool OpenXcom::Tile::damage ( int  part,
int  power 
)

Damage a tile part.

damage terrain - check against armor

Parameters
partPart to check.
powerPower of the damage.
Returns
bool Return true objective was destroyed
bool OpenXcom::Tile::destroy ( int  part)

Destroy a tile part.

Destroy a part on this tile.

We first remove the old object, then replace it with the destroyed one. This is because the object type of the old and new one are not necessarily the same. If the destroyed part is an explosive, set the tile's explosive value, which will trigger a chained explosion.

Parameters
part
Returns
bool Return true objective was destroyed
int OpenXcom::Tile::getAnimationOffset ( ) const

Get fire and smoke animation offset.

Get the number of frames the fire or smoke animation is off-sync.

To void fire and smoke animations of different tiles moving nice in sync - it looks fake.

Returns
offset
bool OpenXcom::Tile::getDangerous ( )

check the danger flag on this tile.

get the danger flag on this tile.

Returns
the danger flag for this tile.
int OpenXcom::Tile::getExplosive ( ) const

Get explosive power of this tile.

Get explosive on this tile.

Returns
explosive
int OpenXcom::Tile::getFire ( ) const

Get fire.

Get the amount of turns this tile is on fire.

0 = no fire.

Returns
fire : amount of turns this tile is on fire.
int OpenXcom::Tile::getFootstepSound ( Tile tileBelow) const

Gets the floor object footstep sound.

Gets the tile's footstep sound.

Parameters
tileBelow
Returns
sound ID
std::vector< BattleItem * > * OpenXcom::Tile::getInventory ( )

Get inventory on this tile.

Get the inventory on this tile.

Returns
pointer to a vector of battleitems.
MapData* OpenXcom::Tile::getMapData ( int  part) const
inline

Get the MapData pointer of a part of the tile.

Parameters
partthe part 0-3.
Returns
pointer to mapdata
void OpenXcom::Tile::getMapData ( int *  mapDataID,
int *  mapDataSetID,
int  part 
) const

Gets the IDs to the mapdata for a specific part of the tile.

get the MapData references of part 0 to 3.

Parameters
mapDataID
mapDataSetID
partthe part number
Returns
the object ID
int OpenXcom::Tile::getMarkerColor ( )

Get the tile marker color.

Get the marker color on this tile.

Returns
color
int OpenXcom::Tile::getOverlaps ( ) const

how many times has this tile been overlapped with smoke/fire (runtime only)

get the overlap value of this tile.

Returns
overlap
const Position& OpenXcom::Tile::getPosition ( ) const
inline

Gets the tile's position.

Returns
position
int OpenXcom::Tile::getPreview ( ) const

retrieve the direction stored by the pathfinding.

Returns
preview
int OpenXcom::Tile::getShade ( ) const

Get the shade amount.

Gets the tile's shade amount 0-15.

It returns the brightest of all light layers. Shade level is the inverse of light level. So a maximum amount of light (15) returns shade level 0.

Returns
shade
int OpenXcom::Tile::getSmoke ( ) const

Get smoke.

Get the amount of turns this tile is smoking.

0 = no smoke.

Returns
smoke : amount of turns this tile is smoking.
Surface * OpenXcom::Tile::getSprite ( int  part) const

Get object sprites.

Get the sprite of a certain part of the tile.

Parameters
part
Returns
Pointer to the sprite.
int OpenXcom::Tile::getTerrainLevel ( ) const

Get terrain level.

If an object stand on this tile, this returns how high the unit is it standing.

Returns
the level in pixels
int OpenXcom::Tile::getTopItemSprite ( )

Get top-most item.

Get the topmost item sprite to draw on the battlescape.

Returns
item sprite ID in floorob, or -1 when no item
int OpenXcom::Tile::getTUCost ( int  part,
MovementType  movementType 
) const

Get the TU cost to walk over a certain part of the tile.

Parameters
part
movementType
Returns
TU cost
int OpenXcom::Tile::getTUMarker ( ) const

get the number to be displayed for pathfinding preview.

Returns
marker
BattleUnit* OpenXcom::Tile::getUnit ( ) const
inline

Get the (alive) unit on this tile.

Returns
BattleUnit.
int OpenXcom::Tile::getVisible ( )

Get the tile visible flag.

Returns
visibility
bool OpenXcom::Tile::hasNoFloor ( Tile tileBelow) const

Checks if this tile has a floor.

Whether this tile has a floor or not.

If no object defined as floor, it has no floor.

Parameters
tileBelow
Returns
bool
bool OpenXcom::Tile::isBigWall ( ) const

Checks if this tile is a big wall.

Whether this tile has a big wall.

Returns
bool
bool OpenXcom::Tile::isDiscovered ( int  part) const

Gets the black fog of war status of this tile.

Get the black fog of war state of this tile.

Parameters
part0-2 westwall/northwall/content+floor
Returns
bool True = discovered the tile.
bool OpenXcom::Tile::isUfoDoorOpen ( int  part) const
inline

Check if the ufo door is open or opening.

Used for visibility/light blocking checks. This function assumes that there never are 2 doors on 1 tile or a door and another wall on 1 tile.

Parameters
part
Returns
bool
bool OpenXcom::Tile::isVoid ( ) const

Gets whether this tile has no objects.

Note that we can have a unit or smoke on this tile.

Returns
bool True if there is nothing but air on this tile.
void OpenXcom::Tile::load ( const YAML::Node &  node)

Load the tile from yaml.

Load the tile from a YAML node.

Parameters
nodeYAML node.
void OpenXcom::Tile::loadBinary ( Uint8 *  buffer,
Tile::SerializationKey &  serKey 
)

Load the tile from binary buffer in memory.

Load the tile from binary.

Parameters
bufferPointer to buffer.
serKeySerialization key.
int OpenXcom::Tile::openDoor ( int  part,
BattleUnit unit = 0,
BattleActionType  reserve = BA_NONE 
)

Open a door, returns the ID, 0(normal), 1(ufo) or -1 if no door opened.

Open a door on this tile.

Parameters
part
unit
reserve
Returns
a value: 0(normal door), 1(ufo door) or -1 if no door opened or 3 if ufo door(=animated) is still opening 4 if not enough TUs
void OpenXcom::Tile::prepareNewTurn ( )

New turn preparations.

average out any smoke added by the number of overlaps. apply fire/smoke damage to units as applicable.

void OpenXcom::Tile::removeItem ( BattleItem item)

Remove item.

Remove an item from the tile.

Parameters
item
void OpenXcom::Tile::resetLight ( int  layer)

Reset light to zero for this tile.

Reset the light amount on the tile.

This is done before a light level recalculation.

Parameters
layerLight is separated in 3 layers: Ambient, Static and Dynamic.
YAML::Node OpenXcom::Tile::save ( ) const

Saves the tile to yaml.

Saves the tile to a YAML node.

Returns
YAML node.
void OpenXcom::Tile::saveBinary ( Uint8 **  buffer) const

Saves the tile to binary.

Parameters
bufferpointer to buffer.
void OpenXcom::Tile::setDangerous ( )

set the danger flag on this tile (so the AI will avoid it).

set the danger flag on this tile.

void OpenXcom::Tile::setDiscovered ( bool  flag,
int  part 
)

Sets the black fog of war status of this tile.

Sets the tile's cache flag.

  • TODO: set this for each object separately?
    Parameters
    flagtrue/false
    part0-2 westwall/northwall/content+floor
void OpenXcom::Tile::setExplosive ( int  power,
bool  force = false 
)

Set a "virtual" explosive on this tile, to detonate later.

Set a "virtual" explosive on this tile.

We mark a tile this way to detonate it later. We do it this way, because the same tile can be visited multiple times by an "explosion ray". The explosive power on the tile is some kind of moving MAXIMUM of the explosive rays that passes it.

Parameters
powerPower of the damage.
forceForce damage.
void OpenXcom::Tile::setFire ( int  fire)

Set fire, does not increment overlaps.

Set the amount of turns this tile is on fire.

0 = no fire.

Parameters
fire: amount of turns this tile is on fire.
void OpenXcom::Tile::setMapData ( MapData dat,
int  mapDataID,
int  mapDataSetID,
int  part 
)

Sets the pointer to the mapdata for a specific part of the tile.

Set the MapData references of part 0 to 3.

Parameters
datpointer to the data object
mapDataID
mapDataSetID
partthe part number
void OpenXcom::Tile::setMarkerColor ( int  color)

Set the tile marker color.

Set the marker color on this tile.

Parameters
color
void OpenXcom::Tile::setPreview ( int  dir)

set the direction (used for path previewing)

set the direction used for path previewing.

Parameters
dir
void OpenXcom::Tile::setSmoke ( int  smoke)

Set smoke, does not increment overlaps.

Set the amount of turns this tile is smoking.

0 = no smoke.

Parameters
smoke: amount of turns this tile is smoking.
void OpenXcom::Tile::setTUMarker ( int  tu)

set the number to be displayed for pathfinding preview.

Parameters
tu
void OpenXcom::Tile::setUnit ( BattleUnit unit,
Tile tileBelow = 0 
)

Set a unit on this tile.

Parameters
unit
tileBelow
void OpenXcom::Tile::setVisible ( int  visibility)

Set the tile visible flag.

Parameters
visibility

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