about summary refs log tree commit diff stats
path: root/.gitignore
Commit message (Collapse)AuthorAgeFilesLines
* Create .gitignoreStar Rauchenberger2023-04-241-0/+1
2'>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
#ifndef TOOLS_UTIL_TSCN_H_
#define TOOLS_UTIL_TSCN_H_

#include <absl/strings/string_view.h>

#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <variant>

namespace com::fourisland::lingo2_archipelago {

struct GodotExtResource {
  std::string type;
  std::string path;
};

struct GodotExtResourceRef {
  std::string id;
};

using GodotInstanceType = std::variant<std::monostate, GodotExtResourceRef>;

class GodotNode {
 public:
  GodotNode(std::string name, GodotInstanceType instance_type)
      : name_(std::move(name)), instance_type_(std::move(instance_type)) {}

  const std::string& GetName() const { return name_; }

  const GodotInstanceType& GetInstanceType() const { return instance_type_; }

  const GodotNode* GetParent() const { return parent_; }
  GodotNode* GetParent() { return parent_; }

  std::string GetPath() const;

  void AddChild(GodotNode& child);

  const GodotNode* GetNode(absl::string_view path) const;
  GodotNode* GetNode(absl::string_view path);

  const std::map<std::string, GodotNode*> GetChildren() const {
    return children_;
  }

 private:
  std::string name_;
  GodotInstanceType instance_type_;

  GodotNode* parent_ = nullptr;
  std::map<std::string, GodotNode*> children_;
};

class GodotScene {
 public:
  virtual const GodotExtResource* GetExtResource(
      const std::string& id) const = 0;
  virtual const GodotNode& GetRoot() const = 0;
};

std::unique_ptr<GodotScene> ReadGodotSceneFromFile(const std::string& path);

}  // namespace com::fourisland::lingo2_archipelago

#endif /* TOOLS_UTIL_TSCN_H_ */