Elin Decompiled Documentation EA 23.324 Nightly
Loading...
Searching...
No Matches
SourceCategory.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4public class SourceCategory : SourceDataString<SourceCategory.Row>
5{
6 [Serializable]
7 public class Row : BaseRow
8 {
9 public string id;
10
11 public int uid;
12
13 public string name_JP;
14
15 public string name;
16
17 public string _parent;
18
19 public string recipeCat;
20
21 public int slot;
22
23 public int skill;
24
25 public int maxStack;
26
27 public int tileDummy;
28
29 public bool installOne;
30
31 public int ignoreBless;
32
33 public string[] tag;
34
35 public string idThing;
36
37 public string[] recycle;
38
39 public int costSP;
40
41 public int gift;
42
43 public int deliver;
44
45 public int offer;
46
47 public int ticket;
48
49 public int sortVal;
50
51 public int flag;
52
53 [NonSerialized]
54 public Row parent;
55
56 [NonSerialized]
57 public List<Row> children;
58
59 [NonSerialized]
60 public string name_L;
61
62 public override bool UseAlias => false;
63
64 public override string GetAlias => "n";
65
66 public bool IsChildOf(string id)
67 {
68 return IsChildOf(EClass.sources.categories.map[id]);
69 }
70
71 public bool IsChildOf(Row r)
72 {
73 if (r == this)
74 {
75 return true;
76 }
77 if (parent != null)
78 {
79 return parent.IsChildOf(r);
80 }
81 return false;
82 }
83
84 public bool IsChildOf(int _uid)
85 {
86 if (uid == _uid)
87 {
88 return true;
89 }
90 if (parent != null)
91 {
92 return parent.IsChildOf(_uid);
93 }
94 return false;
95 }
96
97 public bool Contatin(int _uid)
98 {
99 if (uid == _uid)
100 {
101 return true;
102 }
103 foreach (Row child in children)
104 {
105 if (child.Contatin(_uid))
106 {
107 return true;
108 }
109 }
110 return false;
111 }
112
113 public Row GetRoot()
114 {
115 if (parent == null)
116 {
117 return this;
118 }
119 return parent.GetRoot();
120 }
121
123 {
124 if (parent == null || parent.parent == null)
125 {
126 return this;
127 }
128 return parent.GetSecondRoot();
129 }
130
131 public string GetIdThing()
132 {
133 if (!idThing.IsEmpty())
134 {
135 return idThing;
136 }
137 return parent.GetIdThing();
138 }
139 }
140
141 public static readonly IReadOnlyDictionary<string, int> RowMapping = new Dictionary<string, int>
142 {
143 ["id"] = 0,
144 ["uid"] = 1,
145 ["name_JP"] = 2,
146 ["name"] = 3,
147 ["_parent"] = 4,
148 ["recipeCat"] = 5,
149 ["slot"] = 6,
150 ["skill"] = 7,
151 ["maxStack"] = 8,
152 ["tileDummy"] = 9,
153 ["installOne"] = 10,
154 ["ignoreBless"] = 11,
155 ["tag"] = 12,
156 ["idThing"] = 13,
157 ["recycle"] = 14,
158 ["costSP"] = 15,
159 ["gift"] = 16,
160 ["deliver"] = 17,
161 ["offer"] = 18,
162 ["ticket"] = 19,
163 ["sortVal"] = 20,
164 ["flag"] = 21
165 };
166
167 public static readonly IReadOnlyDictionary<string, string> TypeMapping = new Dictionary<string, string>
168 {
169 ["id"] = "string",
170 ["uid"] = "int",
171 ["name_JP"] = "string",
172 ["name"] = "string",
173 ["_parent"] = "string",
174 ["recipeCat"] = "string",
175 ["slot"] = "element_id",
176 ["skill"] = "element_id",
177 ["maxStack"] = "int",
178 ["tileDummy"] = "int",
179 ["installOne"] = "bool",
180 ["ignoreBless"] = "int",
181 ["tag"] = "string[]",
182 ["idThing"] = "string",
183 ["recycle"] = "string[]",
184 ["costSP"] = "int",
185 ["gift"] = "int",
186 ["deliver"] = "int",
187 ["offer"] = "int",
188 ["ticket"] = "int",
189 ["sortVal"] = "int",
190 ["flag"] = "int"
191 };
192
193 public override Row CreateRow()
194 {
195 return new Row
196 {
197 id = SourceData.GetString(0),
198 uid = SourceData.GetInt(1),
199 name_JP = SourceData.GetString(2),
200 name = SourceData.GetString(3),
201 _parent = SourceData.GetString(4),
202 recipeCat = SourceData.GetString(5),
203 slot = Core.GetElement(SourceData.GetStr(6)),
204 skill = Core.GetElement(SourceData.GetStr(7)),
205 maxStack = SourceData.GetInt(8),
206 tileDummy = SourceData.GetInt(9),
207 installOne = SourceData.GetBool(10),
208 ignoreBless = SourceData.GetInt(11),
209 tag = SourceData.GetStringArray(12),
210 idThing = SourceData.GetString(13),
211 recycle = SourceData.GetStringArray(14),
212 costSP = SourceData.GetInt(15),
213 gift = SourceData.GetInt(16),
214 deliver = SourceData.GetInt(17),
215 offer = SourceData.GetInt(18),
216 ticket = SourceData.GetInt(19),
217 sortVal = SourceData.GetInt(20),
218 flag = SourceData.GetInt(21)
219 };
220 }
221
222 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
223 {
224 return new Row
225 {
226 id = SourceData.GetString(mapping["id"]),
227 uid = SourceData.GetInt(mapping["uid"]),
228 name_JP = SourceData.GetString(mapping["name_JP"]),
229 name = SourceData.GetString(mapping["name"]),
230 _parent = SourceData.GetString(mapping["_parent"]),
231 recipeCat = SourceData.GetString(mapping["recipeCat"]),
232 slot = Core.GetElement(SourceData.GetStr(mapping["slot"])),
233 skill = Core.GetElement(SourceData.GetStr(mapping["skill"])),
234 maxStack = SourceData.GetInt(mapping["maxStack"]),
235 tileDummy = SourceData.GetInt(mapping["tileDummy"]),
236 installOne = SourceData.GetBool(mapping["installOne"]),
237 ignoreBless = SourceData.GetInt(mapping["ignoreBless"]),
238 tag = SourceData.GetStringArray(mapping["tag"]),
239 idThing = SourceData.GetString(mapping["idThing"]),
240 recycle = SourceData.GetStringArray(mapping["recycle"]),
241 costSP = SourceData.GetInt(mapping["costSP"]),
242 gift = SourceData.GetInt(mapping["gift"]),
243 deliver = SourceData.GetInt(mapping["deliver"]),
244 offer = SourceData.GetInt(mapping["offer"]),
245 ticket = SourceData.GetInt(mapping["ticket"]),
246 sortVal = SourceData.GetInt(mapping["sortVal"]),
247 flag = SourceData.GetInt(mapping["flag"])
248 };
249 }
250
251 public override void SetRow(Row r)
252 {
253 map[r.id] = r;
254 }
255
256 public override IReadOnlyDictionary<string, int> GetRowMapping()
257 {
258 return RowMapping;
259 }
260
261 public override IReadOnlyDictionary<string, string> GetTypeMapping()
262 {
263 return TypeMapping;
264 }
265
266 public override void OnInit()
267 {
268 foreach (Row row in rows)
269 {
270 row.children = new List<Row>();
271 }
272 foreach (Row row2 in rows)
273 {
274 if (!row2._parent.IsEmpty())
275 {
276 (row2.parent = map[row2._parent]).children.Add(row2);
277 }
278 }
279 }
280}
@ gift
Definition: Core.cs:14
static int GetElement(string id)
Definition: Core.cs:743
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
bool IsChildOf(Row r)
override bool UseAlias
bool IsChildOf(int _uid)
bool Contatin(int _uid)
List< Row > children
bool IsChildOf(string id)
override string GetAlias
override Row CreateRow()
override IReadOnlyDictionary< string, string > GetTypeMapping()
static readonly IReadOnlyDictionary< string, int > RowMapping
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
override void SetRow(Row r)
override IReadOnlyDictionary< string, int > GetRowMapping()
static readonly IReadOnlyDictionary< string, string > TypeMapping
override void OnInit()
static string[] GetStringArray(int id)
Definition: SourceData.cs:1011
static string GetString(int id)
Definition: SourceData.cs:1016
static bool GetBool(int id)
Definition: SourceData.cs:986
static int GetInt(int id)
Definition: SourceData.cs:981
static string GetStr(int id, bool useDefault=false)
Definition: SourceData.cs:1021
SourceCategory categories