MassBuilderSaveTool/src/ResearchTree/ResearchTree.h

113 lines
3.0 KiB
C++

#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021 Guillaume Jacquemin
//
// This program 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.
//
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#include <unordered_map>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/GrowableArray.h>
#include <Magnum/Magnum.h>
using namespace Corrade;
using namespace Magnum;
class Node {
public:
enum class Type {
Engine,
Gear,
OS,
Module,
Architect,
Tech
};
enum class State {
Unavailable,
Available,
Unlocked
};
Node(Type type, const char* name, UnsignedByte tier, UnsignedByte slots,
const char* description, const char* active_effect, const char* passive_effect);
Node(const Node& other) = delete;
Node& operator=(const Node& other) = delete;
Node(Node&& other) = default;
Node& operator=(Node&& other) = default;
auto type() const -> Type;
auto state() const -> State;
void setState(State state);
auto name() const -> const char*;
auto tier() const -> UnsignedByte;
auto slots() const -> UnsignedByte;
auto description() const -> const char*;
auto activeEffect() const -> const char*;
auto passiveEffect() const -> const char*;
auto children() -> Containers::ArrayView<Node*>;
void addChild(Node& child);
private:
void addParent(Node& parent);
struct NotClickedT {} NotClicked;
void setState(State state, NotClickedT);
Type _type;
State _state;
const char* _name;
UnsignedByte _tier;
UnsignedByte _slots;
const char* _description;
const char* _activeEffect;
const char* _passiveEffect;
Containers::Array<Node*> _parents;
Containers::Array<Node*> _children;
};
class ResearchTree {
public:
void generateEngineTree();
void generateOSTree();
void generateArchTree();
void readEngineUnlocks(Containers::ArrayView<Int> engines, Containers::ArrayView<Int> gears = nullptr);
auto getEngineRootNode() -> Node&;
auto getOSRootNode() -> Node&;
auto getArchRootNode() -> Node&;
private:
using Tree = std::unordered_map<Int, Node>;
Tree _engineNodes;
Tree _osNodes;
Tree _archNodes;
};