diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Common/GameRules/LevelRuleset.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/Common/GameRules/LevelRuleset.cpp')
| -rw-r--r-- | Minecraft.Client/Common/GameRules/LevelRuleset.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp new file mode 100644 index 00000000..1c7ecd47 --- /dev/null +++ b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp @@ -0,0 +1,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_VAR(it, m_areas.begin()); it != m_areas.end(); ++it) + { + delete *it; + } +} + +void LevelRuleset::getChildren(vector<GameRuleDefinition *> *children) +{ + CompoundGameRuleDefinition::getChildren(children); + for (AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); it++) + children->push_back(*it); +} + +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 = NULL; + for(AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); ++it) + { + if( (*it)->getName().compare(areaName) == 0 ) + { + area = (*it)->getArea(); + break; + } + } + return area; +} |
