Repository navigation
Expand file tree
/
Copy pathTiledata.cs
More file actions
213 lines (182 loc) · 6.46 KB
/
Copy pathTiledata.cs
File metadata and controls
213 lines (182 loc) · 6.46 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Linq;
using Newtonsoft.Json.Linq;
using System;
namespace BMG
{
public class Tiledata
{
[OnDeserialized]
internal void Prepare(StreamingContext context)
{
foreach (var biome in biomes)
{
List<TileDefault> update = biome.defaults.ToList();
foreach (var def in defaultBiome.defaults)
{
bool ready = false;
foreach (var setting in biome.defaults)
if (def.tile == setting.tile)
{
ready = true; break;
}
if (!ready)
update.Add(def);
}
biome.defaults = update.ToArray();
}
}
public PresetOptions presetOptions { get; set; }
public char[] ignoreTiles { get; set; } = new char[0];
public Tile[] tiles { get; set; }
public Biome[] biomes { get; set; }
public Biome defaultBiome { get; set; }
public Gamemode[] gamemodes { get; set; }
public Dictionary<string, TileDefault[]> metadata { get; set; } = new Dictionary<string, TileDefault[]>();
private Background[] _backgrounds;
public Background[] backgrounds { get => _backgrounds; set { _backgrounds = value; RegisterParameters(value); } }
public AMGBlockManager BackgroundManagerInstance = new AMGBlockManager();
public class Tile
{
public string tileName { get; set; }
public char tileCode { get; set; }
public TileType[] tileTypes { get; set; }
public TileLink tileLinks { get; set; }
}
public class TileTypeBase
{
public TileParts tileParts { get; set; }
public string asset { get; set; }
}
public class TileType : TileTypeBase
{
public string color { get; set; }
public bool detailed { get; set; }
public bool visible { get; set; }
public string other { get; set; }
public int? orderHor { get; set; }
public int? order { get; set; }
public bool tileTransitions { get; set; } = false;
public TileTypeBase[] randomizer { get; set; }
}
public class TileParts
{
public int top { get; set; }
public int mid { get; set; }
public int bot { get; set; }
public int left { get; set; }
public int right { get; set; }
}
public class TileDefault
{
public string tile { get; set; }
public int type { get; set; }
}
public class BackgroundChoice
{
public string name { get; set; }
public Dictionary<string, object> parameters { get; set; }
}
public class Biome
{
public string name { get; set; }
public BackgroundChoice background { get; set; }
public TileDefault[] defaults { get; set; }
}
public Biome GetBiome(int index)
{
if (index <= biomes.Length - 1) return biomes[index];
return defaultBiome;
}
public class TileLink
{
public TileLinkRule[] rules { get; set; }
public bool multipleConditionsCouldApply { get; set; }
public TileLinkDefault defaults { get; set; }
public EdgeCase edgeCase { get; set; }
public string assetFolder { get; set; }
}
public class TileLinkRule
{
public string condition { get; set; }
public int? requiredBiome { get; set; }
public string[] changeBinary { get; set; }
public int? changeTileType { get; set; }
public string changeAsset { get; set; }
public string changeFolder { get; set; }
}
public class TileLinkDefault
{
public int tileType { get; set; }
public string asset { get; set; }
}
public class GamemodeBase
{
public SpecialTile[] specialTiles { get; set; }
public TileDefault[] overrideBiome { get; set; }
public MapMod[] mapModder { get; set; }
}
public class Gamemode : GamemodeBase
{
public string name { get; set; }
public Dictionary<string, GamemodeBase> variants { get; set; }
}
public class SpecialTile
{
public string tile { get; set; }
public int type { get; set; }
public string position { get; set; }
public int drawOrder { get; set; }
}
public class MapMod
{
public string tile { get; set; }
public string position { get; set; }
}
public enum EdgeCase
{
different, copies, mirror
}
public class PresetOptions
{
public int tileTransitionSize { get; set; }
}
public class AMGBlocksParameter
{
public string name { get; set; }
public string type { get; set; }
private object _default;
public object @default
{
get => _default;
set
{
if (value is JObject jObject)
{
if (jObject.ContainsKey("r") && jObject.ContainsKey("g") && jObject.ContainsKey("b"))
jObject.Add("type", "COLOR");
else
throw new ApplicationException("Unknown default parameter type for " + name);
}
_default = value;
}
}
}
public class Background
{
public string name { get; set; }
public IActionBlock blocks { get; set; }
public AMGBlockFunction function;
public AMGBlocksParameter[] parameters { get; set; } = new AMGBlocksParameter[0];
}
private void RegisterParameters(Background[] bgs)
{
foreach (var bg in bgs)
{
bg.function = new AMGBlockFunction(bg.blocks, bg.parameters);
BackgroundManagerInstance.RegisterFunction(bg.name, bg.function);
}
}
}
}