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;
324 using (Enumerator enumerator = GetEnumerator())
326 while (enumerator.MoveNext())
328 Thing current = enumerator.Current;
335 if (num >
grid.Count)
344 for (
int i = 0; i <
grid.Count; i++)
358 int num =
grid.IndexOf(t);
368 owner.c_containerSize = w * 100 + h;
374 using Enumerator enumerator = GetEnumerator();
375 while (enumerator.MoveNext())
377 Thing current = enumerator.Current;
386 if ((destInvX == -1 || (current.
invX == destInvX && current.
invY == destInvY)) && current != target && target.
TryStackTo(current))
396 using Enumerator enumerator = GetEnumerator();
397 while (enumerator.MoveNext())
399 Thing current = enumerator.Current;
400 if (current != target && target.
CanStackTo(current))
413 SearchDest(
this, searchEmpty:
true, searchStack:
true);
427 TrySearchContainer(
owner);
433 SearchDest(listContainer, searchEmpty:
false, searchStack:
true);
442 SearchDest(listContainer2, searchEmpty:
true, searchStack:
false);
449 void SearchDest(
ThingContainer things,
bool searchEmpty,
bool searchStack)
453 if (searchStack && tryStack)
464 d.container = things.
owner;
468 void TrySearchContainer(
Card c)
474 TrySearchContainer(thing2);
480 if (windowSaveData !=
null && (!windowSaveData.
noRotten || !t.IsDecayed) && (!windowSaveData.
onlyRottable || t.trait.Decay != 0))
495 foreach (
int cat
in windowSaveData.
cats)
497 if (t.category.uid == cat)
505 if (!windowSaveData.
flag.HasFlag(flag))
514 public bool IsFull(
Thing t,
bool recursive =
true,
bool tryStack =
true)
532 if (!(
item.id !=
id) && (mat ==
null ||
item.material == mat) && (num <= 0 || item.Num + num > 0))
539 if (
item.Num + num >= 0)
548 if (num != 0 && num > 0)
561 this.ForeachReverse(delegate(
Thing t)
563 if (funcExclude ==
null || !funcExclude(t))
571 for (
int i = 0; i <
grid.Count; i++)
580 using (Enumerator enumerator = GetEnumerator())
582 while (enumerator.MoveNext())
584 Thing current = enumerator.Current;
593 if (current.
uid == uid)
604 using (Enumerator enumerator = GetEnumerator())
606 while (enumerator.MoveNext())
608 Thing current = enumerator.Current;
617 if (current.
trait is T)
628 List<Thing> list =
List((
Thing t) => t.
trait is T, onlyAccessible:
true);
633 list.Sort((
Thing a,
Thing b) => func(b) - func(a));
637 public Thing Find(Func<Thing, bool> func,
bool recursive =
true)
639 using (Enumerator enumerator = GetEnumerator())
641 while (enumerator.MoveNext())
643 Thing current = enumerator.Current;
666 public Thing Find(
string id,
int idMat = -1,
int refVal = -1)
668 using (Enumerator enumerator = GetEnumerator())
670 while (enumerator.MoveNext())
672 Thing current = enumerator.Current;
681 if (current.
id ==
id && (idMat == -1 || current.
material.id == idMat) && (refVal == -1 || current.refVal == refVal))
692 List<Thing> list =
new List<Thing>();
693 using (Enumerator enumerator = GetEnumerator())
695 while (enumerator.MoveNext())
697 Thing current = enumerator.Current;
708 list.Sort((
Thing a,
Thing b) => Compare(a) - Compare(b));
710 static int Compare(
Thing a)
712 return a.SelfWeight + (a.isEquipped ? 10000 : 0);
725 using Enumerator enumerator = GetEnumerator();
726 while (enumerator.MoveNext())
728 Thing current = enumerator.Current;
733 if ((refVal == -1 || current.
refVal == refVal) && current.
IsIdentified && (current.
id ==
id || (isOrigin && current.
source._origin ==
id)))
750 using Enumerator enumerator = GetEnumerator();
751 while (enumerator.MoveNext())
753 Thing current = enumerator.Current;
758 if (current.
id ==
id || (isOrigin && current.
source._origin ==
id))
768 using (Enumerator enumerator = GetEnumerator())
770 while (enumerator.MoveNext())
772 Thing current = enumerator.Current;
777 if (current.
id ==
id && (mat ==
null || current.
material == mat))
792 List<Thing> list =
new List<Thing>();
800 using Enumerator enumerator = GetEnumerator();
801 while (enumerator.MoveNext())
803 Thing current = enumerator.Current;
808 if (current.
id ==
id)
810 tempList.Add(current);
815 public List<Thing>
List(Func<Thing, bool> func,
bool onlyAccessible =
false)
817 List<Thing> list =
new List<Thing>();
819 _List(list, func, onlyAccessible);
823 public void _List(List<Thing> tempList, Func<Thing, bool> func,
bool onlyAccessible =
false)
829 using Enumerator enumerator = GetEnumerator();
830 while (enumerator.MoveNext())
832 Thing current = enumerator.Current;
833 current.
things.
_List(tempList, func, onlyAccessible);
836 tempList.Add(current);
843 using Enumerator enumerator = GetEnumerator();
844 while (enumerator.MoveNext())
846 Thing current = enumerator.Current;
853 hash.Add(current.
id);
862 public void Foreach(Action<Thing> action,
bool onlyAccessible =
true)
864 using Enumerator enumerator = GetEnumerator();
865 while (enumerator.MoveNext())
867 Thing current = enumerator.Current;
876 public void Foreach(Func<Thing, bool> action,
bool onlyAccessible =
true)
878 using Enumerator enumerator = GetEnumerator();
879 while (enumerator.MoveNext())
881 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)
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)