diff --git a/src/ResearchTree/ResearchTree.cpp b/src/ResearchTree/ResearchTree.cpp index bda6279..ed7093f 100644 --- a/src/ResearchTree/ResearchTree.cpp +++ b/src/ResearchTree/ResearchTree.cpp @@ -401,6 +401,52 @@ void ResearchTree::readEngineUnlocks(Containers::ArrayView engines, Contain } } +void ResearchTree::readOSUnlocks(Containers::ArrayView os, Containers::ArrayView modules) { + if(os == nullptr || os.size() == 0) { + Utility::Error{} << "OSes can't be empty"; + return; + } + + for(Int os_id : os) { + if(_osNodes.find(os_id) != _osNodes.end()) { + _osNodes.at(os_id).setState(Node::State::Unlocked); + } + } + + if(modules == nullptr || modules.size() == 0) { + return; + } + + for(Int module : modules) { + if(_osNodes.find(module) != _osNodes.end()) { + _osNodes.at(module).setState(Node::State::Unlocked); + } + } +} + +void ResearchTree::readArchUnlocks(Containers::ArrayView archs, Containers::ArrayView techs) { + if(archs == nullptr || archs.size() == 0) { + Utility::Error{} << "Archs can't be empty"; + return; + } + + for(Int arch : archs) { + if(_archNodes.find(arch) != _archNodes.end()) { + _archNodes.at(arch).setState(Node::State::Unlocked); + } + } + + if(techs == nullptr || techs.size() == 0) { + return; + } + + for(Int tech : techs) { + if(_archNodes.find(tech) != _archNodes.end()) { + _archNodes.at(tech).setState(Node::State::Unlocked); + } + } +} + auto ResearchTree::getEngineRootNode() -> Node& { return _engineNodes.at(VerseEngine); } diff --git a/src/ResearchTree/ResearchTree.h b/src/ResearchTree/ResearchTree.h index 6f488af..2989453 100644 --- a/src/ResearchTree/ResearchTree.h +++ b/src/ResearchTree/ResearchTree.h @@ -99,6 +99,8 @@ class ResearchTree { void generateArchTree(); void readEngineUnlocks(Containers::ArrayView engines, Containers::ArrayView gears = nullptr); + void readOSUnlocks(Containers::ArrayView os, Containers::ArrayView modules = nullptr); + void readArchUnlocks(Containers::ArrayView archs, Containers::ArrayView techs = nullptr); auto getEngineRootNode() -> Node&; auto getOSRootNode() -> Node&;