Elin Decompiled Documentation EA 23.307 Stable
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 override Row CreateRow()
168 {
169 return new Row
170 {
171 id = SourceData.GetString(0),
172 uid = SourceData.GetInt(1),
173 name_JP = SourceData.GetString(2),
174 name = SourceData.GetString(3),
175 _parent = SourceData.GetString(4),
176 recipeCat = SourceData.GetString(5),
177 slot = Core.GetElement(SourceData.GetStr(6)),
178 skill = Core.GetElement(SourceData.GetStr(7)),
179 maxStack = SourceData.GetInt(8),
180 tileDummy = SourceData.GetInt(9),
181 installOne = SourceData.GetBool(10),
182 ignoreBless = SourceData.GetInt(11),
183 tag = SourceData.GetStringArray(12),
184 idThing = SourceData.GetString(13),
185 recycle = SourceData.GetStringArray(14),
186 costSP = SourceData.GetInt(15),
187 gift = SourceData.GetInt(16),
188 deliver = SourceData.GetInt(17),
189 offer = SourceData.GetInt(18),
190 ticket = SourceData.GetInt(19),
191 sortVal = SourceData.GetInt(20),
192 flag = SourceData.GetInt(21)
193 };
194 }
195
196 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
197 {
198 return new Row
199 {
200 id = SourceData.GetString(mapping["id"]),
201 uid = SourceData.GetInt(mapping["uid"]),
202 name_JP = SourceData.GetString(mapping["name_JP"]),
203 name = SourceData.GetString(mapping["name"]),
204 _parent = SourceData.GetString(mapping["_parent"]),
205 recipeCat = SourceData.GetString(mapping["recipeCat"]),
206 slot = Core.GetElement(SourceData.GetStr(mapping["slot"])),
207 skill = Core.GetElement(SourceData.GetStr(mapping["skill"])),
208 maxStack = SourceData.GetInt(mapping["maxStack"]),
209 tileDummy = SourceData.GetInt(mapping["tileDummy"]),
210 installOne = SourceData.GetBool(mapping["installOne"]),
211 ignoreBless = SourceData.GetInt(mapping["ignoreBless"]),
212 tag = SourceData.GetStringArray(mapping["tag"]),
213 idThing = SourceData.GetString(mapping["idThing"]),
214 recycle = SourceData.GetStringArray(mapping["recycle"]),
215 costSP = SourceData.GetInt(mapping["costSP"]),
216 gift = SourceData.GetInt(mapping["gift"]),
217 deliver = SourceData.GetInt(mapping["deliver"]),
218 offer = SourceData.GetInt(mapping["offer"]),
219 ticket = SourceData.GetInt(mapping["ticket"]),
220 sortVal = SourceData.GetInt(mapping["sortVal"]),
221 flag = SourceData.GetInt(mapping["flag"])
222 };
223 }
224
225 public override void SetRow(Row r)
226 {
227 map[r.id] = r;
228 }
229
230 public override IReadOnlyDictionary<string, int> GetRowMapping()
231 {
232 return RowMapping;
233 }
234
235 public override void OnInit()
236 {
237 foreach (Row row in rows)
238 {
239 row.children = new List<Row>();
240 }
241 foreach (Row row2 in rows)
242 {
243 if (!row2._parent.IsEmpty())
244 {
245 (row2.parent = map[row2._parent]).children.Add(row2);
246 }
247 }
248 }
249}
@ gift
Definition: Core.cs:14
static int GetElement(string id)
Definition: Core.cs:744
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()
static readonly IReadOnlyDictionary< string, int > RowMapping
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
override void SetRow(Row r)
override IReadOnlyDictionary< string, int > GetRowMapping()
override void OnInit()
static string[] GetStringArray(int id)
Definition: SourceData.cs:978
static string GetString(int id)
Definition: SourceData.cs:983
static bool GetBool(int id)
Definition: SourceData.cs:953
static int GetInt(int id)
Definition: SourceData.cs:948
static string GetStr(int id, bool useDefault=false)
Definition: SourceData.cs:988
SourceCategory categories