Elin Decompiled Documentation EA 23.351.2 Nightly
Loading...
Searching...
No Matches
SourceDeco.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4public class SourceDeco : SourceDataInt<SourceDeco.Row>
5{
6 [Serializable]
7 public class Row : TileRow
8 {
9 public string idBiome;
10
11 public string[] reqHarvest;
12
13 public int[] anime;
14
15 public int edge;
16
17 public int autotile;
18
19 public int autotilePriority;
20
21 public float autotileBrightness;
22
23 [NonSerialized]
24 public string name_L;
25
26 [NonSerialized]
27 public string detail_L;
28
29 public override bool UseAlias => true;
30
31 public override string GetAlias => alias;
32
33 public override string RecipeID => "d" + id;
34
35 public override int GetTile(SourceMaterial.Row mat, int dir = 0)
36 {
37 return _tiles[dir % _tiles.Length];
38 }
39 }
40
41 public static readonly IReadOnlyDictionary<string, int> RowMapping = new Dictionary<string, int>
42 {
43 ["id"] = 0,
44 ["alias"] = 1,
45 ["name_JP"] = 2,
46 ["name"] = 3,
47 ["sort"] = 4,
48 ["idBiome"] = 5,
49 ["reqHarvest"] = 6,
50 ["hp"] = 7,
51 ["_tileType"] = 8,
52 ["_idRenderData"] = 9,
53 ["tiles"] = 10,
54 ["anime"] = 11,
55 ["colorMod"] = 12,
56 ["value"] = 13,
57 ["LV"] = 14,
58 ["recipeKey"] = 15,
59 ["factory"] = 16,
60 ["components"] = 17,
61 ["defMat"] = 18,
62 ["category"] = 19,
63 ["edge"] = 20,
64 ["autotile"] = 21,
65 ["autotilePriority"] = 22,
66 ["autotileBrightness"] = 23,
67 ["soundFoot"] = 24,
68 ["tag"] = 25,
69 ["detail_JP"] = 26,
70 ["detail"] = 27
71 };
72
73 public static readonly IReadOnlyDictionary<string, string> TypeMapping = new Dictionary<string, string>
74 {
75 ["id"] = "int",
76 ["alias"] = "string",
77 ["name_JP"] = "string",
78 ["name"] = "string",
79 ["sort"] = "int",
80 ["idBiome"] = "string",
81 ["reqHarvest"] = "string[]",
82 ["hp"] = "int",
83 ["_tileType"] = "string",
84 ["_idRenderData"] = "string",
85 ["tiles"] = "int[]",
86 ["anime"] = "int[]",
87 ["colorMod"] = "int",
88 ["value"] = "int",
89 ["LV"] = "int",
90 ["recipeKey"] = "string[]",
91 ["factory"] = "string[]",
92 ["components"] = "string[]",
93 ["defMat"] = "string",
94 ["category"] = "string",
95 ["edge"] = "int",
96 ["autotile"] = "int",
97 ["autotilePriority"] = "int",
98 ["autotileBrightness"] = "float",
99 ["soundFoot"] = "string",
100 ["tag"] = "string[]",
101 ["detail_JP"] = "string",
102 ["detail"] = "string"
103 };
104
105 public Dictionary<int, Row> _rows = new Dictionary<int, Row>();
106
107 [NonSerialized]
109
111
112 public Row this[int id] => Lookup[id];
113
114 public override Row CreateRow()
115 {
116 return new Row
117 {
118 id = SourceData.GetInt(0),
119 alias = SourceData.GetString(1),
120 name_JP = SourceData.GetString(2),
121 name = SourceData.GetString(3),
122 sort = SourceData.GetInt(4),
123 idBiome = SourceData.GetString(5),
124 reqHarvest = SourceData.GetStringArray(6),
125 hp = SourceData.GetInt(7),
126 _tileType = SourceData.GetString(8),
127 _idRenderData = SourceData.GetString(9),
128 tiles = SourceData.GetIntArray(10),
129 anime = SourceData.GetIntArray(11),
130 colorMod = SourceData.GetInt(12),
131 value = SourceData.GetInt(13),
132 LV = SourceData.GetInt(14),
133 recipeKey = SourceData.GetStringArray(15),
134 factory = SourceData.GetStringArray(16),
135 components = SourceData.GetStringArray(17),
136 defMat = SourceData.GetString(18),
137 category = SourceData.GetString(19),
138 edge = SourceData.GetInt(20),
139 autotile = SourceData.GetInt(21),
140 autotilePriority = SourceData.GetInt(22),
141 autotileBrightness = SourceData.GetFloat(23),
142 soundFoot = SourceData.GetString(24),
143 tag = SourceData.GetStringArray(25),
144 detail_JP = SourceData.GetString(26),
145 detail = SourceData.GetString(27)
146 };
147 }
148
149 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
150 {
151 return new Row
152 {
153 id = SourceData.GetInt(mapping["id"]),
154 alias = SourceData.GetString(mapping["alias"]),
155 name_JP = SourceData.GetString(mapping["name_JP"]),
156 name = SourceData.GetString(mapping["name"]),
157 sort = SourceData.GetInt(mapping["sort"]),
158 idBiome = SourceData.GetString(mapping["idBiome"]),
159 reqHarvest = SourceData.GetStringArray(mapping["reqHarvest"]),
160 hp = SourceData.GetInt(mapping["hp"]),
161 _tileType = SourceData.GetString(mapping["_tileType"]),
162 _idRenderData = SourceData.GetString(mapping["_idRenderData"]),
163 tiles = SourceData.GetIntArray(mapping["tiles"]),
164 anime = SourceData.GetIntArray(mapping["anime"]),
165 colorMod = SourceData.GetInt(mapping["colorMod"]),
166 value = SourceData.GetInt(mapping["value"]),
167 LV = SourceData.GetInt(mapping["LV"]),
168 recipeKey = SourceData.GetStringArray(mapping["recipeKey"]),
169 factory = SourceData.GetStringArray(mapping["factory"]),
170 components = SourceData.GetStringArray(mapping["components"]),
171 defMat = SourceData.GetString(mapping["defMat"]),
172 category = SourceData.GetString(mapping["category"]),
173 edge = SourceData.GetInt(mapping["edge"]),
174 autotile = SourceData.GetInt(mapping["autotile"]),
175 autotilePriority = SourceData.GetInt(mapping["autotilePriority"]),
176 autotileBrightness = SourceData.GetFloat(mapping["autotileBrightness"]),
177 soundFoot = SourceData.GetString(mapping["soundFoot"]),
178 tag = SourceData.GetStringArray(mapping["tag"]),
179 detail_JP = SourceData.GetString(mapping["detail_JP"]),
180 detail = SourceData.GetString(mapping["detail"])
181 };
182 }
183
184 public override void SetRow(Row r)
185 {
186 map[r.id] = r;
187 }
188
189 public override IReadOnlyDictionary<string, int> GetRowMapping()
190 {
191 return RowMapping;
192 }
193
194 public override IReadOnlyDictionary<string, string> GetTypeMapping()
195 {
196 return TypeMapping;
197 }
198
199 public override void BackupPref()
200 {
201 _rows.Clear();
202 foreach (Row row in rows)
203 {
204 _rows[row.id] = row;
205 }
206 }
207
208 public override void RestorePref()
209 {
210 foreach (Row row in rows)
211 {
212 row.pref = _rows.TryGetValue(row.id)?.pref ?? new SourcePref();
213 }
214 }
215
216 public override void ValidatePref()
217 {
218 foreach (Row row in rows)
219 {
220 row.pref.Validate();
221 }
222 }
223
224 public override void OnAfterImportData()
225 {
226 int num = 0;
227 foreach (Row row in rows)
228 {
229 if (row.sort != 0)
230 {
231 num = row.sort;
232 }
233 row.sort = num;
234 num++;
235 }
236 rows.Sort((Row r) => r.id);
237 }
238
239 public override void OnInit()
240 {
241 Lookup.Build();
242 Cell.decoSource = this;
243 Cell.decoList = rows;
244 foreach (Row row in rows)
245 {
246 row.Init();
247 }
248 }
249}
int sort
Definition: RenderRow.cs:18
SourcePref pref
Definition: RenderRow.cs:68
int[] _tiles
Definition: RenderRow.cs:12
static float GetFloat(int id)
Definition: SourceData.cs:996
static string[] GetStringArray(int id)
Definition: SourceData.cs:1011
static string GetString(int id)
Definition: SourceData.cs:1016
static int GetInt(int id)
Definition: SourceData.cs:981
static int[] GetIntArray(int id)
Definition: SourceData.cs:1006
string name_L
Definition: SourceDeco.cs:24
string idBiome
Definition: SourceDeco.cs:9
int autotilePriority
Definition: SourceDeco.cs:19
string[] reqHarvest
Definition: SourceDeco.cs:11
string detail_L
Definition: SourceDeco.cs:27
override string RecipeID
Definition: SourceDeco.cs:33
override string GetAlias
Definition: SourceDeco.cs:31
override bool UseAlias
Definition: SourceDeco.cs:29
override int GetTile(SourceMaterial.Row mat, int dir=0)
Definition: SourceDeco.cs:35
float autotileBrightness
Definition: SourceDeco.cs:21
override void OnAfterImportData()
Definition: SourceDeco.cs:224
override IReadOnlyDictionary< string, string > GetTypeMapping()
Definition: SourceDeco.cs:194
static readonly IReadOnlyDictionary< string, int > RowMapping
Definition: SourceDeco.cs:41
override void RestorePref()
Definition: SourceDeco.cs:208
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
Definition: SourceDeco.cs:149
override void BackupPref()
Definition: SourceDeco.cs:199
override void SetRow(Row r)
Definition: SourceDeco.cs:184
override void ValidatePref()
Definition: SourceDeco.cs:216
override void OnInit()
Definition: SourceDeco.cs:239
TileLookup< Row > _lookup
Definition: SourceDeco.cs:108
TileLookup< Row > Lookup
Definition: SourceDeco.cs:110
static readonly IReadOnlyDictionary< string, string > TypeMapping
Definition: SourceDeco.cs:73
override IReadOnlyDictionary< string, int > GetRowMapping()
Definition: SourceDeco.cs:189
override Row CreateRow()
Definition: SourceDeco.cs:114
Dictionary< int, Row > _rows
Definition: SourceDeco.cs:105
void Validate()
Definition: SourcePref.cs:385
string alias
Definition: TileRow.cs:13
int id
Definition: TileRow.cs:9
void Init()
Definition: TileRow.cs:17