19 #ifndef OPENXCOM_SAVEDBATTLEGAME_H
20 #define OPENXCOM_SAVEDBATTLEGAME_H
27 #include <yaml-cpp/yaml.h>
28 #include "BattleUnit.h"
38 class BattlescapeState;
54 int _mapsize_x, _mapsize_y, _mapsize_z;
55 std::vector<MapDataSet*> _mapDataSets;
58 std::vector<Node*> _nodes;
59 std::vector<BattleUnit*> _units;
60 std::vector<BattleItem*> _items, _deleted;
63 std::string _missionType;
70 bool _objectiveDestroyed;
71 std::vector<BattleUnit*> _exposedUnits;
72 std::list<BattleUnit*> _fallingUnits;
73 bool _unitsFalling, _cheating;
74 std::vector<Position> _tileSearch, _storageSpace;
75 BattleActionType _tuReserved;
77 std::vector< std::vector<std::pair<int, int> > > _baseModules;
79 BattleUnit *selectPlayerUnit(
int dir,
bool checkReselect =
false,
bool setReselect =
false,
bool checkInventory =
false);
88 YAML::Node
save()
const;
90 void initMap(
int mapsize_x,
int mapsize_y,
int mapsize_z);
108 std::vector<BattleItem*> *
getItems();
110 std::vector<BattleUnit*> *
getUnits();
128 return pos.z * _mapsize_y * _mapsize_x + pos.y * _mapsize_x + pos.x;
143 if (pos.x < 0 || pos.y < 0 || pos.z < 0
144 || pos.x >= _mapsize_x || pos.y >= _mapsize_y || pos.z >= _mapsize_z)
245 std::vector< std::vector<std::pair<int, int> > > &
getModuleMap();
void setTUReserved(BattleActionType reserved)
set the reserved fire mode.
Definition: SavedBattleGame.cpp:1699
void setDebugMode()
Sets debug mode.
Definition: SavedBattleGame.cpp:867
A utility class that modifies tile properties on a battlescape map.
Definition: TileEngine.h:40
bool getUnitsFalling() const
Checks the status of the switch that says "there are units falling".
Definition: SavedBattleGame.cpp:1537
bool addFallingUnit(BattleUnit *unit)
Adds this unit to the vector of falling units.
Definition: SavedBattleGame.cpp:1496
void endTurn()
Ends the turn.
Definition: SavedBattleGame.cpp:781
void setUnitsFalling(bool fall)
Toggles the switch that says "there are units falling, start the fall state".
Definition: SavedBattleGame.cpp:1528
BattleUnit * selectUnit(const Position &pos)
Selects the unit with position on map.
Definition: SavedBattleGame.cpp:692
std::vector< BattleUnit * > * getUnits()
Gets a pointer to the list of units.
Definition: SavedBattleGame.cpp:719
std::vector< MapDataSet * > * getMapDataSets()
Gets the game's mapdatafiles.
Definition: SavedBattleGame.cpp:755
void initMap(int mapsize_x, int mapsize_y, int mapsize_z)
Sets the dimensions of the map and initializes it.
Definition: SavedBattleGame.cpp:448
BattlescapeGame * getBattleGame()
Gets a pointer to the BattlescapeGame.
Definition: SavedBattleGame.cpp:899
void setBattleState(BattlescapeState *bs)
Sets the pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:908
bool isAborted() const
Checks if the mission was aborted.
Definition: SavedBattleGame.cpp:1053
void resetUnitTiles()
Resets tiles units are standing on.
Definition: SavedBattleGame.cpp:916
Pathfinding * getPathfinding() const
Gets the pathfinding object.
Definition: SavedBattleGame.cpp:737
Tile ** getTiles() const
Gets a pointer to the tiles, a tile is the smallest component of battlescape.
Definition: SavedBattleGame.cpp:437
int * getCurrentItemId()
Gets the current item ID.
Definition: SavedBattleGame.cpp:1086
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
void resetTurnCounter()
Resets the turn counter.
Definition: SavedBattleGame.cpp:1651
int getTurn() const
Gets the turn number.
Definition: SavedBattleGame.cpp:773
std::vector< BattleItem * > * getItems()
Gets a pointer to the list of items.
Definition: SavedBattleGame.cpp:728
bool setUnitPosition(BattleUnit *bu, const Position &position, bool testOnly=false)
Sets or tries to set a unit of a certain size on a certain position of the map.
Definition: SavedBattleGame.cpp:1422
void prepareNewTurn()
Carries out new turn preparations.
Definition: SavedBattleGame.cpp:1207
bool getKneelReserved() const
get whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1708
void removeUnconsciousBodyItem(BattleUnit *bu)
Removes the body item that corresponds to the unit.
Definition: SavedBattleGame.cpp:1401
void resetTiles()
Resets the visibility of all tiles on the map.
Definition: SavedBattleGame.cpp:1659
void randomizeItemLocations(Tile *t)
move all the leftover items to random locations in the storage tiles vector.
Definition: SavedBattleGame.cpp:963
void setSelectedUnit(BattleUnit *unit)
Sets the currently selected unit.
Definition: SavedBattleGame.cpp:589
void setAborted(bool flag)
Sets whether the mission was aborted.
Definition: SavedBattleGame.cpp:1044
int getTileIndex(const Position &pos) const
Converts coordinates into a unique index.
Definition: SavedBattleGame.h:126
std::vector< std::vector< std::pair< int, int > > > & getModuleMap()
get a reference to the baseModules map.
Definition: SavedBattleGame.cpp:1729
TileEngine * getTileEngine() const
Gets a pointer to the tileengine.
Definition: SavedBattleGame.cpp:746
SavedGame * getGeoscapeSave()
a shortcut to the geoscape save.
Definition: SavedBattleGame.cpp:1760
Node * getSpawnNode(int nodeRank, BattleUnit *unit)
Gets a spawn node.
Definition: SavedBattleGame.cpp:1097
void removeItem(BattleItem *item)
Removes an item from the game.
Definition: SavedBattleGame.cpp:985
int getMoraleModifier(BattleUnit *unit=0)
Gets the morale modifier for XCom based on the highest ranked, living XCom unit, or the modifier for ...
Definition: SavedBattleGame.cpp:1569
void setMissionType(const std::string &missionType)
Sets the mission type.
Definition: SavedBattleGame.cpp:494
Tile * getTile(const Position &pos) const
Gets the Tile at a given position on the map.
Definition: SavedBattleGame.h:141
bool placeUnitNearPosition(BattleUnit *unit, Position entryPoint)
Attempts to place a unit on or near entryPoint.
Definition: SavedBattleGame.cpp:1618
Node * getPatrolNode(bool scout, BattleUnit *unit, Node *fromNode)
Gets a patrol node.
Definition: SavedBattleGame.cpp:1138
int getMapSizeX() const
Gets terrain size x.
Definition: SavedBattleGame.cpp:530
int getGlobalShade() const
Gets the global shade.
Definition: SavedBattleGame.cpp:521
UnitFaction getSide() const
Gets the playing side.
Definition: SavedBattleGame.cpp:764
Represents a single item in the battlescape.
Definition: BattleItem.h:39
Set of rules and stats for a game.
Definition: Ruleset.h:69
int getMapSizeY() const
Gets terrain size y.
Definition: SavedBattleGame.cpp:539
BattleUnit * getHighestRankedXCom()
Gets the highest ranked, living XCom unit.
Definition: SavedBattleGame.cpp:1546
YAML::Node save() const
Saves a saved battle game to YAML.
Definition: SavedBattleGame.cpp:355
std::string getMissionType() const
Gets the mission type.
Definition: SavedBattleGame.cpp:503
BattleUnit * selectNextPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the next soldier.
Definition: SavedBattleGame.cpp:615
void calculateModuleMap()
calculate the number of map modules remaining
Definition: SavedBattleGame.cpp:1738
std::vector< Node * > * getNodes()
Gets a pointer to the list of nodes.
Definition: SavedBattleGame.cpp:710
~SavedBattleGame()
Cleans up the saved game.
Definition: SavedBattleGame.cpp:75
bool isCheating()
check if the AI has engaged cheat mode.
Definition: SavedBattleGame.cpp:1681
void setObjectiveDestroyed(bool flag)
Sets whether the objective is destroyed.
Definition: SavedBattleGame.cpp:1062
Basic element of which a battle map is build.
Definition: Tile.h:43
void load(const YAML::Node &node, Ruleset *rule, SavedGame *savedGame)
Loads a saved battle game from YAML.
Definition: SavedBattleGame.cpp:117
void getTileCoords(int index, int *x, int *y, int *z) const
Converts a tile index to its coordinates.
Definition: SavedBattleGame.cpp:569
std::vector< Position > & getStorageSpace()
give me access to the storage tiles vector.
Definition: SavedBattleGame.cpp:954
Packs of external game media.
Definition: ResourcePack.h:50
BattleUnit * selectPreviousPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the previous soldier.
Definition: SavedBattleGame.cpp:602
void loadMapResources(Game *game)
Load map resources.
Definition: SavedBattleGame.cpp:318
BattleUnit * getSelectedUnit() const
Gets the currently selected unit.
Definition: SavedBattleGame.cpp:580
bool getDebugMode() const
Gets debug mode.
Definition: SavedBattleGame.cpp:881
void setGlobalShade(int shade)
Sets the global shade.
Definition: SavedBattleGame.cpp:512
Battlescape game - the core game engine of the battlescape game.
Definition: BattlescapeGame.h:70
A utility class that calculates the shortest path between two points on the battlescape map...
Definition: Pathfinding.h:37
int getMapSizeXYZ() const
Gets terrain x*y*z.
Definition: SavedBattleGame.cpp:557
const std::vector< Position > getTileSearch()
get an 11x11 grid of positions (-10 to +10) to check.
Definition: SavedBattleGame.cpp:1672
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:50
int getMapSizeZ() const
Gets terrain size z.
Definition: SavedBattleGame.cpp:548
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:44
Represents a node/spawnpoint in the battlescape, loaded from RMP files.
Definition: Node.h:34
BattleActionType getTUReserved() const
get the reserved fire mode.
Definition: SavedBattleGame.cpp:1690
void setKneelReserved(bool reserved)
set whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1717
bool isObjectiveDestroyed()
Checks if the objective is detroyed.
Definition: SavedBattleGame.cpp:1077
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30
BattlescapeState * getBattleState()
Gets a pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:890
Battlescape screen which shows the tactical battle.
Definition: BattlescapeState.h:48
SavedBattleGame()
Creates a new battle save, based on the current generic save.
Definition: SavedBattleGame.cpp:54
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:58
void reviveUnconsciousUnits()
Revives unconscious units (healthcheck).
Definition: SavedBattleGame.cpp:1363
void initUtilities(ResourcePack *res)
Initialises the pathfinding and tileengine.
Definition: SavedBattleGame.cpp:484
bool eyesOnTarget(UnitFaction faction, BattleUnit *unit)
Checks whether a particular faction has eyes on *unit (whether any unit on that faction sees *unit)...
Definition: SavedBattleGame.cpp:1476
std::list< BattleUnit * > * getFallingUnits()
Gets the vector of falling units.
Definition: SavedBattleGame.cpp:1519