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