OpenXcom  1.0
Open-source clone of the original X-Com
MapScript.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 <string>
22 #include <yaml-cpp/yaml.h>
23 #include <SDL_video.h>
24 #include "RuleTerrain.h"
25 #include "MapBlock.h"
26 
27 namespace OpenXcom
28 {
29 
30 enum MapDirection {MD_NONE, MD_VERTICAL, MD_HORIZONTAL, MD_BOTH};
31 struct MCDReplacement { int set, entry;};
32 struct TunnelData
33  {
34  std::map<std::string, MCDReplacement> replacements;
35  int level;
36  MCDReplacement *getMCDReplacement(const std::string& type)
37  {
38  if (replacements.find(type) == replacements.end())
39  {
40  return 0;
41  }
42 
43  return &replacements[type];
44  }
45  };
46 enum MapScriptCommand {MSC_UNDEFINED = -1, MSC_ADDBLOCK, MSC_ADDLINE, MSC_ADDCRAFT, MSC_ADDUFO, MSC_DIGTUNNEL, MSC_FILLAREA, MSC_CHECKBLOCK, MSC_REMOVE, MSC_RESIZE};
47 
48 class MapBlock;
49 class RuleTerrain;
50 
51 class MapScript
52 {
53 private:
54  MapScriptCommand _type;
55  std::vector<SDL_Rect*> _rects;
56  std::vector<int> _groups, _blocks, _frequencies, _maxUses, _conditionals;
57  std::vector<int> _groupsTemp, _blocksTemp, _frequenciesTemp, _maxUsesTemp;
58  int _sizeX, _sizeY, _sizeZ, _executionChances, _executions, _cumulativeFrequency, _label;
59  MapDirection _direction;
60  TunnelData *_tunnelData;
61  std::string _ufoName;
62 
64  int getGroupNumber();
66  int getBlockNumber();
67 public:
68  MapScript();
69  ~MapScript();
71  void load(const YAML::Node& node);
73  void init();
75  MapScriptCommand getType() const {return _type;};
77  const std::vector<SDL_Rect*> *getRects() const {return &_rects;};
79  int getSizeX() const {return _sizeX;};
81  int getSizeY() const {return _sizeY;};
83  int getSizeZ() const {return _sizeZ;};
85  int getChancesOfExecution() const {return _executionChances;};
87  int getLabel() const {return _label;};
89  int getExecutions() const {return _executions;};
91  const std::vector<int> *getConditionals() const {return &_conditionals;};
93  const std::vector<int> *getGroups() const {return &_groups;};
95  const std::vector<int> *getBlocks() const {return &_blocks;};
97  MapDirection getDirection() const {return _direction;};
99  TunnelData *getTunnelData() {return _tunnelData;};
101  MapBlock *getNextBlock(RuleTerrain *terrain);
103  std::string getUFOName() const;
104 };
105 
106 }
int getExecutions() const
Gets how many times this command repeats (1 repeat means 2 executions)
Definition: MapScript.h:89
Represents a Terrain Map Block.
Definition: MapBlock.h:37
const std::vector< SDL_Rect * > * getRects() const
Gets the rects, describing the areas this command applies to.
Definition: MapScript.h:77
MapScriptCommand getType() const
Gets what type of command this is.
Definition: MapScript.h:75
int getSizeX() const
Gets the X size for this command.
Definition: MapScript.h:79
TunnelData * getTunnelData()
Gets the mcd replacement data for tunnel replacements.
Definition: MapScript.h:99
const std::vector< int > * getBlocks() const
Gets the blocks vector for iteration.
Definition: MapScript.h:95
int getSizeY() const
Gets the Y size for this command.
Definition: MapScript.h:81
int getSizeZ() const
Gets the Z size for this command.
Definition: MapScript.h:83
const std::vector< int > * getGroups() const
Gets the groups vector for iteration.
Definition: MapScript.h:93
const std::vector< int > * getConditionals() const
Gets what conditions apply to this command.
Definition: MapScript.h:91
Definition: MapScript.h:31
MapDirection getDirection() const
Gets the direction this command goes (for lines and tunnels).
Definition: MapScript.h:97
Definition: MapScript.h:32
int getLabel() const
Gets the label for this command.
Definition: MapScript.h:87
Definition: MapScript.h:51
int getChancesOfExecution() const
Get the chances of this command executing.
Definition: MapScript.h:85
Represents a specific type of Battlescape Terrain.
Definition: RuleTerrain.h:39
Definition: BaseInfoState.cpp:40