Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WorldGenConfiguration.cs
Go to the documentation of this file.
1using System.IO;
3using Newtonsoft.Json;
4using Newtonsoft.Json.Linq;
5using Terraria.IO;
6
8
10{
11 private readonly JObject _biomeRoot;
12
13 private readonly JObject _passRoot;
14
15 public WorldGenConfiguration(JObject configurationRoot)
16 : base(configurationRoot)
17 {
18 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
19 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
20 //IL_0026: Expected O, but got Unknown
21 //IL_0032: Unknown result type (might be due to invalid IL or missing references)
22 //IL_0037: Unknown result type (might be due to invalid IL or missing references)
23 //IL_001c: Unknown result type (might be due to invalid IL or missing references)
24 //IL_0045: Expected O, but got Unknown
25 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
26 _003F val = (JObject)configurationRoot["Biomes"];
27 if ((int)val == 0)
28 {
29 val = new JObject();
30 }
31 _biomeRoot = (JObject)val;
32 _003F val2 = (JObject)configurationRoot["Passes"];
33 if ((int)val2 == 0)
34 {
35 val2 = new JObject();
36 }
37 _passRoot = (JObject)val2;
38 }
39
40 public T CreateBiome<T>() where T : MicroBiome, new()
41 {
42 return CreateBiome<T>(typeof(T).Name);
43 }
44
45 public T CreateBiome<T>(string name) where T : MicroBiome, new()
46 {
47 JToken val = default(JToken);
48 if (_biomeRoot.TryGetValue(name, ref val))
49 {
50 return val.ToObject<T>();
51 }
52 return new T();
53 }
54
56 {
57 //IL_001c: Unknown result type (might be due to invalid IL or missing references)
58 //IL_0026: Expected O, but got Unknown
59 //IL_0011: Unknown result type (might be due to invalid IL or missing references)
60 //IL_001b: Expected O, but got Unknown
61 JToken val = default(JToken);
62 if (_passRoot.TryGetValue(name, ref val))
63 {
64 return new GameConfiguration((JObject)val);
65 }
66 return new GameConfiguration(new JObject());
67 }
68
69 public static WorldGenConfiguration FromEmbeddedPath(string path)
70 {
71 using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
72 using StreamReader streamReader = new StreamReader(stream);
73 return new WorldGenConfiguration(JsonConvert.DeserializeObject<JObject>(streamReader.ReadToEnd()));
74 }
75}
static RuntimeAssembly GetExecutingAssembly(ref StackCrawlMark stackMark)
Definition Assembly.cs:198
GameConfiguration(JObject configurationRoot)
GameConfiguration GetPassConfiguration(string name)
static WorldGenConfiguration FromEmbeddedPath(string path)