Elin Decompiled Documentation EA 23.306 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 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 Dictionary<int, Row> _rows = new Dictionary<int, Row>();
68
69 public override Row CreateRow()
70 {
71 return new Row
72 {
73 id = SourceData.GetInt(0),
74 alias = SourceData.GetString(1),
75 name_JP = SourceData.GetString(2),
76 name = SourceData.GetString(3),
77 sort = SourceData.GetInt(4),
78 idBiome = SourceData.GetString(5),
79 reqHarvest = SourceData.GetStringArray(6),
80 hp = SourceData.GetInt(7),
81 _tileType = SourceData.GetString(8),
82 _idRenderData = SourceData.GetString(9),
83 tiles = SourceData.GetIntArray(10),
84 anime = SourceData.GetIntArray(11),
85 colorMod = SourceData.GetInt(12),
86 value = SourceData.GetInt(13),
87 LV = SourceData.GetInt(14),
88 recipeKey = SourceData.GetStringArray(15),
89 factory = SourceData.GetStringArray(16),
90 components = SourceData.GetStringArray(17),
91 defMat = SourceData.GetString(18),
92 category = SourceData.GetString(19),
93 edge = SourceData.GetInt(20),
94 autotile = SourceData.GetInt(21),
95 autotilePriority = SourceData.GetInt(22),
96 autotileBrightness = SourceData.GetFloat(23),
97 soundFoot = SourceData.GetString(24),
98 tag = SourceData.GetStringArray(25),
99 detail_JP = SourceData.GetString(26),
100 detail = SourceData.GetString(27)
101 };
102 }
103
104 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
105 {
106 return new Row
107 {
108 id = SourceData.GetInt(mapping["id"]),
109 alias = SourceData.GetString(mapping["alias"]),
110 name_JP = SourceData.GetString(mapping["name_JP"]),
111 name = SourceData.GetString(mapping["name"]),
112 sort = SourceData.GetInt(mapping["sort"]),
113 idBiome = SourceData.GetString(mapping["idBiome"]),
114 reqHarvest = SourceData.GetStringArray(mapping["reqHarvest"]),
115 hp = SourceData.GetInt(mapping["hp"]),
116 _tileType = SourceData.GetString(mapping["_tileType"]),
117 _idRenderData = SourceData.GetString(mapping["_idRenderData"]),
118 tiles = SourceData.GetIntArray(mapping["tiles"]),
119 anime = SourceData.GetIntArray(mapping["anime"]),
120 colorMod = SourceData.GetInt(mapping["colorMod"]),
121 value = SourceData.GetInt(mapping["value"]),
122 LV = SourceData.GetInt(mapping["LV"]),
123 recipeKey = SourceData.GetStringArray(mapping["recipeKey"]),
124 factory = SourceData.GetStringArray(mapping["factory"]),
125 components = SourceData.GetStringArray(mapping["components"]),
126 defMat = SourceData.GetString(mapping["defMat"]),
127 category = SourceData.GetString(mapping["category"]),
128 edge = SourceData.GetInt(mapping["edge"]),
129 autotile = SourceData.GetInt(mapping["autotile"]),
130 autotilePriority = SourceData.GetInt(mapping["autotilePriority"]),
131 autotileBrightness = SourceData.GetFloat(mapping["autotileBrightness"]),
132 soundFoot = SourceData.GetString(mapping["soundFoot"]),
133 tag = SourceData.GetStringArray(mapping["tag"]),
134 detail_JP = SourceData.GetString(mapping["detail_JP"]),
135 detail = SourceData.GetString(mapping["detail"])
136 };
137 }
138
139 public override void SetRow(Row r)
140 {
141 map[r.id] = r;
142 }
143
144 public override IReadOnlyDictionary<string, int> GetRowMapping()
145 {
146 return RowMapping;
147 }
148
149 public override void BackupPref()
150 {
151 _rows.Clear();
152 foreach (Row row in rows)
153 {
154 _rows[row.id] = row;
155 }
156 }
157
158 public override void RestorePref()
159 {
160 foreach (Row row in rows)
161 {
162 row.pref = _rows.TryGetValue(row.id)?.pref ?? new SourcePref();
163 }
164 }
165
166 public override void ValidatePref()
167 {
168 foreach (Row row in rows)
169 {
170 row.pref.Validate();
171 }
172 }
173
174 public override void OnAfterImportData()
175 {
176 int num = 0;
177 foreach (Row row in rows)
178 {
179 if (row.sort != 0)
180 {
181 num = row.sort;
182 }
183 row.sort = num;
184 num++;
185 }
186 rows.Sort((Row a, Row b) => a.id - b.id);
187 }
188
189 public override void OnInit()
190 {
191 Cell.decoList = rows;
192 foreach (Row row in rows)
193 {
194 row.Init();
195 }
196 }
197}
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:963
static string[] GetStringArray(int id)
Definition: SourceData.cs:978
static string GetString(int id)
Definition: SourceData.cs:983
static int GetInt(int id)
Definition: SourceData.cs:948
static int[] GetIntArray(int id)
Definition: SourceData.cs:973
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:174
static readonly IReadOnlyDictionary< string, int > RowMapping
Definition: SourceDeco.cs:35
override void RestorePref()
Definition: SourceDeco.cs:158
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
Definition: SourceDeco.cs:104
override void BackupPref()
Definition: SourceDeco.cs:149
override void SetRow(Row r)
Definition: SourceDeco.cs:139
override void ValidatePref()
Definition: SourceDeco.cs:166
override void OnInit()
Definition: SourceDeco.cs:189
override IReadOnlyDictionary< string, int > GetRowMapping()
Definition: SourceDeco.cs:144
override Row CreateRow()
Definition: SourceDeco.cs:69
Dictionary< int, Row > _rows
Definition: SourceDeco.cs:67
void Validate()
Definition: SourcePref.cs:351
string alias
Definition: TileRow.cs:12
int id
Definition: TileRow.cs:8
void Init()
Definition: TileRow.cs:16