1 /* 2 * Copyright 2010-2014 OpenXcom Developers. 3 * 4 * This file is part of OpenXcom. 5 * 6 * OpenXcom is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * OpenXcom is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef OPENXCOM_BATTLESCAPEGENERATOR_H 20 #define OPENXCOM_BATTLESCAPEGENERATOR_H 21 22 namespace OpenXcom 23 { 24 25 class SavedBattleGame; 26 class Craft; 27 class Ufo; 28 class RuleTerrain; 29 class ResourcePack; 30 class BattleItem; 31 class MapBlock; 32 class Vehicle; 33 class Tile; 34 class RuleItem; 35 class Unit; 36 class AlienRace; 37 class AlienDeployment; 38 class Game; 39 class Base; 40 class TerrorSite; 41 class AlienBase; 42 class BattleUnit; 43 44 /** 45 * A utility class that generates the initial battlescape data. Taking into account mission type, craft and ufo involved, terrain type,... 46 */ 47 class BattlescapeGenerator 48 { 49 private: 50 Game *_game; 51 SavedBattleGame *_save; 52 ResourcePack *_res; 53 Craft *_craft; 54 Ufo *_ufo; 55 Base *_base; 56 TerrorSite *_terror; 57 AlienBase *_alienBase; 58 RuleTerrain *_terrain; 59 int _mapsize_x, _mapsize_y, _mapsize_z; 60 int _worldTexture, _worldShade; 61 int _unitSequence; 62 Tile *_craftInventoryTile; 63 std::string _alienRace; 64 int _alienItemLevel; 65 bool _allowAutoLoadout, _baseInventory; 66 int _craftX, _craftY, _craftZ; 67 68 /// Generates a new battlescape map. 69 void generateMap(); 70 /// Adds a vehicle to the game. 71 BattleUnit *addXCOMVehicle(Vehicle *v); 72 /// Adds a soldier to the game. 73 BattleUnit *addXCOMUnit(BattleUnit *unit); 74 /// Adds an alien to the game. 75 BattleUnit *addAlien(Unit *rules, int alienRank, bool outside); 76 /// Adds a civlian to the game. 77 BattleUnit *addCivilian(Unit *rules); 78 /// Places an item on a soldier based on equipment layout. 79 bool placeItemByLayout(BattleItem *item); 80 /// Adds an item to a unit and the game. 81 bool addItem(BattleItem *item, BattleUnit *unit, bool allowSecondClip = false); 82 /// Loads an XCom MAP file. 83 int loadMAP(MapBlock *mapblock, int xoff, int yoff, RuleTerrain *terrain, int objectIDOffset, bool discovered = false, bool craft = false); 84 /// Loads an XCom RMP file. 85 void loadRMP(MapBlock *mapblock, int xoff, int yoff, int segment); 86 /// Fills power sources with an elerium-115 object. 87 void fuelPowerSources(); 88 /// Possibly explodes ufo powersources. 89 void explodePowerSources(); 90 /// Deploys the XCOM units on the mission. 91 void deployXCOM(); 92 /// Runs necessary checks before physically setting the position. 93 bool canPlaceXCOMUnit(Tile *tile); 94 /// Deploys the aliens, according to the alien deployment rules. 95 void deployAliens(AlienRace *race, AlienDeployment *deployment); 96 /// Spawns civilians on a terror mission. 97 void deployCivilians(int max); 98 /// Gets battlescape terrain. 99 RuleTerrain *getTerrain(int tex, double lat); 100 public: 101 /// Creates a new BattlescapeGenerator class 102 BattlescapeGenerator(Game *game); 103 /// Cleans up the BattlescapeGenerator. 104 ~BattlescapeGenerator(); 105 /// Sets the XCom craft. 106 void setCraft(Craft *craft); 107 /// Sets the ufo. 108 void setUfo(Ufo* ufo); 109 /// Sets the polygon texture. 110 void setWorldTexture(int texture); 111 /// Sets the polygon shade. 112 void setWorldShade(int shade); 113 /// Sets the alien race. 114 void setAlienRace(const std::string &alienRace); 115 /// Sets the alien item level. 116 void setAlienItemlevel(int alienItemLevel); 117 /// Sets the XCom base. 118 void setBase(Base *base); 119 /// Sets the terror site. 120 void setTerrorSite(TerrorSite* site); 121 /// Sets the alien base 122 void setAlienBase(AlienBase* base); 123 /// Runs the generator. 124 void run(); 125 /// Sets up the next stage (for cydonia/tftd terror missions). 126 void nextStage(); 127 /// Finds a spot near a friend to spawn at. 128 bool placeUnitNearFriend(BattleUnit *unit); 129 /// Generates an inventory battlescape. 130 void runInventory(Craft *craft); 131 /// Load all Xcom weapons. 132 void loadWeapons(); 133 }; 134 135 } 136 137 #endif 138