2using System.Collections.Generic;
72 width = owner.c_containerSize / 100;
73 height = owner.c_containerSize % 100;
85 owner.c_containerSize = w * 100 + h;
92 using (Enumerator enumerator = GetEnumerator())
94 while (enumerator.MoveNext())
96 Thing current = enumerator.Current;
113 using (Enumerator enumerator = GetEnumerator())
115 while (enumerator.MoveNext())
117 Thing current = enumerator.Current;
134 if (freeGridIndex == -1)
139 item.invX = freeGridIndex;
151 bool flag = !text.IsEmpty();
152 bool flag2 = !magic.
idCat.IsEmpty();
156 bool flag4 = text !=
null && text.Length >= 2 && (text[0] ==
'@' || text[0] ==
'@');
159 text = text.Substring(1);
161 using (Enumerator enumerator = GetEnumerator())
163 while (enumerator.MoveNext())
165 Thing current = enumerator.Current;
171 text2 = current.
category.GetRoot().id;
174 text2 = current.
category.GetSecondRoot().id;
180 magic.
cats.Add(text2);
181 if (magic.
catCount.ContainsKey(text2))
205 if (!current.
tempName.Contains(text) && !current.
source.GetSearchName(jp:
false).Contains(text) && !current.
source.GetSearchName(jp:
true).Contains(text))
211 if (!flag2 || !(text2 != magic.
idCat))
217 if (flag2 && !magic.
cats.Contains(magic.
idCat))
223 magic.pageMax = (magic.filteredList.Count - 1) /
GridSize;
230 int num = magic.page *
GridSize + i;
244 using (Enumerator enumerator = GetEnumerator())
246 while (enumerator.MoveNext())
248 Thing current = enumerator.Current;
249 if (current.
invY == y && current.
invX == x)
280 if (freeGridIndex != -1)
282 grid[freeGridIndex] = t;
284 t.pos.x = freeGridIndex;
290 return base.Count + threshold >=
GridSize;
329 using (Enumerator enumerator = GetEnumerator())
331 while (enumerator.MoveNext())
333 Thing current = enumerator.Current;
340 if (num >
grid.Count)
349 for (
int i = 0; i <
grid.Count; i++)
363 int num =
grid.IndexOf(t);
373 owner.c_containerSize = w * 100 + h;
379 using Enumerator enumerator = GetEnumerator();
380 while (enumerator.MoveNext())
382 Thing current = enumerator.Current;
391 if ((destInvX == -1 || (current.
invX == destInvX && current.
invY == destInvY)) && current != target && target.
TryStackTo(current))
401 using Enumerator enumerator = GetEnumerator();
402 while (enumerator.MoveNext())
404 Thing current = enumerator.Current;
405 if (current != target && target.
CanStackTo(current))
418 SearchDest(
this, searchEmpty:
true, searchStack:
true);
432 TrySearchContainer(
owner);
438 SearchDest(listContainer, searchEmpty:
false, searchStack:
true);
447 SearchDest(listContainer2, searchEmpty:
true, searchStack:
false);
454 void SearchDest(
ThingContainer things,
bool searchEmpty,
bool searchStack)
458 if (searchStack && tryStack)
469 d.container = things.
owner;
473 void TrySearchContainer(
Card c)
479 TrySearchContainer(thing2);
485 if (windowSaveData !=
null && (!windowSaveData.
noRotten || !t.IsDecayed) && (!windowSaveData.
onlyRottable || t.trait.Decay != 0))
500 foreach (
int cat
in windowSaveData.
cats)
502 if (t.category.uid == cat)
510 if (!windowSaveData.
flag.HasFlag(flag))
519 public bool IsFull(
Thing t,
bool recursive =
true,
bool tryStack =
true)
537 if (!(
item.id !=
id) && (mat ==
null ||
item.material == mat) && (num <= 0 || item.Num + num > 0))
544 if (
item.Num + num >= 0)
553 if (num != 0 && num > 0)
566 this.ForeachReverse(delegate(
Thing t)
568 if (funcExclude ==
null || !funcExclude(t))
576 for (
int i = 0; i <
grid.Count; i++)
585 using (Enumerator enumerator = GetEnumerator())
587 while (enumerator.MoveNext())
589 Thing current = enumerator.Current;
598 if (current.
uid == uid)
609 using (Enumerator enumerator = GetEnumerator())
611 while (enumerator.MoveNext())
613 Thing current = enumerator.Current;
622 if (current.
trait is T)
633 List<Thing> list =
List((
Thing t) => t.
trait is T, onlyAccessible:
true);
638 list.Sort((
Thing a,
Thing b) => func(b) - func(a));
642 public Thing Find(Func<Thing, bool> func,
bool recursive =
true)
644 using (Enumerator enumerator = GetEnumerator())
646 while (enumerator.MoveNext())
648 Thing current = enumerator.Current;
671 public Thing Find(
string id,
int idMat = -1,
int refVal = -1)
673 using (Enumerator enumerator = GetEnumerator())
675 while (enumerator.MoveNext())
677 Thing current = enumerator.Current;
686 if (current.
id ==
id && (idMat == -1 || current.
material.id == idMat) && (refVal == -1 || current.refVal == refVal))
697 List<Thing> list =
new List<Thing>();
698 using (Enumerator enumerator = GetEnumerator())
700 while (enumerator.MoveNext())
702 Thing current = enumerator.Current;
713 list.Sort((
Thing a,
Thing b) => Compare(a) - Compare(b));
715 static int Compare(
Thing a)
717 return a.SelfWeight + (a.isEquipped ? 10000 : 0);
730 using Enumerator enumerator = GetEnumerator();
731 while (enumerator.MoveNext())
733 Thing current = enumerator.Current;
738 if ((refVal == -1 || current.
refVal == refVal) && current.
IsIdentified && (current.
id ==
id || (isOrigin && current.
source._origin ==
id)))
755 using Enumerator enumerator = GetEnumerator();
756 while (enumerator.MoveNext())
758 Thing current = enumerator.Current;
763 if (current.
id ==
id || (isOrigin && current.
source._origin ==
id))
773 using (Enumerator enumerator = GetEnumerator())
775 while (enumerator.MoveNext())
777 Thing current = enumerator.Current;
782 if (current.
id ==
id && (mat ==
null || current.
material == mat))
797 List<Thing> list =
new List<Thing>();
805 using Enumerator enumerator = GetEnumerator();
806 while (enumerator.MoveNext())
808 Thing current = enumerator.Current;
813 if (current.
id ==
id)
815 tempList.Add(current);
820 public List<Thing>
List(Func<Thing, bool> func,
bool onlyAccessible =
false)
822 List<Thing> list =
new List<Thing>();
824 _List(list, func, onlyAccessible);
828 public void _List(List<Thing> tempList, Func<Thing, bool> func,
bool onlyAccessible =
false)
834 using Enumerator enumerator = GetEnumerator();
835 while (enumerator.MoveNext())
837 Thing current = enumerator.Current;
838 current.
things.
_List(tempList, func, onlyAccessible);
841 tempList.Add(current);
848 using Enumerator enumerator = GetEnumerator();
849 while (enumerator.MoveNext())
851 Thing current = enumerator.Current;
858 hash.Add(current.
id);
867 public void Foreach(Action<Thing> action,
bool onlyAccessible =
true)
869 using Enumerator enumerator = GetEnumerator();
870 while (enumerator.MoveNext())
872 Thing current = enumerator.Current;
881 public void Foreach(Func<Thing, bool> action,
bool onlyAccessible =
true)
883 using Enumerator enumerator = GetEnumerator();
884 while (enumerator.MoveNext())
886 Thing current = enumerator.Current;
void Add(Act a, string s="")
ContainerUpgrade c_containerUpgrade
SourceMaterial.Row material
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Thing AddThing(string id, int lv=-1)
Window.SaveData GetWindowSaveData()
bool TryStackTo(Thing to)
Thing Add(string id, int num=1, int lv=1)
SourceCategory.Row category
static SourceManager sources
Dictionary< string, CardRow > map
Thing Find(string id, string idMat)
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void SetOwner(Card owner)
void RefreshGrid(UIMagicChest magic, Window.SaveData data)
void AddFactory(HashSet< string > hash)
void DestroyAll(Func< Thing, bool > funcExclude=null)
ThingStack GetThingStack(string id, ThingStack s, bool isOrigin)
ThingStack GetThingStack(string id)
Thing TryStack(Thing target, int destInvX=-1, int destInvY=-1)
void AddCurrency(Card owner, string id, int a, SourceMaterial.Row mat=null)
List< Thing > ListCurrency(string id)
void _List(List< Thing > tempList, Func< Thing, bool > func, bool onlyAccessible=false)
void ChangeSize(int w, int h)
DestData GetDest(Thing t, bool tryStack=true)
bool IsOccupied(int x, int y)
bool ShouldShowOnGrid(Thing t)
void SetSize(int w, int h)
static List< ThingContainer > _listContainers
void Foreach(Action< Thing > action, bool onlyAccessible=true)
Thing Find(string id, int idMat=-1, int refVal=-1)
static List< Thing > listUnassigned
Thing FindBest< T >(Func< Thing, int > func)
void Foreach(Func< Thing, bool > action, bool onlyAccessible=true)
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
bool IsAlmostFull(int threshold=2)
ThingStack GetThingStack(string id, ThingStack s, bool isOrigin, int refVal=-1)
ThingStack GetThingStack(string id, int refVal=-1)
long GetCurrency(string id, ref long sum, SourceMaterial.Row mat=null)
void _ListCurrency(List< Thing > tempList, string id)
void RefreshGridRecursive()
Thing Find(Func< Thing, bool > func, bool recursive=true)
bool IsFull(Thing t, bool recursive=true, bool tryStack=true)
static Thing Create(string id, int idMat=-1, int lv=-1)
override bool MatchEncSearch(string s)
override string GetName(NameStyle style, int _num=-1)
override bool CanStackTo(Thing to)
virtual bool CanSearchContent
virtual ToggleType ToggleType
virtual bool IsSpecialContainer
virtual bool CanOnlyCarry
Dictionary< string, int > catCount
List< Thing > filteredList
FilterResult IsFilterPass(string text)