about summary refs log tree commit diff stats
path: root/tools/util/godot_scene.h
blob: 17f3f508edc1189b279fe228d6bbe575e1dba7fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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
#ifndef TOOLS_UTIL_TSCN_H_
#define TOOLS_UTIL_TSCN_H_

#include <map>
#include <memory>
#include <string>
#include <utility>
#include <variant>
#include <vector>

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>;

struct GodotNode {
  std::string name;
  std::string parent;
  GodotInstanceType instance_type;

  std::string GetPath() const;
};

class GodotScene {
 public:
  GodotScene(std::map<std::string, GodotExtResource> ext_resources,
             std::vector<GodotNode> nodes)
      : ext_resources_(std::move(ext_resources)), nodes_(std::move(nodes)) {}

  const GodotExtResource* GetExtResource(const std::string& id) const {
    auto it = ext_resources_.find(id);
    if (it != ext_resources_.end()) {
      return &it->second;
    } else {
      return nullptr;
    }
  }
  const std::vector<GodotNode>& GetNodes() const { return nodes_; }

 private:
  std::map<std::string, GodotExtResource> ext_resources_;
  std::vector<GodotNode> nodes_;
};

GodotScene ReadGodotSceneFromFile(const std::string& path);

}  // namespace com::fourisland::lingo2_archipelago

#endif /* TOOLS_UTIL_TSCN_H_ */
repeated string symbols = 7; repeated Proxy proxies = 8; uint64 required_door = 9; } message Painting { uint64 id = 1; uint64 room_id = 2; string name = 9; string path = 10; string display_name = 4; string orientation = 3; bool move = 6; bool enter_only = 7; bool flipped = 8; uint64 required_door = 5; } message Port { uint64 id = 1; uint64 room_id = 2; string name = 3; string path = 4; string orientation = 5; uint64 required_door = 6; } message Room { uint64 id = 1; uint64 map_id = 8; string name = 2; string display_name = 3; repeated uint64 panels = 4; repeated uint64 paintings = 5; repeated Letter letters = 6; repeated uint64 ports = 7; } message Map { uint64 id = 1; string name = 2; } message AllObjects { repeated Map maps = 7; repeated Room rooms = 1; repeated Door doors = 2; repeated Panel panels = 3; repeated Painting paintings = 4; repeated Port ports = 5; repeated Connection connections = 6; }