blob: 658abe91ff01917c6e2f7e27abe5c97173390974 (
plain)
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
|
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\StringTable.h"
#include "ConsoleGameRules.h"
#include "LevelRuleset.h"
LevelRuleset::LevelRuleset()
{
m_stringTable = NULL;
}
LevelRuleset::~LevelRuleset()
{
for (auto it = m_areas.begin(); it != m_areas.end(); ++it)
{
delete *it;
}
}
void LevelRuleset::getChildren(vector<GameRuleDefinition *> *children)
{
CompoundGameRuleDefinition::getChildren(children);
for (const auto& area : m_areas)
children->push_back(area);
}
GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea)
{
rule = new NamedAreaRuleDefinition();
m_areas.push_back((NamedAreaRuleDefinition *)rule);
}
else
{
rule = CompoundGameRuleDefinition::addChild(ruleType);
}
return rule;
}
void LevelRuleset::loadStringTable(StringTable *table)
{
m_stringTable = table;
}
LPCWSTR LevelRuleset::getString(const wstring &key)
{
if(m_stringTable == NULL)
{
return L"";
}
else
{
return m_stringTable->getString(key);
}
}
AABB *LevelRuleset::getNamedArea(const wstring &areaName)
{
AABB *area = nullptr;
for(auto& it : m_areas)
{
if( it->getName().compare(areaName) == 0 )
{
area = it->getArea();
break;
}
}
return area;
}
|