-
Notifications
You must be signed in to change notification settings - Fork 0
/
StaticSourceTemplate.sbncs
154 lines (146 loc) · 8.12 KB
/
StaticSourceTemplate.sbncs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# nullable enable
// <auto-generated/>
using System;
using Godot;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson;
namespace HLNC.Serialization
{
public static partial class NetworkScenesRegister
{
private static Dictionary<byte, string> SCENES_MAP = new Dictionary<byte, string>(){
{{ for scene in ScenesMap }}
{ {{scene.Key}}, "{{scene.Value}}" },
{{ end }}
};
private static Dictionary<string, byte> SCENES_PACK = new Dictionary<string, byte>(){
{{ for scene in ScenesMap }}
{ "{{scene.Value}}", {{scene.Key}} },
{{ end }}
};
/// <summary>
/// A map of every packed scene to a list of paths to its internal network nodes.
/// </summary>
private static Dictionary<string, Dictionary<byte, string>> STATIC_NETWORK_NODE_PATHS_MAP = new Dictionary<string, Dictionary<byte, string>>(){
{{ for scene in StaticNetworkNodesMap }}
{ "{{scene.Key}}", new Dictionary<byte, string>(){
{{ for node in scene.Value }}
{ {{node.Item1}}, "{{node.Item2}}" },
{{ end }}
} },
{{ end }}
};
private static Dictionary<string, Dictionary<string, byte>> STATIC_NETWORK_NODE_PATHS_PACK = new Dictionary<string, Dictionary<string, byte>>(){
{{ for scene in StaticNetworkNodesMap }}
{ "{{scene.Key}}", new Dictionary<string, byte>(){
{{ for node in scene.Value }}
{ "{{node.Item2}}", {{node.Item1}} },
{{ end }}
} },
{{ end }}
};
private static Dictionary<string, Dictionary<string, Dictionary<string, CollectedNetworkProperty>>> PROPERTIES_MAP = new Dictionary<string, Dictionary<string, Dictionary<string, CollectedNetworkProperty>>>(){
{{ for scene in PropertiesMap }}
{{ i = 0 }}
{
"{{scene.Key}}", new Dictionary<string, Dictionary<string, CollectedNetworkProperty>>() {
{{ for node in scene.Value }}
{
"{{node.Key}}", new Dictionary<string, CollectedNetworkProperty>() {
{{ for property in node.Value }}
{ "{{property.Key}}", new CollectedNetworkProperty{
NodePath = "{{node.Key}}",
Name = "{{property.Value.Name}}",
Type = (Variant.Type){{property.Value.Type}},
Subtype = (HLNC.Serialization.VariantSubtype){{property.Value.Subtype}},
Index = {{i++}},
InterestMask = {{property.Value.InterestMask}},
{{ if property.Value.NetworkSerializerClass != "" }}
NetworkSerialize = Callable.From((WorldRunner currentWorld, NetPeer peer, {{property.Value.NetworkSerializerClass}} obj) =>
{
return {{property.Value.NetworkSerializerClass}}.NetworkSerialize(currentWorld, peer, obj) as HLBuffer;
}),
NetworkDeserialize = Callable.From((WorldRunner currentWorld, HLBuffer buffer, {{property.Value.NetworkSerializerClass}} obj) =>
{
return {{property.Value.NetworkSerializerClass}}.NetworkDeserialize(currentWorld, buffer, obj);
}),
{{ end }}
{{ if property.Value.BsonSerializerClass != "" }}
BsonDeserialize = (Variant context, BsonValue doc, GodotObject instance) =>
{
return {{property.Value.BsonSerializerClass}}.BsonDeserialize(context, doc, instance);
},
{{ end }}
}
},
{{ end }}
}
},
{{ end }}
}
},
{{ end }}
};
private static Dictionary<string, Dictionary<string, Dictionary<string, CollectedNetworkFunction>>> FUNCTIONS_MAP = new Dictionary<string, Dictionary<string, Dictionary<string, CollectedNetworkFunction>>>(){
{{ for scene in FunctionsMap }}
{{ i = 0 }}
{
"{{scene.Key}}", new Dictionary<string, Dictionary<string, CollectedNetworkFunction>>() {
{{ for node in scene.Value }}
{
"{{node.Key}}", new Dictionary<string, CollectedNetworkFunction>() {
{{ for function in node.Value }}
{ "{{function.Key}}", new CollectedNetworkFunction{
NodePath = "{{node.Key}}",
Name = "{{function.Value.Name}}",
Index = {{i++}},
Arguments = [
{{ for arg in function.Value.Arguments }}
new VariantType{
Type = Variant.Type.{{arg.Type}},
Subtype = VariantSubtype.{{arg.Subtype}},
},
{{ end }}
],
WithPeer = {{function.Value.WithPeer}},
}
},
{{ end }}
}
},
{{ end }}
}
},
{{ end }}
};
private static Dictionary<string, Dictionary<int, CollectedNetworkFunction>> FUNCTIONS_LOOKUP = new Dictionary<string, Dictionary<int, CollectedNetworkFunction>>(){
{{ for scene in FunctionsMap }}
{{ i = 0 }}
{
"{{scene.Key}}", new Dictionary<int, CollectedNetworkFunction>() {
{{ for node in scene.Value }}
{{ for function in node.Value }}
{ {{i++}}, FUNCTIONS_MAP["{{scene.Key}}"]["{{node.Key}}"]["{{function.Key}}"] },
{{ end }}
{{ end }}
}
},
{{ end }}
};
private static Dictionary<string, Dictionary<int, CollectedNetworkProperty>> PROPERTIES_LOOKUP = new Dictionary<string, Dictionary<int, CollectedNetworkProperty>>(){
{{ for scene in PropertiesMap }}
{{ i = 0 }}
{
"{{scene.Key}}", new Dictionary<int, CollectedNetworkProperty>() {
{{ for node in scene.Value }}
{{ for property in node.Value }}
{ {{i++}}, PROPERTIES_MAP["{{scene.Key}}"]["{{node.Key}}"]["{{property.Key}}"] },
{{ end }}
{{ end }}
}
},
{{ end }}
};
}
}