forked from OpenXcom/OpenXcom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapScript.h
More file actions
105 lines (98 loc) · 3.67 KB
/
Copy pathMapScript.h
File metadata and controls
105 lines (98 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
/*
* Copyright 2010-2016 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <string>
#include <yaml-cpp/yaml.h>
#include <SDL_video.h>
#include "MapBlock.h"
namespace OpenXcom
{
enum MapDirection {MD_NONE, MD_VERTICAL, MD_HORIZONTAL, MD_BOTH};
struct MCDReplacement { int set, entry;};
struct TunnelData
{
std::map<std::string, MCDReplacement> replacements;
int level;
MCDReplacement *getMCDReplacement(const std::string& type)
{
if (replacements.find(type) == replacements.end())
{
return 0;
}
return &replacements[type];
}
};
enum MapScriptCommand {MSC_UNDEFINED = -1, MSC_ADDBLOCK, MSC_ADDLINE, MSC_ADDCRAFT, MSC_ADDUFO, MSC_DIGTUNNEL, MSC_FILLAREA, MSC_CHECKBLOCK, MSC_REMOVE, MSC_RESIZE};
class MapBlock;
class RuleTerrain;
class MapScript
{
private:
MapScriptCommand _type;
std::vector<SDL_Rect*> _rects;
std::vector<int> _groups, _blocks, _frequencies, _maxUses, _conditionals;
std::vector<int> _groupsTemp, _blocksTemp, _frequenciesTemp, _maxUsesTemp;
int _sizeX, _sizeY, _sizeZ, _executionChances, _executions, _cumulativeFrequency, _label;
MapDirection _direction;
TunnelData *_tunnelData;
std::string _ufoName;
/// Randomly generate a group from within the array.
int getGroupNumber();
/// Randomly generate a block number from within the array.
int getBlockNumber();
public:
MapScript();
~MapScript();
/// Loads information from a ruleset file.
void load(const YAML::Node& node);
/// Initializes all the variables and junk for a mapscript command.
void init();
/// Gets what type of command this is.
MapScriptCommand getType() const {return _type;};
/// Gets the rects, describing the areas this command applies to.
const std::vector<SDL_Rect*> *getRects() const {return &_rects;};
/// Gets the X size for this command.
int getSizeX() const {return _sizeX;};
/// Gets the Y size for this command.
int getSizeY() const {return _sizeY;};
/// Gets the Z size for this command.
int getSizeZ() const {return _sizeZ;};
/// Get the chances of this command executing.
int getChancesOfExecution() const {return _executionChances;};
/// Gets the label for this command.
int getLabel() const {return _label;};
/// Gets how many times this command repeats (1 repeat means 2 executions)
int getExecutions() const {return _executions;};
/// Gets what conditions apply to this command.
const std::vector<int> *getConditionals() const {return &_conditionals;};
/// Gets the groups vector for iteration.
const std::vector<int> *getGroups() const {return &_groups;};
/// Gets the blocks vector for iteration.
const std::vector<int> *getBlocks() const {return &_blocks;};
/// Gets the direction this command goes (for lines and tunnels).
MapDirection getDirection() const {return _direction;};
/// Gets the mcd replacement data for tunnel replacements.
TunnelData *getTunnelData() {return _tunnelData;};
/// Randomly generate a block from within either the array of groups or blocks.
MapBlock *getNextBlock(RuleTerrain *terrain);
/// Gets the UFO's name (for setUFO)
std::string getUFOName() const;
};
}