OpenXcom
1.0
Open-source clone of the original X-Com
|
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... | |
MapData * | getMapData (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 Position & | getPosition () 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... | |
Surface * | getSprite (int part) const |
Get object sprites. More... | |
void | setUnit (BattleUnit *unit, Tile *tileBelow=0) |
Set a unit on this tile. More... | |
BattleUnit * | getUnit () 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. | |
Basic element of which a battle map is build.
OpenXcom::Tile::~Tile | ( | ) |
Cleans up a tile.
destructor
void OpenXcom::Tile::addItem | ( | BattleItem * | item, |
RuleInventory * | ground | ||
) |
Add item.
Add an item on the tile.
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.
light | Amount of light to add. |
layer | Light 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.
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
part | Part to check. |
power | Power of the damage. |
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.
part |
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.
bool OpenXcom::Tile::getDangerous | ( | ) |
check the danger flag on this tile.
get the danger flag on this tile.
int OpenXcom::Tile::getExplosive | ( | ) | const |
Get explosive power of this tile.
Get explosive on this tile.
int OpenXcom::Tile::getFire | ( | ) | const |
Get fire.
Get the amount of turns this tile is on fire.
0 = no fire.
int OpenXcom::Tile::getFootstepSound | ( | Tile * | tileBelow | ) | const |
Gets the floor object footstep sound.
Gets the tile's footstep sound.
tileBelow |
std::vector< BattleItem * > * OpenXcom::Tile::getInventory | ( | ) |
Get inventory on this tile.
Get the inventory on this tile.
|
inline |
Get the MapData pointer of a part of the tile.
part | the part 0-3. |
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.
mapDataID | |
mapDataSetID | |
part | the part number |
int OpenXcom::Tile::getMarkerColor | ( | ) |
Get the tile marker color.
Get the marker color on this tile.
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.
|
inline |
Gets the tile's position.
int OpenXcom::Tile::getPreview | ( | ) | const |
retrieve the direction stored by the pathfinding.
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.
int OpenXcom::Tile::getSmoke | ( | ) | const |
Get smoke.
Get the amount of turns this tile is smoking.
0 = no smoke.
Surface * OpenXcom::Tile::getSprite | ( | int | part | ) | const |
Get object sprites.
Get the sprite of a certain part of the tile.
part |
int OpenXcom::Tile::getTerrainLevel | ( | ) | const |
Get terrain level.
If an object stand on this tile, this returns how high the unit is it standing.
int OpenXcom::Tile::getTopItemSprite | ( | ) |
Get top-most item.
Get the topmost item sprite to draw on the battlescape.
int OpenXcom::Tile::getTUCost | ( | int | part, |
MovementType | movementType | ||
) | const |
Get the TU cost to walk over a certain part of the tile.
part | |
movementType |
int OpenXcom::Tile::getTUMarker | ( | ) | const |
get the number to be displayed for pathfinding preview.
|
inline |
Get the (alive) unit on this tile.
int OpenXcom::Tile::getVisible | ( | ) |
Get the tile visible flag.
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.
tileBelow |
bool OpenXcom::Tile::isBigWall | ( | ) | const |
Checks if this tile is a big wall.
Whether this tile has a big wall.
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.
part | 0-2 westwall/northwall/content+floor |
|
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.
part |
bool OpenXcom::Tile::isVoid | ( | ) | const |
Gets whether this tile has no objects.
Note that we can have a unit or smoke on this tile.
void OpenXcom::Tile::load | ( | const YAML::Node & | node | ) |
Load the tile from yaml.
Load the tile from a YAML node.
node | YAML node. |
void OpenXcom::Tile::loadBinary | ( | Uint8 * | buffer, |
Tile::SerializationKey & | serKey | ||
) |
Load the tile from binary buffer in memory.
Load the tile from binary.
buffer | Pointer to buffer. |
serKey | Serialization 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.
part | |
unit | |
reserve |
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.
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.
layer | Light 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.
void OpenXcom::Tile::saveBinary | ( | Uint8 ** | buffer | ) | const |
Saves the tile to binary.
buffer | pointer 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.
flag | true/false |
part | 0-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.
power | Power of the damage. |
force | Force 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.
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.
dat | pointer to the data object |
mapDataID | |
mapDataSetID | |
part | the part number |
void OpenXcom::Tile::setMarkerColor | ( | int | color | ) |
Set the tile marker color.
Set the marker color on this tile.
color |
void OpenXcom::Tile::setPreview | ( | int | dir | ) |
set the direction (used for path previewing)
set the direction used for path previewing.
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.
smoke | : amount of turns this tile is smoking. |
void OpenXcom::Tile::setTUMarker | ( | int | tu | ) |
set the number to be displayed for pathfinding preview.
tu |
void OpenXcom::Tile::setUnit | ( | BattleUnit * | unit, |
Tile * | tileBelow = 0 |
||
) |
Set a unit on this tile.
unit | |
tileBelow |
void OpenXcom::Tile::setVisible | ( | int | visibility | ) |
Set the tile visible flag.
visibility |