From e786cf2d7a04b200b00095f871813a8ada96b65a Mon Sep 17 00:00:00 2001 From: William JCM Date: Tue, 3 Aug 2021 20:40:42 +0200 Subject: [PATCH] ResearchTree: add functions to read OS and arch unlocks. Now the set is complete. --- src/ResearchTree/ResearchTree.cpp | 46 +++++++++++++++++++++++++++++++ src/ResearchTree/ResearchTree.h | 2 ++ 2 files changed, 48 insertions(+) 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&;