Elin Decompiled Documentation EA 23.335 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 public override Row CreateRow()
108 {
109 return new Row
110 {
111 id = SourceData.GetInt(0),
112 alias = SourceData.GetString(1),
113 name_JP = SourceData.GetString(2),
114 name = SourceData.GetString(3),
115 sort = SourceData.GetInt(4),
116 idBiome = SourceData.GetString(5),
117 reqHarvest = SourceData.GetStringArray(6),
118 hp = SourceData.GetInt(7),
119 _tileType = SourceData.GetString(8),
120 _idRenderData = SourceData.GetString(9),
121 tiles = SourceData.GetIntArray(10),
122 anime = SourceData.GetIntArray(11),
123 colorMod = SourceData.GetInt(12),
124 value = SourceData.GetInt(13),
125 LV = SourceData.GetInt(14),
126 recipeKey = SourceData.GetStringArray(15),
127 factory = SourceData.GetStringArray(16),
128 components = SourceData.GetStringArray(17),
129 defMat = SourceData.GetString(18),
130 category = SourceData.GetString(19),
131 edge = SourceData.GetInt(20),
132 autotile = SourceData.GetInt(21),
133 autotilePriority = SourceData.GetInt(22),
134 autotileBrightness = SourceData.GetFloat(23),
135 soundFoot = SourceData.GetString(24),
136 tag = SourceData.GetStringArray(25),
137 detail_JP = SourceData.GetString(26),
138 detail = SourceData.GetString(27)
139 };
140 }
141
142 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
143 {
144 return new Row
145 {
146 id = SourceData.GetInt(mapping["id"]),
147 alias = SourceData.GetString(mapping["alias"]),
148 name_JP = SourceData.GetString(mapping["name_JP"]),
149 name = SourceData.GetString(mapping["name"]),
150 sort = SourceData.GetInt(mapping["sort"]),
151 idBiome = SourceData.GetString(mapping["idBiome"]),
152 reqHarvest = SourceData.GetStringArray(mapping["reqHarvest"]),
153 hp = SourceData.GetInt(mapping["hp"]),
154 _tileType = SourceData.GetString(mapping["_tileType"]),
155 _idRenderData = SourceData.GetString(mapping["_idRenderData"]),
156 tiles = SourceData.GetIntArray(mapping["tiles"]),
157 anime = SourceData.GetIntArray(mapping["anime"]),
158 colorMod = SourceData.GetInt(mapping["colorMod"]),
159 value = SourceData.GetInt(mapping["value"]),
160 LV = SourceData.GetInt(mapping["LV"]),
161 recipeKey = SourceData.GetStringArray(mapping["recipeKey"]),
162 factory = SourceData.GetStringArray(mapping["factory"]),
163 components = SourceData.GetStringArray(mapping["components"]),
164 defMat = SourceData.GetString(mapping["defMat"]),
165 category = SourceData.GetString(mapping["category"]),
166 edge = SourceData.GetInt(mapping["edge"]),
167 autotile = SourceData.GetInt(mapping["autotile"]),
168 autotilePriority = SourceData.GetInt(mapping["autotilePriority"]),
169 autotileBrightness = SourceData.GetFloat(mapping["autotileBrightness"]),
170 soundFoot = SourceData.GetString(mapping["soundFoot"]),
171 tag = SourceData.GetStringArray(mapping["tag"]),
172 detail_JP = SourceData.GetString(mapping["detail_JP"]),
173 detail = SourceData.GetString(mapping["detail"])
174 };
175 }
176
177 public override void SetRow(Row r)
178 {
179 map[r.id] = r;
180 }
181
182 public override IReadOnlyDictionary<string, int> GetRowMapping()
183 {
184 return RowMapping;
185 }
186
187 public override IReadOnlyDictionary<string, string> GetTypeMapping()
188 {
189 return TypeMapping;
190 }
191
192 public override void BackupPref()
193 {
194 _rows.Clear();
195 foreach (Row row in rows)
196 {
197 _rows[row.id] = row;
198 }
199 }
200
201 public override void RestorePref()
202 {
203 foreach (Row row in rows)
204 {
205 row.pref = _rows.TryGetValue(row.id)?.pref ?? new SourcePref();
206 }
207 }
208
209 public override void ValidatePref()
210 {
211 foreach (Row row in rows)
212 {
213 row.pref.Validate();
214 }
215 }
216
217 public override void OnAfterImportData()
218 {
219 int num = 0;
220 foreach (Row row in rows)
221 {
222 if (row.sort != 0)
223 {
224 num = row.sort;
225 }
226 row.sort = num;
227 num++;
228 }
229 rows.Sort((Row a, Row b) => a.id - b.id);
230 }
231
232 public override void OnInit()
233 {
234 Cell.decoList = rows;
235 foreach (Row row in rows)
236 {
237 row.Init();
238 }
239 }
240}
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:217
override IReadOnlyDictionary< string, string > GetTypeMapping()
Definition: SourceDeco.cs:187
static readonly IReadOnlyDictionary< string, int > RowMapping
Definition: SourceDeco.cs:41
override void RestorePref()
Definition: SourceDeco.cs:201
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
Definition: SourceDeco.cs:142
override void BackupPref()
Definition: SourceDeco.cs:192
override void SetRow(Row r)
Definition: SourceDeco.cs:177
override void ValidatePref()
Definition: SourceDeco.cs:209
override void OnInit()
Definition: SourceDeco.cs:232
static readonly IReadOnlyDictionary< string, string > TypeMapping
Definition: SourceDeco.cs:73
override IReadOnlyDictionary< string, int > GetRowMapping()
Definition: SourceDeco.cs:182
override Row CreateRow()
Definition: SourceDeco.cs:107
Dictionary< int, Row > _rows
Definition: SourceDeco.cs:105
void Validate()
Definition: SourcePref.cs:363
string alias
Definition: TileRow.cs:12
int id
Definition: TileRow.cs:8
void Init()
Definition: TileRow.cs:16