11 public virtual bool IsStocked
21 public virtual bool IsRoaming
31 public virtual bool IsInstalled
41 public virtual PlaceState state
45 return PlaceState.roaming;
51 public virtual List<Thing> Things
65 return this.all.Count;
72 if (this.categoryMap.Count > 0)
85 if (propSetCategory.source.parent !=
null)
87 propSetCategory.parent = this.categoryMap[propSetCategory.source.parent.id];
93 public void Add(
Card t)
100 t.placeState = this.state;
103 this.raceMap.GetOrCreate(t.Chara.race.id,
null).Add(t);
106 foreach (
Thing t2
in t.things)
108 if (t.placeState != PlaceState.roaming)
110 EClass._map.Stocked.Add(t2);
113 if (this.all.Contains(t))
115 Debug.LogError(((t !=
null) ? t.ToString() :
null) +
" alreadin in " + ((
this !=
null) ?
this.ToString() :
null));
118 this.weight += t.Num;
120 this.things.Add(t.Thing);
121 this.cardMap.GetOrCreate(t.id,
null).Add(t);
122 if (t.sourceCard.origin !=
null)
124 this.cardMap.GetOrCreate(t.sourceCard.origin.id,
null).Add(t);
126 this.categoryMap[t.category.id].Add(t);
127 if (!t.Thing.source.workTag.IsEmpty())
129 this.workMap.GetOrCreate(t.Thing.source.workTag,
null).Add(t);
133 this.containers.Add(t.Thing);
135 this.traits.OnAddCard(t);
136 if (t.isDeconstructing)
138 EClass._map.props.deconstructing.Add(t);
143 public void Remove(
Card t)
146 t.placeState = PlaceState.roaming;
149 this.raceMap[t.Chara.race.id].Remove(t);
152 foreach (
Thing thing
in t.things)
154 if (thing.props !=
null)
156 thing.props.Remove(thing);
159 if (!this.all.Contains(t))
161 Debug.LogError(((t !=
null) ? t.ToString() :
null) +
" isn't in " + ((
this !=
null) ?
this.ToString() :
null));
164 this.weight -= t.Num;
166 this.things.Remove(t.Thing);
167 this.cardMap[t.id].Remove(t);
168 if (t.sourceCard.origin !=
null)
170 this.cardMap[t.sourceCard.origin.id].Remove(t);
172 this.categoryMap[t.category.id].Remove(t);
173 if (!t.Thing.source.workTag.IsEmpty())
175 this.workMap[t.Thing.source.workTag].Remove(t);
179 this.containers.Remove(t.Thing);
181 this.traits.OnRemoveCard(t);
182 if (t.isDeconstructing)
184 EClass._map.props.deconstructing.Remove(t);
189 public void OnNumChange(
Card c,
int a)
196 this.categoryMap[c.category.id].OnChangeNum(a);
197 this.cardMap[c.id].OnChangeNum(a);
198 if (!c.Thing.source.workTag.IsEmpty())
200 this.workMap[c.Thing.source.workTag].OnChangeNum(a);
205 public Thing GetAvailableThing(
string id,
int idMat)
207 PropSet propSet = this.cardMap.TryGetValue(
id,
null);
212 foreach (
Card card
in propSet.Values)
214 if (card.idMaterial == idMat)
216 return card as
Thing;
225 Props.<>c__DisplayClass27_0 CS$<>8__locals1 =
new Props.<>c__DisplayClass27_0();
226 CS$<>8__locals1.<>4__this =
this;
228 CS$<>8__locals1.idMat = -1;
229 CS$<>8__locals1.tag = (ing.tag.IsEmpty() ?
null : ing.tag);
232 val = CS$<>8__locals1.idMat
237 CS$<>8__locals1.<ListThingStack>g__FindCat|0(id);
238 foreach (
string id2
in ing.idOther)
240 CS$<>8__locals1.<ListThingStack>g__FindCat|0(id2);
242 return CS$<>8__locals1.stack;
244 CS$<>8__locals1.<ListThingStack>g__Find|1(id);
245 foreach (
string id3
in ing.idOther)
247 CS$<>8__locals1.<ListThingStack>g__Find|1(id3);
249 return CS$<>8__locals1.stack;
255 List<Thing> list =
new List<Thing>();
256 foreach (
Thing thing
in this.Things)
258 if (thing.category.IsChildOf(cat))
267 public Dictionary<string, ThingStack> ListThingStacksInCategory(
SourceCategory.
Row cat)
269 Dictionary<string, ThingStack> dictionary =
new Dictionary<string, ThingStack>();
270 foreach (
Thing t
in this.Things)
272 this.ListThingStacksInCategory(cat, dictionary, t);
278 private void ListThingStacksInCategory(
SourceCategory.
Row cat, Dictionary<string, ThingStack> stacks,
Thing t)
280 if (
EClass.sources.categories.map[t.source.category].IsChildOf(cat))
282 ThingStack thingStack = stacks.TryGetValue(t.id,
null);
283 if (thingStack ==
null)
286 stacks.Add(t.id, thingStack);
288 thingStack.count += t.Num;
289 thingStack.list.Add(t);
296 foreach (
Thing thing
in this.Things)
298 if (thing.trait is T)
307 public Thing FindEmptyContainer<T>() where T :
Trait
309 foreach (
Thing thing
in this.Things)
311 if (thing.trait is T && !thing.things.IsFull(0))
322 foreach (
Thing thing
in this.Things)
324 if (thing.trait is T && !thing.things.IsFull(target,
true,
true))
333 public Thing Find(
int uid)
335 foreach (
Thing thing
in this.Things)
337 if (thing.uid == uid)
346 public Thing FindShared(
string id)
348 return this.Find(
id, -1, -1,
true);
352 public Thing Find(
string id,
string idMat)
354 return this.Find(
id, idMat.IsEmpty() ? -1 :
EClass.sources.materials.alias[idMat].id, -1,
false);
358 public Thing Find(
string id,
int idMat = -1,
int refVal = -1,
bool shared =
false)
360 PropSet propSet = this.cardMap.TryGetValue(
id,
null);
361 Dictionary<int, Card>.ValueCollection valueCollection = (propSet !=
null) ? propSet.Values :
null;
362 if (valueCollection !=
null)
364 foreach (
Card card
in valueCollection)
369 if (thing ==
null || !thing.IsSharedContainer)
374 if ((idMat == -1 || card.material.id == idMat) && (refVal == -1 || card.refVal == refVal))
376 return card as
Thing;
384 public int GetNum(
string id,
bool onlyShared =
false)
387 foreach (
Card card
in this.cardMap.GetOrCreate(
id,
null).Values)
389 if (!onlyShared || (card.parentThing !=
null && card.parentThing.IsSharedContainer))
398 public static int GetNumStockedAndRoaming(
string id)
400 return EClass._map.Stocked.cardMap.GetOrCreate(
id,
null).num +
EClass._map.Roaming.GetNum(
id,
false);
404 public void Validate()
406 foreach (KeyValuePair<string, PropSet> keyValuePair
in this.cardMap)
409 foreach (
Card card
in keyValuePair.Value.Values)
413 if (num != keyValuePair.Value.num)
415 Debug.LogError(
string.Concat(
new string[]
420 keyValuePair.Value.num.ToString(),
432 public Dictionary<string, PropSet> cardMap =
new Dictionary<string, PropSet>();
435 public Dictionary<string, PropSetCategory> categoryMap =
new Dictionary<string, PropSetCategory>();
438 public Dictionary<string, PropSet> raceMap =
new Dictionary<string, PropSet>();
441 public Dictionary<string, PropSet> workMap =
new Dictionary<string, PropSet>();
447 public List<Thing> things =
new List<Thing>();
450 public List<Thing> containers =
new List<Thing>();
454 public int maxWeight = 100;