Elin Modding Docs Doc
All Classes Namespaces
Props.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6// Token: 0x0200069F RID: 1695
7public class Props : EClass
8{
9 // Token: 0x17000E2F RID: 3631
10 // (get) Token: 0x06003130 RID: 12592 RVA: 0x001138F7 File Offset: 0x00111AF7
11 public virtual bool IsStocked
12 {
13 get
14 {
15 return false;
16 }
17 }
18
19 // Token: 0x17000E30 RID: 3632
20 // (get) Token: 0x06003131 RID: 12593 RVA: 0x001138FA File Offset: 0x00111AFA
21 public virtual bool IsRoaming
22 {
23 get
24 {
25 return false;
26 }
27 }
28
29 // Token: 0x17000E31 RID: 3633
30 // (get) Token: 0x06003132 RID: 12594 RVA: 0x001138FD File Offset: 0x00111AFD
31 public virtual bool IsInstalled
32 {
33 get
34 {
35 return false;
36 }
37 }
38
39 // Token: 0x17000E32 RID: 3634
40 // (get) Token: 0x06003133 RID: 12595 RVA: 0x00113900 File Offset: 0x00111B00
41 public virtual PlaceState state
42 {
43 get
44 {
45 return PlaceState.roaming;
46 }
47 }
48
49 // Token: 0x17000E33 RID: 3635
50 // (get) Token: 0x06003134 RID: 12596 RVA: 0x00113903 File Offset: 0x00111B03
51 public virtual List<Thing> Things
52 {
53 get
54 {
55 return this.things;
56 }
57 }
58
59 // Token: 0x17000E34 RID: 3636
60 // (get) Token: 0x06003135 RID: 12597 RVA: 0x0011390B File Offset: 0x00111B0B
61 public int Count
62 {
63 get
64 {
65 return this.all.Count;
66 }
67 }
68
69 // Token: 0x06003136 RID: 12598 RVA: 0x00113918 File Offset: 0x00111B18
70 public void Init()
71 {
72 if (this.categoryMap.Count > 0)
73 {
74 return;
75 }
76 foreach (SourceCategory.Row row in EClass.sources.categories.rows)
77 {
78 this.categoryMap.Add(row.id, new PropSetCategory
79 {
80 source = row
81 });
82 }
83 foreach (PropSetCategory propSetCategory in this.categoryMap.Values)
84 {
85 if (propSetCategory.source.parent != null)
86 {
87 propSetCategory.parent = this.categoryMap[propSetCategory.source.parent.id];
88 }
89 }
90 }
91
92 // Token: 0x06003137 RID: 12599 RVA: 0x00113A08 File Offset: 0x00111C08
93 public void Add(Card t)
94 {
95 if (t.props != null)
96 {
97 t.props.Remove(t);
98 }
99 t.props = this;
100 t.placeState = this.state;
101 if (t.isChara)
102 {
103 this.raceMap.GetOrCreate(t.Chara.race.id, null).Add(t);
104 return;
105 }
106 foreach (Thing t2 in t.things)
107 {
108 if (t.placeState != PlaceState.roaming)
109 {
110 EClass._map.Stocked.Add(t2);
111 }
112 }
113 if (this.all.Contains(t))
114 {
115 Debug.LogError(((t != null) ? t.ToString() : null) + " alreadin in " + ((this != null) ? this.ToString() : null));
116 return;
117 }
118 this.weight += t.Num;
119 this.all.Add(t);
120 this.things.Add(t.Thing);
121 this.cardMap.GetOrCreate(t.id, null).Add(t);
122 if (t.sourceCard.origin != null)
123 {
124 this.cardMap.GetOrCreate(t.sourceCard.origin.id, null).Add(t);
125 }
126 this.categoryMap[t.category.id].Add(t);
127 if (!t.Thing.source.workTag.IsEmpty())
128 {
129 this.workMap.GetOrCreate(t.Thing.source.workTag, null).Add(t);
130 }
131 if (t.IsContainer)
132 {
133 this.containers.Add(t.Thing);
134 }
135 this.traits.OnAddCard(t);
136 if (t.isDeconstructing)
137 {
138 EClass._map.props.deconstructing.Add(t);
139 }
140 }
141
142 // Token: 0x06003138 RID: 12600 RVA: 0x00113C04 File Offset: 0x00111E04
143 public void Remove(Card t)
144 {
145 t.props = null;
146 t.placeState = PlaceState.roaming;
147 if (t.isChara)
148 {
149 this.raceMap[t.Chara.race.id].Remove(t);
150 return;
151 }
152 foreach (Thing thing in t.things)
153 {
154 if (thing.props != null)
155 {
156 thing.props.Remove(thing);
157 }
158 }
159 if (!this.all.Contains(t))
160 {
161 Debug.LogError(((t != null) ? t.ToString() : null) + " isn't in " + ((this != null) ? this.ToString() : null));
162 return;
163 }
164 this.weight -= t.Num;
165 this.all.Remove(t);
166 this.things.Remove(t.Thing);
167 this.cardMap[t.id].Remove(t);
168 if (t.sourceCard.origin != null)
169 {
170 this.cardMap[t.sourceCard.origin.id].Remove(t);
171 }
172 this.categoryMap[t.category.id].Remove(t);
173 if (!t.Thing.source.workTag.IsEmpty())
174 {
175 this.workMap[t.Thing.source.workTag].Remove(t);
176 }
177 if (t.IsContainer)
178 {
179 this.containers.Remove(t.Thing);
180 }
181 this.traits.OnRemoveCard(t);
182 if (t.isDeconstructing)
183 {
184 EClass._map.props.deconstructing.Remove(t);
185 }
186 }
187
188 // Token: 0x06003139 RID: 12601 RVA: 0x00113DE4 File Offset: 0x00111FE4
189 public void OnNumChange(Card c, int a)
190 {
191 if (c.isChara)
192 {
193 return;
194 }
195 this.weight += a;
196 this.categoryMap[c.category.id].OnChangeNum(a);
197 this.cardMap[c.id].OnChangeNum(a);
198 if (!c.Thing.source.workTag.IsEmpty())
199 {
200 this.workMap[c.Thing.source.workTag].OnChangeNum(a);
201 }
202 }
203
204 // Token: 0x0600313A RID: 12602 RVA: 0x00113E74 File Offset: 0x00112074
205 public Thing GetAvailableThing(string id, int idMat)
206 {
207 PropSet propSet = this.cardMap.TryGetValue(id, null);
208 if (propSet == null)
209 {
210 return null;
211 }
212 foreach (Card card in propSet.Values)
213 {
214 if (card.idMaterial == idMat)
215 {
216 return card as Thing;
217 }
218 }
219 return null;
220 }
221
222 // Token: 0x0600313B RID: 12603 RVA: 0x00113EE8 File Offset: 0x001120E8
223 public ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
224 {
225 Props.<>c__DisplayClass27_0 CS$<>8__locals1 = new Props.<>c__DisplayClass27_0();
226 CS$<>8__locals1.<>4__this = this;
227 string id = ing.id;
228 CS$<>8__locals1.idMat = -1;
229 CS$<>8__locals1.tag = (ing.tag.IsEmpty() ? null : ing.tag);
230 CS$<>8__locals1.stack = new ThingStack
231 {
232 val = CS$<>8__locals1.idMat
233 };
234 Room room = EClass.pc.pos.cell.room;
235 if (ing.useCat)
236 {
237 CS$<>8__locals1.<ListThingStack>g__FindCat|0(id);
238 foreach (string id2 in ing.idOther)
239 {
240 CS$<>8__locals1.<ListThingStack>g__FindCat|0(id2);
241 }
242 return CS$<>8__locals1.stack;
243 }
244 CS$<>8__locals1.<ListThingStack>g__Find|1(id);
245 foreach (string id3 in ing.idOther)
246 {
247 CS$<>8__locals1.<ListThingStack>g__Find|1(id3);
248 }
249 return CS$<>8__locals1.stack;
250 }
251
252 // Token: 0x0600313C RID: 12604 RVA: 0x00114008 File Offset: 0x00112208
253 public List<Thing> ListThingsInCategory(SourceCategory.Row cat)
254 {
255 List<Thing> list = new List<Thing>();
256 foreach (Thing thing in this.Things)
257 {
258 if (thing.category.IsChildOf(cat))
259 {
260 list.Add(thing);
261 }
262 }
263 return list;
264 }
265
266 // Token: 0x0600313D RID: 12605 RVA: 0x00114070 File Offset: 0x00112270
267 public Dictionary<string, ThingStack> ListThingStacksInCategory(SourceCategory.Row cat)
268 {
269 Dictionary<string, ThingStack> dictionary = new Dictionary<string, ThingStack>();
270 foreach (Thing t in this.Things)
271 {
272 this.ListThingStacksInCategory(cat, dictionary, t);
273 }
274 return dictionary;
275 }
276
277 // Token: 0x0600313E RID: 12606 RVA: 0x001140CC File Offset: 0x001122CC
278 private void ListThingStacksInCategory(SourceCategory.Row cat, Dictionary<string, ThingStack> stacks, Thing t)
279 {
280 if (EClass.sources.categories.map[t.source.category].IsChildOf(cat))
281 {
282 ThingStack thingStack = stacks.TryGetValue(t.id, null);
283 if (thingStack == null)
284 {
285 thingStack = new ThingStack();
286 stacks.Add(t.id, thingStack);
287 }
288 thingStack.count += t.Num;
289 thingStack.list.Add(t);
290 }
291 }
292
293 // Token: 0x0600313F RID: 12607 RVA: 0x00114144 File Offset: 0x00112344
294 public Thing Find<T>() where T : Trait
295 {
296 foreach (Thing thing in this.Things)
297 {
298 if (thing.trait is T)
299 {
300 return thing;
301 }
302 }
303 return null;
304 }
305
306 // Token: 0x06003140 RID: 12608 RVA: 0x001141A4 File Offset: 0x001123A4
307 public Thing FindEmptyContainer<T>() where T : Trait
308 {
309 foreach (Thing thing in this.Things)
310 {
311 if (thing.trait is T && !thing.things.IsFull(0))
312 {
313 return thing;
314 }
315 }
316 return null;
317 }
318
319 // Token: 0x06003141 RID: 12609 RVA: 0x00114214 File Offset: 0x00112414
320 public Thing FindEmptyContainer<T>(Thing target) where T : Trait
321 {
322 foreach (Thing thing in this.Things)
323 {
324 if (thing.trait is T && !thing.things.IsFull(target, true, true))
325 {
326 return thing;
327 }
328 }
329 return null;
330 }
331
332 // Token: 0x06003142 RID: 12610 RVA: 0x00114284 File Offset: 0x00112484
333 public Thing Find(int uid)
334 {
335 foreach (Thing thing in this.Things)
336 {
337 if (thing.uid == uid)
338 {
339 return thing;
340 }
341 }
342 return null;
343 }
344
345 // Token: 0x06003143 RID: 12611 RVA: 0x001142E0 File Offset: 0x001124E0
346 public Thing FindShared(string id)
347 {
348 return this.Find(id, -1, -1, true);
349 }
350
351 // Token: 0x06003144 RID: 12612 RVA: 0x001142EC File Offset: 0x001124EC
352 public Thing Find(string id, string idMat)
353 {
354 return this.Find(id, idMat.IsEmpty() ? -1 : EClass.sources.materials.alias[idMat].id, -1, false);
355 }
356
357 // Token: 0x06003145 RID: 12613 RVA: 0x0011431C File Offset: 0x0011251C
358 public Thing Find(string id, int idMat = -1, int refVal = -1, bool shared = false)
359 {
360 PropSet propSet = this.cardMap.TryGetValue(id, null);
361 Dictionary<int, Card>.ValueCollection valueCollection = (propSet != null) ? propSet.Values : null;
362 if (valueCollection != null)
363 {
364 foreach (Card card in valueCollection)
365 {
366 if (shared)
367 {
368 Thing thing = card.parent as Thing;
369 if (thing == null || !thing.IsSharedContainer)
370 {
371 continue;
372 }
373 }
374 if ((idMat == -1 || card.material.id == idMat) && (refVal == -1 || card.refVal == refVal))
375 {
376 return card as Thing;
377 }
378 }
379 }
380 return null;
381 }
382
383 // Token: 0x06003146 RID: 12614 RVA: 0x001143C8 File Offset: 0x001125C8
384 public int GetNum(string id, bool onlyShared = false)
385 {
386 int num = 0;
387 foreach (Card card in this.cardMap.GetOrCreate(id, null).Values)
388 {
389 if (!onlyShared || (card.parentThing != null && card.parentThing.IsSharedContainer))
390 {
391 num += card.Num;
392 }
393 }
394 return num;
395 }
396
397 // Token: 0x06003147 RID: 12615 RVA: 0x00114444 File Offset: 0x00112644
398 public static int GetNumStockedAndRoaming(string id)
399 {
400 return EClass._map.Stocked.cardMap.GetOrCreate(id, null).num + EClass._map.Roaming.GetNum(id, false);
401 }
402
403 // Token: 0x06003148 RID: 12616 RVA: 0x00114474 File Offset: 0x00112674
404 public void Validate()
405 {
406 foreach (KeyValuePair<string, PropSet> keyValuePair in this.cardMap)
407 {
408 int num = 0;
409 foreach (Card card in keyValuePair.Value.Values)
410 {
411 num += card.Num;
412 }
413 if (num != keyValuePair.Value.num)
414 {
415 Debug.LogError(string.Concat(new string[]
416 {
417 "prop num:",
418 keyValuePair.Key,
419 " ",
420 keyValuePair.Value.num.ToString(),
421 "/",
422 num.ToString()
423 }));
424 }
425 }
426 }
427
428 // Token: 0x04001B3E RID: 6974
429 public PropSet all = new PropSet();
430
431 // Token: 0x04001B3F RID: 6975
432 public Dictionary<string, PropSet> cardMap = new Dictionary<string, PropSet>();
433
434 // Token: 0x04001B40 RID: 6976
435 public Dictionary<string, PropSetCategory> categoryMap = new Dictionary<string, PropSetCategory>();
436
437 // Token: 0x04001B41 RID: 6977
438 public Dictionary<string, PropSet> raceMap = new Dictionary<string, PropSet>();
439
440 // Token: 0x04001B42 RID: 6978
441 public Dictionary<string, PropSet> workMap = new Dictionary<string, PropSet>();
442
443 // Token: 0x04001B43 RID: 6979
444 public TraitManager traits = new TraitManager();
445
446 // Token: 0x04001B44 RID: 6980
447 public List<Thing> things = new List<Thing>();
448
449 // Token: 0x04001B45 RID: 6981
450 public List<Thing> containers = new List<Thing>();
451
452 // Token: 0x04001B46 RID: 6982
453 [JsonProperty]
454 public int maxWeight = 100;
455
456 // Token: 0x04001B47 RID: 6983
457 public int weight;
458}
Definition Card.cs:13
Definition Props.cs:8
Definition Room.cs:6
Definition Thing.cs:10
Definition Trait.cs:9