OpenXcom  1.0
Open-source clone of the original X-Com
BattlescapeGenerator.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <vector>
21 #include "../Mod/RuleTerrain.h"
22 #include "../Mod/MapScript.h"
23 
24 namespace OpenXcom
25 {
26 
27 class SavedBattleGame;
28 class Mod;
29 class Craft;
30 class Ufo;
31 class BattleItem;
32 class MapBlock;
33 class Vehicle;
34 class Tile;
35 class RuleInventory;
36 class RuleItem;
37 class Unit;
38 class AlienRace;
39 class AlienDeployment;
40 class Game;
41 class Base;
42 class MissionSite;
43 class AlienBase;
44 class BattleUnit;
45 class Texture;
46 
51 {
52 private:
53  Game *_game;
54  SavedBattleGame *_save;
55  Mod *_mod;
56  Craft *_craft;
57  Ufo *_ufo;
58  Base *_base;
59  MissionSite *_mission;
60  AlienBase *_alienBase;
61  RuleTerrain *_terrain;
62  int _mapsize_x, _mapsize_y, _mapsize_z;
63  Texture *_worldTexture;
64  int _worldShade;
65  int _unitSequence;
66  Tile *_craftInventoryTile;
67  std::string _alienRace;
68  int _alienItemLevel;
69  bool _allowAutoLoadout, _baseInventory, _generateFuel, _craftDeployed;
70  int _craftZ;
71  SDL_Rect _craftPos;
72  std::vector<SDL_Rect> _ufoPos;
73  int _blocksToDo;
74  std::vector< std::vector<MapBlock*> > _blocks;
75  std::vector< std::vector<bool> > _landingzone;
76  std::vector< std::vector<int> > _segments, _drillMap;
77  MapBlock *_dummy;
78 
80  void init(bool resetTerrain);
82  void generateMap(const std::vector<MapScript*> *script);
84  BattleUnit *addXCOMVehicle(Vehicle *v);
86  BattleUnit *addXCOMUnit(BattleUnit *unit);
88  BattleUnit *addAlien(Unit *rules, int alienRank, bool outside);
90  BattleUnit *addCivilian(Unit *rules);
92  bool placeItemByLayout(BattleItem *item);
94  bool addItem(BattleItem *item, BattleUnit *unit, bool allowSecondClip = false);
96  int loadMAP(MapBlock *mapblock, int xoff, int yoff, RuleTerrain *terrain, int objectIDOffset, bool discovered = false, bool craft = false);
98  void loadRMP(MapBlock *mapblock, int xoff, int yoff, int segment);
100  void fuelPowerSources();
102  void explodePowerSources();
104  void deployXCOM();
106  bool canPlaceXCOMUnit(Tile *tile);
108  void deployAliens(AlienDeployment *deployment);
110  void deployCivilians(int max);
112  bool placeUnitNearFriend(BattleUnit *unit);
114  void loadWeapons();
116  bool addCraft(MapBlock *craftMap, MapScript *command, SDL_Rect &craftPos);
118  bool addLine(MapDirection lineType, const std::vector<SDL_Rect*> *rects);
120  bool addBlock(int x, int y, MapBlock *block);
122  void loadNodes();
124  void attachNodeLinks();
126  bool selectPosition(const std::vector<SDL_Rect *> *rects, int &X, int &Y, int sizeX, int sizeY);
128  void generateBaseMap();
130  void clearModule(int x, int y, int sizeX, int sizeY);
132  void drillModules(TunnelData* data, const std::vector<SDL_Rect *> *rects, MapDirection dir);
134  bool removeBlocks(MapScript *command);
136  void setDepth(AlienDeployment* ruleDeploy, bool nextStage);
138  void setMusic(AlienDeployment* ruleDeploy, bool nextStage);
139 public:
141  BattlescapeGenerator(Game* game);
145  void setCraft(Craft *craft);
147  void setUfo(Ufo* ufo);
149  void setWorldTexture(Texture *texture);
151  void setWorldShade(int shade);
153  void setAlienRace(const std::string &alienRace);
155  void setAlienItemlevel(int alienItemLevel);
157  void setBase(Base *base);
159  void setMissionSite(MissionSite* mission);
161  void setAlienBase(AlienBase* base);
163  void setTerrain(RuleTerrain *terrain);
165  void run();
167  void nextStage();
169  void runInventory(Craft *craft);
171  void setupObjectives(AlienDeployment *ruleDeploy);
172  // Autoequip a set of units
173  static void autoEquip(std::vector<BattleUnit*> units, Mod *mod, SavedBattleGame *addToSave, std::vector<BattleItem*> *craftInv,
174  RuleInventory *groundRuleInv, int worldShade, bool allowAutoLoadout, bool overrideEquipmentLayout);
175 };
176 
177 }
~BattlescapeGenerator()
Cleans up the BattlescapeGenerator.
Definition: BattlescapeGenerator.cpp:81
void setMissionSite(MissionSite *mission)
Sets the mission site.
Definition: BattlescapeGenerator.cpp:183
Represents a craft stored in a base.
Definition: Craft.h:45
Represents a vehicle (tanks etc.) kept in a craft.
Definition: Vehicle.h:32
Represents an alien base on the world.
Definition: AlienBase.h:31
void runInventory(Craft *craft)
Generates an inventory battlescape.
Definition: BattlescapeGenerator.cpp:1943
void run()
Runs the generator.
Definition: BattlescapeGenerator.cpp:544
void setupObjectives(AlienDeployment *ruleDeploy)
Sets up the objectives for the map.
Definition: BattlescapeGenerator.cpp:2995
Represents an alien mission site on the world.
Definition: MissionSite.h:33
Represents a Terrain Map Block.
Definition: MapBlock.h:37
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
void setWorldShade(int shade)
Sets the polygon shade.
Definition: BattlescapeGenerator.cpp:140
void setUfo(Ufo *ufo)
Sets the ufo.
Definition: BattlescapeGenerator.cpp:121
void setAlienItemlevel(int alienItemLevel)
Sets the alien item level.
Definition: BattlescapeGenerator.cpp:164
BattlescapeGenerator(Game *game)
Creates a new BattlescapeGenerator class.
Definition: BattlescapeGenerator.cpp:72
Represents a single item in the battlescape.
Definition: BattleItem.h:37
void nextStage()
Sets up the next stage (for Cydonia/TFTD missions).
Definition: BattlescapeGenerator.cpp:193
void setAlienBase(AlienBase *base)
Sets the alien base.
Definition: BattlescapeGenerator.cpp:1897
void setTerrain(RuleTerrain *terrain)
Sets the terrain.
Definition: BattlescapeGenerator.cpp:2985
A utility class that generates the initial battlescape data.
Definition: BattlescapeGenerator.h:50
Represents a player base on the globe.
Definition: Base.h:45
Definition: MapScript.h:31
Basic element of which a battle map is build.
Definition: Tile.h:42
void setWorldTexture(Texture *texture)
Sets the polygon texture.
Definition: BattlescapeGenerator.cpp:131
Represents the relations between a Geoscape texture and the corresponding Battlescape mission attribu...
Definition: Texture.h:42
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:47
Definition: MapScript.h:50
Represents an alien UFO on the map.
Definition: Ufo.h:40
The core of the game engine, manages the game&#39;s entire contents and structure.
Definition: Game.h:41
Represents a specific type of Alien Deployment.
Definition: AlienDeployment.h:63
void setBase(Base *base)
Sets the XCom base.
Definition: BattlescapeGenerator.cpp:173
Represents a specific type of Battlescape Terrain.
Definition: RuleTerrain.h:39
void setAlienRace(const std::string &alienRace)
Sets the alien race.
Definition: BattlescapeGenerator.cpp:151
void setCraft(Craft *craft)
Sets the XCom craft.
Definition: BattlescapeGenerator.cpp:111
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
Definition: BaseInfoState.cpp:40
Represents the static data for a unit that is generated on the battlescape, this includes: HWPs...
Definition: Unit.h:57
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:42