19 #ifndef OPENXCOM_TILEENGINE_H
20 #define OPENXCOM_TILEENGINE_H
24 #include "../Ruleset/RuleItem.h"
30 class SavedBattleGame;
43 static const int MAX_VIEW_DISTANCE = 20;
44 static const int MAX_VOXEL_VIEW_DISTANCE = MAX_VIEW_DISTANCE * 16;
45 static const int MAX_DARKNESS_TO_SEE_UNITS = 9;
47 std::vector<Uint16> *_voxelData;
48 static const int heightFromCenter[11];
49 void addLight(
const Position ¢er,
int power,
int layer);
50 int blockage(
Tile *tile,
const int part, ItemDamageType type,
int direction = -1,
bool checkingFromOrigin =
false);
51 bool _personalLighting;
bool canTargetUnit(Position *originVoxel, Tile *tile, Position *scanVoxel, BattleUnit *excludeUnit, BattleUnit *potentialUnit=0)
Checks validity for targetting a unit.
Definition: TileEngine.cpp:532
A utility class that modifies tile properties on a battlescape map.
Definition: TileEngine.h:40
int castedShade(const Position &voxel)
Calculates the z voxel for shadows.
Definition: TileEngine.cpp:2245
void togglePersonalLighting()
Turn XCom soldier's personal lighting on or off.
Definition: TileEngine.cpp:2381
bool canMakeSnap(BattleUnit *unit, BattleUnit *target)
Checks validity of a snap shot to this position.
Definition: TileEngine.cpp:909
int calculateLine(const Position &origin, const Position &target, bool storeTrajectory, std::vector< Position > *trajectory, BattleUnit *excludeUnit, bool doVoxelCheck=true, bool onlyVisible=false, BattleUnit *excludeAllBut=0)
Calculates a line trajectory.
Definition: TileEngine.cpp:2020
void explode(const Position ¢er, int power, ItemDamageType type, int maxRadius, BattleUnit *unit=0)
Handles explosions.
Definition: TileEngine.cpp:1105
bool psiAttack(BattleAction *action)
Attempts a panic or mind control action.
Definition: TileEngine.cpp:2420
Definition: BattlescapeGame.h:45
int closeUfoDoors()
Closes ufo doors.
Definition: TileEngine.cpp:1983
bool isVoxelVisible(const Position &voxel)
Checks the visibility of a given voxel.
Definition: TileEngine.cpp:2274
int verticalBlockage(Tile *startTile, Tile *endTile, ItemDamageType type)
Checks the vertical blockage of a tile.
Definition: TileEngine.cpp:1446
BattleUnit * hit(const Position ¢er, int power, ItemDamageType type, BattleUnit *unit)
Handles bullet/weapon hits.
Definition: TileEngine.cpp:1000
int unitOpensDoor(BattleUnit *unit, bool rClick=false, int dir=-1)
Unit opens door?
Definition: TileEngine.cpp:1797
void recalculateFOV()
Recalculates FOV of all units in-game.
Definition: TileEngine.cpp:2730
TileEngine(SavedBattleGame *save, std::vector< Uint16 > *voxelData)
Creates a new TileEngine class.
Definition: TileEngine.cpp:64
Position getOriginVoxel(BattleAction &action, Tile *tile)
determine the origin voxel of a given action.
Definition: TileEngine.cpp:2797
bool visible(BattleUnit *currentUnit, Tile *tile)
Checks visibility of a unit on this tile.
Definition: TileEngine.cpp:388
int getDirectionTo(const Position &origin, const Position &target) const
Get direction to a certain point.
Definition: TileEngine.cpp:2747
int faceWindow(const Position &position)
Gets the AI to look through a window.
Definition: TileEngine.cpp:2651
std::vector< BattleUnit * > getSpottingUnits(BattleUnit *unit)
Creates a vector of units that can spot this unit.
Definition: TileEngine.cpp:823
bool tryReactionSnap(BattleUnit *unit, BattleUnit *target)
Tries to perform a reaction snap shot to this location.
Definition: TileEngine.cpp:937
Tile * applyGravity(Tile *t)
Applies gravity to anything that occupy this tile.
Definition: TileEngine.cpp:2480
Tile * checkForTerrainExplosions()
Checks if a destroyed tile starts an explosion.
Definition: TileEngine.cpp:1426
bool validMeleeRange(BattleUnit *attacker, BattleUnit *target, int dir)
Returns melee validity between two units.
Definition: TileEngine.cpp:2581
bool checkReactionFire(BattleUnit *unit)
Checks reaction fire.
Definition: TileEngine.cpp:775
BattleUnit * getReactor(std::vector< BattleUnit * > spotters, BattleUnit *unit)
Given a vector of spotters, and a unit, picks the spotter with the highest reaction score...
Definition: TileEngine.cpp:875
void calculateSunShading()
Calculates sun shading of the whole map.
Definition: TileEngine.cpp:79
bool detonate(Tile *tile)
Blows this tile up.
Definition: TileEngine.cpp:1343
void checkAdjacentDoors(Position pos, int part)
Opens any doors this door is connected to.
Definition: TileEngine.cpp:1953
int voxelCheck(const Position &voxel, BattleUnit *excludeUnit, bool excludeAllUnits=false, bool onlyVisible=false, BattleUnit *excludeAllBut=0)
Checks what type of voxel occupies this space.
Definition: TileEngine.cpp:2303
void calculateTerrainLighting()
Recalculates lighting of the battlescape for terrain.
Definition: TileEngine.cpp:115
int distanceSq(const Position &pos1, const Position &pos2, bool considerZ=true) const
Checks the distance squared between two positions.
Definition: TileEngine.cpp:2407
Basic element of which a battle map is build.
Definition: Tile.h:43
Position getSightOriginVoxel(BattleUnit *currentUnit)
Gets the origin voxel of a unit's eyesight.
Definition: TileEngine.cpp:357
int calculateParabola(const Position &origin, const Position &target, bool storeTrajectory, std::vector< Position > *trajectory, BattleUnit *excludeUnit, double curvature, const Position delta)
Calculates a parabola trajectory.
Definition: TileEngine.cpp:2186
void setDangerZone(Position pos, int radius, BattleUnit *unit)
mark a region of the map as "dangerous" for a turn.
Definition: TileEngine.cpp:2872
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:50
void calculateUnitLighting()
Recalculates lighting of the battlescape for units.
Definition: TileEngine.cpp:162
int checkVoxelExposure(Position *originVoxel, Tile *tile, BattleUnit *excludeUnit, BattleUnit *excludeAllBut)
Checks a unit's % exposure on a tile.
Definition: TileEngine.cpp:454
bool validateThrow(BattleAction &action, Position originVoxel, Position targetVoxel, double *curve=0, int *voxelType=0)
Validates a throwing action.
Definition: TileEngine.cpp:2677
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30
int horizontalBlockage(Tile *startTile, Tile *endTile, ItemDamageType type)
Checks the horizontal blockage of a tile.
Definition: TileEngine.cpp:1510
bool canTargetTile(Position *originVoxel, Tile *tile, int part, Position *scanVoxel, BattleUnit *excludeUnit)
Check validity for targetting a tile.
Definition: TileEngine.cpp:630
~TileEngine()
Cleans up the TileEngine.
Definition: TileEngine.cpp:71
int distance(const Position &pos1, const Position &pos2) const
Checks the distance between two positions.
Definition: TileEngine.cpp:2393
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:58
bool calculateFOV(BattleUnit *unit)
Calculates the field of view from a units view point.
Definition: TileEngine.cpp:227