Elin Decompiled Documentation EA 23.306 Nightly
Loading...
Searching...
No Matches
ThingContainer Class Reference
Inheritance diagram for ThingContainer:
ActPlan.List< Thing >

Classes

struct  DestData
 

Public Member Functions

void SetOwner (Card owner)
 
void ChangeSize (int w, int h)
 
void RefreshGridRecursive ()
 
void RefreshGrid ()
 
void RefreshGrid (UIMagicChest magic, Window.SaveData data)
 
bool IsOccupied (int x, int y)
 
bool ShouldShowOnGrid (Thing t)
 
void OnAdd (Thing t)
 
bool IsAlmostFull (int threshold=2)
 
bool IsFull (int y=0)
 
bool IsOverflowing ()
 
int GetFreeGridIndex ()
 
void OnRemove (Thing t)
 
void SetSize (int w, int h)
 
Thing TryStack (Thing target, int destInvX=-1, int destInvY=-1)
 
Thing CanStack (Thing target, int destInvX=-1, int destInvY=-1)
 
DestData GetDest (Thing t, bool tryStack=true)
 
bool IsFull (Thing t, bool recursive=true, bool tryStack=true)
 
void AddCurrency (Card owner, string id, int a, SourceMaterial.Row mat=null)
 
void DestroyAll (Func< Thing, bool > funcExclude=null)
 
Thing Find (int uid)
 
Thing Find< T > ()
 
Thing FindBest< T > (Func< Thing, int > func)
 
Thing Find (Func< Thing, bool > func, bool recursive=true)
 
Thing Find (string id, string idMat)
 
Thing Find (string id, int idMat=-1, int refVal=-1)
 
Thing FindStealable ()
 
ThingStack GetThingStack (string id, int refVal=-1)
 
ThingStack GetThingStack (string id, ThingStack s, bool isOrigin, int refVal=-1)
 
ThingStack GetThingStack (string id)
 
ThingStack GetThingStack (string id, ThingStack s, bool isOrigin)
 
long GetCurrency (string id, ref long sum, SourceMaterial.Row mat=null)
 
List< ThingListCurrency (string id)
 
List< ThingList (Func< Thing, bool > func, bool onlyAccessible=false)
 
void _List (List< Thing > tempList, Func< Thing, bool > func, bool onlyAccessible=false)
 
void AddFactory (HashSet< string > hash)
 
void Foreach (Action< Thing > action, bool onlyAccessible=true)
 
void Foreach (Func< Thing, bool > action, bool onlyAccessible=true)
 
- Public Member Functions inherited from ActPlan.List< Thing >
void Add (Act a, string s="")
 

Public Attributes

int width
 
int height
 
Card owner
 
List< Thinggrid
 

Static Public Attributes

static List< ThinglistUnassigned = new List<Thing>()
 
const int InvYHotbar = 1
 

Properties

int GridSize [get]
 
bool HasGrid [get]
 
bool IsMagicChest [get]
 
int MaxCapacity [get]
 

Private Member Functions

void _ListCurrency (List< Thing > tempList, string id)
 

Static Private Attributes

static List< ThingContainer_listContainers = new List<ThingContainer>()
 

Detailed Description

Definition at line 6 of file ThingContainer.cs.

Member Function Documentation

◆ _List()

void ThingContainer._List ( List< Thing tempList,
Func< Thing, bool >  func,
bool  onlyAccessible = false 
)
inline

Definition at line 828 of file ThingContainer.cs.

829 {
830 if (onlyAccessible && !owner.trait.CanSearchContent)
831 {
832 return;
833 }
834 using Enumerator enumerator = GetEnumerator();
835 while (enumerator.MoveNext())
836 {
837 Thing current = enumerator.Current;
838 current.things._List(tempList, func, onlyAccessible);
839 if (func(current))
840 {
841 tempList.Add(current);
842 }
843 }
844 }
void Add(Act a, string s="")
Definition: ActPlan.cs:11
Trait trait
Definition: Card.cs:54
ThingContainer things
Definition: Card.cs:39
void _List(List< Thing > tempList, Func< Thing, bool > func, bool onlyAccessible=false)
Definition: Thing.cs:8
virtual bool CanSearchContent
Definition: Trait.cs:230

References _List(), Trait.CanSearchContent, owner, Card.things, and Card.trait.

Referenced by _List(), and List().

◆ _ListCurrency()

void ThingContainer._ListCurrency ( List< Thing tempList,
string  id 
)
inlineprivate

Definition at line 803 of file ThingContainer.cs.

804 {
805 using Enumerator enumerator = GetEnumerator();
806 while (enumerator.MoveNext())
807 {
808 Thing current = enumerator.Current;
809 if (current.CanSearchContents)
810 {
811 current.things._ListCurrency(tempList, id);
812 }
813 if (current.id == id)
814 {
815 tempList.Add(current);
816 }
817 }
818 }
string id
Definition: Card.cs:36
void _ListCurrency(List< Thing > tempList, string id)
bool CanSearchContents
Definition: Thing.cs:98

References _ListCurrency(), Thing.CanSearchContents, Card.id, and Card.things.

Referenced by _ListCurrency(), and ListCurrency().

◆ AddCurrency()

void ThingContainer.AddCurrency ( Card  owner,
string  id,
int  a,
SourceMaterial::Row  mat = null 
)
inline

Definition at line 532 of file ThingContainer.cs.

533 {
534 int num = a;
535 foreach (Thing item in ListCurrency(id))
536 {
537 if (!(item.id != id) && (mat == null || item.material == mat) && (num <= 0 || item.Num + num > 0))
538 {
539 if (num > 0)
540 {
541 item.ModNum(num);
542 return;
543 }
544 if (item.Num + num >= 0)
545 {
546 item.ModNum(num);
547 return;
548 }
549 num += item.Num;
550 item.ModNum(-item.Num);
551 }
552 }
553 if (num != 0 && num > 0)
554 {
555 Thing thing = ThingGen.Create(id);
556 if (mat != null)
557 {
558 thing.ChangeMaterial(mat);
559 }
560 owner.AddThing(thing, tryStack: false).SetNum(num);
561 }
562 }
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3119
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3182
Thing SetNum(int a)
Definition: Card.cs:3579
List< Thing > ListCurrency(string id)
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53

References Card.AddThing(), Card.ChangeMaterial(), ThingGen.Create(), item, ListCurrency(), owner, and Card.SetNum().

Referenced by Card.ModCurrency(), and LayerGachaResult.PlayGacha().

◆ AddFactory()

void ThingContainer.AddFactory ( HashSet< string >  hash)
inline

Definition at line 846 of file ThingContainer.cs.

847 {
848 using Enumerator enumerator = GetEnumerator();
849 while (enumerator.MoveNext())
850 {
851 Thing current = enumerator.Current;
852 if (current.CanSearchContents)
853 {
854 current.things.AddFactory(hash);
855 }
856 if (current.trait.IsFactory)
857 {
858 hash.Add(current.id);
859 }
860 if (current.trait.ToggleType == ToggleType.Fire && current.isOn)
861 {
862 hash.Add("fire");
863 }
864 }
865 }
ToggleType
Definition: ToggleType.cs:2
bool isOn
Definition: Card.cs:545
void AddFactory(HashSet< string > hash)
virtual bool IsFactory
Definition: Trait.cs:143
virtual ToggleType ToggleType
Definition: Trait.cs:482

References AddFactory(), Thing.CanSearchContents, Card.id, Trait.IsFactory, Card.isOn, Card.things, Trait.ToggleType, and Card.trait.

Referenced by AddFactory(), and RecipeUpdater.RunRecipe().

◆ CanStack()

Thing ThingContainer.CanStack ( Thing  target,
int  destInvX = -1,
int  destInvY = -1 
)
inline

Definition at line 399 of file ThingContainer.cs.

400 {
401 using Enumerator enumerator = GetEnumerator();
402 while (enumerator.MoveNext())
403 {
404 Thing current = enumerator.Current;
405 if (current != target && target.CanStackTo(current))
406 {
407 return current;
408 }
409 }
410 return target;
411 }
override bool CanStackTo(Thing to)
Definition: Thing.cs:1677

References Thing.CanStackTo().

Referenced by GetDest(), IsFull(), InvOwner.OnShiftClick(), and Zone.TryAddThingInSharedContainer().

◆ ChangeSize()

void ThingContainer.ChangeSize ( int  w,
int  h 
)
inline

Definition at line 81 of file ThingContainer.cs.

82 {
83 width = w;
84 height = h;
85 owner.c_containerSize = w * 100 + h;
87 Debug.Log(base.Count + "/" + width + "/" + height + "/" + GridSize);
88 }

References Debug, GridSize, height, RefreshGrid(), and width.

◆ DestroyAll()

void ThingContainer.DestroyAll ( Func< Thing, bool >  funcExclude = null)
inline

Definition at line 564 of file ThingContainer.cs.

565 {
566 this.ForeachReverse(delegate(Thing t)
567 {
568 if (funcExclude == null || !funcExclude(t))
569 {
570 t.Destroy();
571 Remove(t);
572 }
573 });
574 if (grid != null)
575 {
576 for (int i = 0; i < grid.Count; i++)
577 {
578 grid[i] = null;
579 }
580 }
581 }
void Destroy()
Definition: Card.cs:5198
List< Thing > grid

References Card.Destroy(), and grid.

Referenced by ThingGen.CreateCardboardBox(), ThingGen.CreateTreasureContent(), Player.DropReward(), DNA.GenerateManiGene(), TraitFoodEggFertilized.Incubate(), Trait.OnBarter(), Player.OnCreateGame(), QuestFiamaLock.OnStart(), Player.OnStartNewGame(), TraitContainer.Open(), DramaOutcome.QuestDefense_0(), SerializedCards.Restore(), Chara.ScaleByPrincipal(), and Zone.SpawnLostItems().

◆ Find() [1/4]

Thing ThingContainer.Find ( Func< Thing, bool >  func,
bool  recursive = true 
)
inline

Definition at line 642 of file ThingContainer.cs.

643 {
644 using (Enumerator enumerator = GetEnumerator())
645 {
646 while (enumerator.MoveNext())
647 {
648 Thing current = enumerator.Current;
649 if (recursive && current.CanSearchContents)
650 {
651 Thing thing = current.things.Find(func);
652 if (thing != null)
653 {
654 return thing;
655 }
656 }
657 if (func(current))
658 {
659 return current;
660 }
661 }
662 }
663 return null;
664 }
Thing Find(int uid)

References Thing.CanSearchContents, Find(), and Card.things.

◆ Find() [2/4]

Thing ThingContainer.Find ( int  uid)
inline

Definition at line 583 of file ThingContainer.cs.

584 {
585 using (Enumerator enumerator = GetEnumerator())
586 {
587 while (enumerator.MoveNext())
588 {
589 Thing current = enumerator.Current;
590 if (current.CanSearchContents)
591 {
592 Thing thing = current.things.Find(uid);
593 if (thing != null)
594 {
595 return thing;
596 }
597 }
598 if (current.uid == uid)
599 {
600 return current;
601 }
602 }
603 }
604 return null;
605 }
int uid
Definition: Card.cs:125

References Thing.CanSearchContents, Find(), Card.things, and Card.uid.

Referenced by AM_Adv._OnUpdateInput(), TraitGodStatue._OnUse(), DropdownGrid.BuildIngredients(), QuestCraft.CanDeliverToClient(), ActBloodsuck.CanPerform(), ActNTR.CanPerform(), QuestLoytelFarm.CanUpdateOnTalk(), DramaOutcome.chara_hired_ticket(), DramaOutcome.check_sketch(), LayerInventory.CreateBuy(), FactionBranch.DailyOutcome(), Chara.Die(), DramaOutcome.duponne_capture(), Find(), Find< T >(), Chara.FindAmmo(), Card.FindTool< T >(), AI_Fuck.Finish(), CoreDebug.Fix_LostCore(), DramaOutcome.give_sketch_special(), Chara.GiveGift(), DramaOutcome.guild_mageTrial(), Chara.MakeGrave(), Trait.OnBarter(), QuestNasu.OnComplete(), ShopTransaction.OnEndTransaction(), ConSleep.OnRemoved(), ConWrath.OnRemoved(), HotItemActionSleep.Perform(), HotItemEQSet.Perform(), LayerGacha.PlayGacha(), CoreDebug.QuickStart(), UIRecipeInfo.Refresh(), LayerQuestBoard.RefreshHire(), Recipe.Ingredient.RefreshThing(), Card.RemoveBacker(), Card.RemoveThing(), AI_Churyu.Run(), AI_Idle.Run(), AI_PlayMusic.Run(), HitSummary.SetRecipe(), ConSleep.SuccubusVisit(), Player.TryEquipBait(), Zone.TryGetRestock< T >(), Zone.TryGetThingFromSharedContainer(), ActPray.TryPray(), and TraitToolTorch.TrySetHeldAct().

◆ Find() [3/4]

Thing ThingContainer.Find ( string  id,
int  idMat = -1,
int  refVal = -1 
)
inline

Definition at line 671 of file ThingContainer.cs.

672 {
673 using (Enumerator enumerator = GetEnumerator())
674 {
675 while (enumerator.MoveNext())
676 {
677 Thing current = enumerator.Current;
678 if (current.CanSearchContents)
679 {
680 Thing thing = current.things.Find(id, idMat, refVal);
681 if (thing != null)
682 {
683 return thing;
684 }
685 }
686 if (current.id == id && (idMat == -1 || current.material.id == idMat) && (refVal == -1 || current.refVal == refVal))
687 {
688 return current;
689 }
690 }
691 }
692 return null;
693 }
SourceMaterial.Row material
Definition: Card.cs:2091

References Thing.CanSearchContents, Find(), Card.id, Card.material, and Card.things.

◆ Find() [4/4]

Thing ThingContainer.Find ( string  id,
string  idMat 
)
inline

Definition at line 666 of file ThingContainer.cs.

667 {
668 return Find(id, idMat.IsEmpty() ? (-1) : EClass.sources.materials.alias[idMat].id);
669 }
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
SourceMaterial materials

References Find(), SourceManager.materials, and EClass.sources.

◆ Find< T >()

Thing ThingContainer.Find< T > ( )
inline
Type Constraints
T :Trait 

Definition at line 607 of file ThingContainer.cs.

607 : Trait
608 {
609 using (Enumerator enumerator = GetEnumerator())
610 {
611 while (enumerator.MoveNext())
612 {
613 Thing current = enumerator.Current;
614 if (current.CanSearchContents)
615 {
616 Thing thing = current.things.Find<T>();
617 if (thing != null)
618 {
619 return thing;
620 }
621 }
622 if (current.trait is T)
623 {
624 return current;
625 }
626 }
627 }
628 return null;
629 }
Definition: Trait.cs:7

References Thing.CanSearchContents, Find(), Card.things, and Card.trait.

◆ FindBest< T >()

Thing ThingContainer.FindBest< T > ( Func< Thing, int >  func)
inline
Type Constraints
T :Trait 

Definition at line 631 of file ThingContainer.cs.

631 : Trait
632 {
633 List<Thing> list = List((Thing t) => t.trait is T, onlyAccessible: true);
634 if (list.Count == 0)
635 {
636 return null;
637 }
638 list.Sort((Thing a, Thing b) => func(b) - func(a));
639 return list[0];
640 }
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)

References List(), and Card.trait.

◆ FindStealable()

Thing ThingContainer.FindStealable ( )
inline

Definition at line 695 of file ThingContainer.cs.

696 {
697 List<Thing> list = new List<Thing>();
698 using (Enumerator enumerator = GetEnumerator())
699 {
700 while (enumerator.MoveNext())
701 {
702 Thing current = enumerator.Current;
703 if (!current.IsContainer && current.trait.CanBeStolen && !current.HasTag(CTAG.gift) && (!current.IsEquipmentOrRangedOrAmmo || !current.IsUnique))
704 {
705 list.Add(current);
706 }
707 }
708 }
709 if (list.Count == 0)
710 {
711 return null;
712 }
713 list.Sort((Thing a, Thing b) => Compare(a) - Compare(b));
714 return list[0];
715 static int Compare(Thing a)
716 {
717 return a.SelfWeight + (a.isEquipped ? 10000 : 0);
718 }
719 }
CTAG
Definition: CTAG.cs:2
bool IsUnique
Definition: Card.cs:2131
bool HasTag(CTAG tag)
Definition: Card.cs:2637
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3159
bool IsContainer
Definition: Card.cs:2129
virtual bool CanBeStolen
Definition: Trait.cs:294

References Card.Add(), Trait.CanBeStolen, Card.HasTag(), Card.IsContainer, Card.IsUnique, and Card.trait.

Referenced by AI_Steal.Run().

◆ Foreach() [1/2]

void ThingContainer.Foreach ( Action< Thing action,
bool  onlyAccessible = true 
)
inline

Definition at line 867 of file ThingContainer.cs.

868 {
869 using Enumerator enumerator = GetEnumerator();
870 while (enumerator.MoveNext())
871 {
872 Thing current = enumerator.Current;
873 if (!onlyAccessible || current.CanSearchContents)
874 {
875 current.things.Foreach(action);
876 }
877 action(current);
878 }
879 }
void Foreach(Action< Thing > action, bool onlyAccessible=true)

References Thing.CanSearchContents, Foreach(), and Card.things.

Referenced by BuildMenu._Search(), Card.AddThing(), DramaCustomSequence.Build(), Foreach(), BaseTaskHarvest.GetBestTool(), Props.ListThingStack(), TaskDump.ListThingsToPut(), ZoneEventHarvest.OnLeaveZone(), Player.OnLoad(), RecipeManager.OnVersionUpdate(), BuildMenu.RefreshCategory(), Chara.Revive(), CoreDebug.Rust(), WidgetSearch.Search(), Trait.TryRefuel(), LayerInventory.TryShowGuide(), and GoalAutoCombat.TryUseRanged().

◆ Foreach() [2/2]

void ThingContainer.Foreach ( Func< Thing, bool >  action,
bool  onlyAccessible = true 
)
inline

Definition at line 881 of file ThingContainer.cs.

882 {
883 using Enumerator enumerator = GetEnumerator();
884 while (enumerator.MoveNext())
885 {
886 Thing current = enumerator.Current;
887 if (!onlyAccessible || current.CanSearchContents)
888 {
889 current.things.Foreach(action);
890 }
891 if (action(current))
892 {
893 break;
894 }
895 }
896 }

References Thing.CanSearchContents, Foreach(), and Card.things.

◆ GetCurrency()

long ThingContainer.GetCurrency ( string  id,
ref long  sum,
SourceMaterial::Row  mat = null 
)
inline

Definition at line 771 of file ThingContainer.cs.

772 {
773 using (Enumerator enumerator = GetEnumerator())
774 {
775 while (enumerator.MoveNext())
776 {
777 Thing current = enumerator.Current;
778 if (current.CanSearchContents)
779 {
780 current.things.GetCurrency(id, ref sum, mat);
781 }
782 if (current.id == id && (mat == null || current.material == mat))
783 {
784 sum += current.Num;
785 }
786 }
787 }
788 if (sum < 0)
789 {
790 sum = 2147483647L;
791 }
792 return sum;
793 }
int Num
Definition: Card.cs:161
long GetCurrency(string id, ref long sum, SourceMaterial.Row mat=null)

References Thing.CanSearchContents, GetCurrency(), Card.id, Card.material, Card.Num, and Card.things.

Referenced by GetCurrency(), and Card.GetCurrency().

◆ GetDest()

DestData ThingContainer.GetDest ( Thing  t,
bool  tryStack = true 
)
inline

Definition at line 413 of file ThingContainer.cs.

414 {
415 DestData d = default(DestData);
416 if (!owner.IsPC)
417 {
418 SearchDest(this, searchEmpty: true, searchStack: true);
419 return d;
420 }
421 if (t.trait.CanOnlyCarry && IsFull())
422 {
423 return d;
424 }
425 ContainerFlag flag = t.category.GetRoot().id.ToEnum<ContainerFlag>();
426 if (flag == ContainerFlag.none)
427 {
428 flag = ContainerFlag.other;
429 }
430 _listContainers.Clear();
431 _listContainers.Add(this);
432 TrySearchContainer(owner);
433 _listContainers.Sort((ThingContainer a, ThingContainer b) => (b.owner.GetWindowSaveData()?.priority ?? 0) * 10 + (b.owner.IsPC ? 1 : 0) - ((a.owner.GetWindowSaveData()?.priority ?? 0) * 10 + (a.owner.IsPC ? 1 : 0)));
434 if (tryStack)
435 {
436 foreach (ThingContainer listContainer in _listContainers)
437 {
438 SearchDest(listContainer, searchEmpty: false, searchStack: true);
439 if (d.IsValid)
440 {
441 return d;
442 }
443 }
444 }
445 foreach (ThingContainer listContainer2 in _listContainers)
446 {
447 SearchDest(listContainer2, searchEmpty: true, searchStack: false);
448 if (d.IsValid)
449 {
450 return d;
451 }
452 }
453 return d;
454 void SearchDest(ThingContainer things, bool searchEmpty, bool searchStack)
455 {
456 if (!t.IsContainer || t.things.Count <= 0 || !things.owner.IsContainer || things.owner.trait is TraitToolBelt)
457 {
458 if (searchStack && tryStack)
459 {
460 Thing thing = things.CanStack(t);
461 if (thing != t)
462 {
463 d.stack = thing;
464 return;
465 }
466 }
467 if (searchEmpty && !things.IsFull() && !(things.owner.trait is TraitToolBelt) && (things.owner.isChara || things.owner.parent is Chara || (things.owner.parent as Thing)?.trait is TraitToolBelt))
468 {
469 d.container = things.owner;
470 }
471 }
472 }
473 void TrySearchContainer(Card c)
474 {
475 foreach (Thing thing2 in c.things)
476 {
477 if (thing2.CanSearchContents)
478 {
479 TrySearchContainer(thing2);
480 }
481 }
482 if (c.things != this)
483 {
484 Window.SaveData windowSaveData = c.GetWindowSaveData();
485 if (windowSaveData != null && (!windowSaveData.noRotten || !t.IsDecayed) && (!windowSaveData.onlyRottable || t.trait.Decay != 0))
486 {
487 if (windowSaveData.userFilter)
488 {
489 switch (windowSaveData.IsFilterPass(t.GetName(NameStyle.Full, 1)))
490 {
491 case Window.SaveData.FilterResult.Block:
492 return;
493 case Window.SaveData.FilterResult.PassWithoutFurtherTest:
494 _listContainers.Add(c.things);
495 return;
496 }
497 }
498 if (windowSaveData.advDistribution)
499 {
500 foreach (int cat in windowSaveData.cats)
501 {
502 if (t.category.uid == cat)
503 {
504 _listContainers.Add(c.things);
505 break;
506 }
507 }
508 return;
509 }
510 if (!windowSaveData.flag.HasFlag(flag))
511 {
512 _listContainers.Add(c.things);
513 }
514 }
515 }
516 }
517 }
ContainerFlag
Definition: ContainerFlag.cs:5
NameStyle
Definition: NameStyle.cs:2
Definition: Card.cs:11
bool IsDecayed
Definition: Card.cs:2329
ICardParent parent
Definition: Card.cs:56
Window.SaveData GetWindowSaveData()
Definition: Card.cs:2558
virtual bool IsPC
Definition: Card.cs:2185
virtual bool isChara
Definition: Card.cs:2123
SourceCategory.Row category
Definition: Card.cs:2089
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:505
static List< ThingContainer > _listContainers
Thing CanStack(Thing target, int destInvX=-1, int destInvY=-1)
bool IsFull(int y=0)
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:532
virtual int Decay
Definition: Trait.cs:123
virtual bool CanOnlyCarry
Definition: Trait.cs:305
FilterResult IsFilterPass(string text)
Definition: Window.cs:498
ContainerFlag flag
Definition: Window.cs:267
HashSet< int > cats
Definition: Window.cs:119
bool userFilter
Definition: Window.cs:132
bool noRotten
Definition: Window.cs:439
bool onlyRottable
Definition: Window.cs:451
bool advDistribution
Definition: Window.cs:427
Definition: Window.cs:13

References _listContainers, Window.SaveData.advDistribution, Trait.CanOnlyCarry, Thing.CanSearchContents, CanStack(), Card.category, Window.SaveData.cats, Window.SaveData.flag, Card.GetWindowSaveData(), Card.isChara, Card.IsContainer, Window.SaveData.IsFilterPass(), IsFull(), Card.IsPC, ThingContainer.DestData.IsValid, Window.SaveData.noRotten, Window.SaveData.onlyRottable, owner, Card.parent, Card.things, Card.trait, Chara.trait, and Window.SaveData.userFilter.

Referenced by IsFull(), and Card.TryStack().

◆ GetFreeGridIndex()

int ThingContainer.GetFreeGridIndex ( )
inline

Definition at line 347 of file ThingContainer.cs.

348 {
349 for (int i = 0; i < grid.Count; i++)
350 {
351 if (grid[i] == null)
352 {
353 return i;
354 }
355 }
356 return -1;
357 }

References grid.

Referenced by IsFull(), OnAdd(), and RefreshGrid().

◆ GetThingStack() [1/4]

ThingStack ThingContainer.GetThingStack ( string  id)
inline

Definition at line 746 of file ThingContainer.cs.

747 {
748 ThingStack s = new ThingStack();
749 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
750 return GetThingStack(id, s, isOrigin);
751 }
Dictionary< string, CardRow > map
Definition: SourceCard.cs:9
SourceCard cards
ThingStack GetThingStack(string id, int refVal=-1)

References SourceManager.cards, GetThingStack(), SourceCard.map, and EClass.sources.

◆ GetThingStack() [2/4]

ThingStack ThingContainer.GetThingStack ( string  id,
int  refVal = -1 
)
inline

Definition at line 721 of file ThingContainer.cs.

722 {
723 ThingStack s = new ThingStack();
724 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
725 return GetThingStack(id, s, isOrigin, refVal);
726 }

References SourceManager.cards, GetThingStack(), SourceCard.map, and EClass.sources.

Referenced by GetThingStack(), UIRecipeInfo.Refresh(), and ButtonGrid.RefreshCraftable().

◆ GetThingStack() [3/4]

ThingStack ThingContainer.GetThingStack ( string  id,
ThingStack  s,
bool  isOrigin 
)
inline

Definition at line 753 of file ThingContainer.cs.

754 {
755 using Enumerator enumerator = GetEnumerator();
756 while (enumerator.MoveNext())
757 {
758 Thing current = enumerator.Current;
759 if (current.CanSearchContents)
760 {
761 current.things.GetThingStack(id, s, isOrigin);
762 }
763 if (current.id == id || (isOrigin && current.source._origin == id))
764 {
765 s.Add(current);
766 }
767 }
768 return s;
769 }
void Add(Thing t)
Definition: ThingStack.cs:13
SourceThing.Row source
Definition: Thing.cs:11

References ThingStack.Add(), Thing.CanSearchContents, GetThingStack(), Card.id, Thing.source, and Card.things.

◆ GetThingStack() [4/4]

ThingStack ThingContainer.GetThingStack ( string  id,
ThingStack  s,
bool  isOrigin,
int  refVal = -1 
)
inline

Definition at line 728 of file ThingContainer.cs.

729 {
730 using Enumerator enumerator = GetEnumerator();
731 while (enumerator.MoveNext())
732 {
733 Thing current = enumerator.Current;
734 if (current.CanSearchContents)
735 {
736 current.things.GetThingStack(id, s, isOrigin, refVal);
737 }
738 if ((refVal == -1 || current.refVal == refVal) && current.IsIdentified && (current.id == id || (isOrigin && current.source._origin == id)))
739 {
740 s.Add(current);
741 }
742 }
743 return s;
744 }
int refVal
Definition: Card.cs:209
bool IsIdentified
Definition: Card.cs:2419

References ThingStack.Add(), Thing.CanSearchContents, GetThingStack(), Card.id, Card.IsIdentified, Card.refVal, Thing.source, and Card.things.

◆ IsAlmostFull()

bool ThingContainer.IsAlmostFull ( int  threshold = 2)
inline

Definition at line 288 of file ThingContainer.cs.

289 {
290 return base.Count + threshold >= GridSize;
291 }

References GridSize.

◆ IsFull() [1/2]

bool ThingContainer.IsFull ( int  y = 0)
inline

Definition at line 293 of file ThingContainer.cs.

294 {
295 if (IsMagicChest)
296 {
297 if (base.Count < MaxCapacity)
298 {
299 if (owner.trait.IsFridge)
300 {
301 return !owner.isOn;
302 }
303 return false;
304 }
305 return true;
306 }
307 if (y != 0)
308 {
309 return false;
310 }
312 {
313 return true;
314 }
315 if (!HasGrid)
316 {
317 return base.Count >= GridSize;
318 }
319 return GetFreeGridIndex() == -1;
320 }
virtual bool IsSpecialContainer
Definition: Trait.cs:257
virtual bool IsFridge
Definition: Trait.cs:129

References GetFreeGridIndex(), GridSize, HasGrid, Trait.IsFridge, IsMagicChest, Card.isOn, Trait.IsSpecialContainer, MaxCapacity, owner, Card.parent, and Card.trait.

Referenced by FactionBranch.DailyOutcome(), QuestDeliver.Deliver(), Props.FindEmptyContainer< T >(), GetDest(), FactionBranch.GetMeal(), InvOwner.GetShitDestOwner(), IsFull(), InvOwner.Transaction.IsValid(), InvOwnerEquip.ListInteractions(), Faction.OnAdvanceMonth(), AI_Fish.ProgressFish.OnProgressComplete(), ActDreamBug.Perform(), InvOwner.PutBack(), AI_Idle.Run(), and GameDate.ShipPackages().

◆ IsFull() [2/2]

bool ThingContainer.IsFull ( Thing  t,
bool  recursive = true,
bool  tryStack = true 
)
inline

Definition at line 519 of file ThingContainer.cs.

520 {
521 if (!IsFull() || (tryStack && CanStack(t) != t))
522 {
523 return false;
524 }
525 if (!recursive)
526 {
527 return true;
528 }
529 return !GetDest(t, tryStack).IsValid;
530 }
DestData GetDest(Thing t, bool tryStack=true)

References CanStack(), GetDest(), IsFull(), and ThingContainer.DestData.IsValid.

◆ IsOccupied()

bool ThingContainer.IsOccupied ( int  x,
int  y 
)
inline

Definition at line 242 of file ThingContainer.cs.

243 {
244 using (Enumerator enumerator = GetEnumerator())
245 {
246 while (enumerator.MoveNext())
247 {
248 Thing current = enumerator.Current;
249 if (current.invY == y && current.invX == x)
250 {
251 return true;
252 }
253 }
254 }
255 return false;
256 }
int invY
Definition: Card.cs:1995
int invX
Definition: Card.cs:1983

References Card.invX, and Card.invY.

Referenced by InvOwner.PutBack().

◆ IsOverflowing()

bool ThingContainer.IsOverflowing ( )
inline

Definition at line 322 of file ThingContainer.cs.

323 {
324 if (!HasGrid || IsMagicChest)
325 {
326 return false;
327 }
328 int num = 0;
329 using (Enumerator enumerator = GetEnumerator())
330 {
331 while (enumerator.MoveNext())
332 {
333 Thing current = enumerator.Current;
334 if (current.invY != 1 && !current.isEquipped)
335 {
336 num++;
337 }
338 }
339 }
340 if (num > grid.Count)
341 {
342 return true;
343 }
344 return false;
345 }
bool isEquipped
Definition: Thing.cs:17

References grid, HasGrid, Card.invY, Thing.isEquipped, and IsMagicChest.

Referenced by InvOwner.ListInteractions().

◆ List()

◆ ListCurrency()

List< Thing > ThingContainer.ListCurrency ( string  id)
inline

Definition at line 795 of file ThingContainer.cs.

796 {
797 List<Thing> list = new List<Thing>();
798 list.Clear();
799 _ListCurrency(list, id);
800 return list;
801 }

References _ListCurrency().

Referenced by AddCurrency().

◆ OnAdd()

void ThingContainer.OnAdd ( Thing  t)
inline

Definition at line 275 of file ThingContainer.cs.

276 {
277 if (HasGrid && ShouldShowOnGrid(t))
278 {
279 int freeGridIndex = GetFreeGridIndex();
280 if (freeGridIndex != -1)
281 {
282 grid[freeGridIndex] = t;
283 }
284 t.pos.x = freeGridIndex;
285 }
286 }
bool ShouldShowOnGrid(Thing t)

References GetFreeGridIndex(), grid, HasGrid, and ShouldShowOnGrid().

Referenced by Card.AddThing().

◆ OnRemove()

void ThingContainer.OnRemove ( Thing  t)
inline

Definition at line 359 of file ThingContainer.cs.

360 {
361 if (HasGrid && t.invY == 0)
362 {
363 int num = grid.IndexOf(t);
364 if (num != -1)
365 {
366 grid[num] = null;
367 }
368 }
369 }

References grid, HasGrid, and Card.invY.

Referenced by Card.RemoveThing().

◆ RefreshGrid() [1/2]

void ThingContainer.RefreshGrid ( )
inline

Definition at line 106 of file ThingContainer.cs.

107 {
108 if (GridSize == 0)
109 {
110 return;
111 }
112 grid = new List<Thing>(new Thing[GridSize]);
113 using (Enumerator enumerator = GetEnumerator())
114 {
115 while (enumerator.MoveNext())
116 {
117 Thing current = enumerator.Current;
118 if (ShouldShowOnGrid(current))
119 {
120 if (current.invX >= GridSize || current.invX < 0 || grid[current.invX] != null)
121 {
122 listUnassigned.Add(current);
123 }
124 else
125 {
126 grid[current.invX] = current;
127 }
128 }
129 }
130 }
131 foreach (Thing item in listUnassigned)
132 {
133 int freeGridIndex = GetFreeGridIndex();
134 if (freeGridIndex == -1)
135 {
136 break;
137 }
138 grid[freeGridIndex] = item;
139 item.invX = freeGridIndex;
140 }
141 listUnassigned.Clear();
142 }
static List< Thing > listUnassigned

References ActPlan.List.Add(), GetFreeGridIndex(), grid, GridSize, Card.invX, item, listUnassigned, and ShouldShowOnGrid().

Referenced by ChangeSize(), RefreshGrid(), RefreshGridRecursive(), and LayerDragGrid.SetInv().

◆ RefreshGrid() [2/2]

void ThingContainer.RefreshGrid ( UIMagicChest  magic,
Window::SaveData  data 
)
inline

Definition at line 144 of file ThingContainer.cs.

145 {
146 magic.filteredList.Clear();
147 magic.cats.Clear();
148 magic.catCount.Clear();
149 grid = new List<Thing>(new Thing[GridSize]);
150 string text = magic.lastSearch;
151 bool flag = !text.IsEmpty();
152 bool flag2 = !magic.idCat.IsEmpty();
154 bool flag3 = category != Window.SaveData.CategoryType.None;
155 string text2 = "";
156 bool flag4 = text != null && text.Length >= 2 && (text[0] == '@' || text[0] == '@');
157 if (flag4)
158 {
159 text = text.Substring(1);
160 }
161 using (Enumerator enumerator = GetEnumerator())
162 {
163 while (enumerator.MoveNext())
164 {
165 Thing current = enumerator.Current;
166 if (flag3)
167 {
168 switch (category)
169 {
170 case Window.SaveData.CategoryType.Main:
171 text2 = current.category.GetRoot().id;
172 break;
174 text2 = current.category.GetSecondRoot().id;
175 break;
176 case Window.SaveData.CategoryType.Exact:
177 text2 = current.category.id;
178 break;
179 }
180 magic.cats.Add(text2);
181 if (magic.catCount.ContainsKey(text2))
182 {
183 magic.catCount[text2]++;
184 }
185 else
186 {
187 magic.catCount.Add(text2, 1);
188 }
189 }
190 if (flag)
191 {
192 if (flag4)
193 {
194 if (!current.MatchEncSearch(text))
195 {
196 continue;
197 }
198 }
199 else
200 {
201 if (current.tempName == null)
202 {
203 current.tempName = current.GetName(NameStyle.Full, 1).ToLower();
204 }
205 if (!current.tempName.Contains(text) && !current.source.GetSearchName(jp: false).Contains(text) && !current.source.GetSearchName(jp: true).Contains(text))
206 {
207 continue;
208 }
209 }
210 }
211 if (!flag2 || !(text2 != magic.idCat))
212 {
213 magic.filteredList.Add(current);
214 }
215 }
216 }
217 if (flag2 && !magic.cats.Contains(magic.idCat))
218 {
219 magic.idCat = "";
220 RefreshGrid(magic, data);
221 return;
222 }
223 magic.pageMax = (magic.filteredList.Count - 1) / GridSize;
224 if (magic.page > magic.pageMax)
225 {
226 magic.page = magic.pageMax;
227 }
228 for (int i = 0; i < GridSize; i++)
229 {
230 int num = magic.page * GridSize + i;
231 if (num >= magic.filteredList.Count)
232 {
233 break;
234 }
235 Thing thing = magic.filteredList[num];
236 grid[i] = thing;
237 thing.invX = i;
238 }
239 magic.RefreshCats();
240 }
string tempName
Definition: Thing.cs:15
override bool MatchEncSearch(string s)
Definition: Thing.cs:2158
void RefreshCats()
string idCat
Definition: UIMagicChest.cs:47
Dictionary< string, int > catCount
Definition: UIMagicChest.cs:45
HashSet< string > cats
Definition: UIMagicChest.cs:41
string lastSearch
Definition: UIMagicChest.cs:53
List< Thing > filteredList
Definition: UIMagicChest.cs:35
CategoryType category
Definition: Window.cs:303

References ActPlan.List.Add(), UIMagicChest.catCount, Card.category, UIMagicChest.cats, UIMagicChest.filteredList, Thing.GetName(), grid, GridSize, UIMagicChest.idCat, UIMagicChest.lastSearch, Thing.MatchEncSearch(), UIMagicChest.page, UIMagicChest.pageMax, UIMagicChest.RefreshCats(), RefreshGrid(), Thing.source, and Thing.tempName.

◆ RefreshGridRecursive()

void ThingContainer.RefreshGridRecursive ( )
inline

Definition at line 90 of file ThingContainer.cs.

91 {
92 using (Enumerator enumerator = GetEnumerator())
93 {
94 while (enumerator.MoveNext())
95 {
96 Thing current = enumerator.Current;
97 if (current.IsContainer)
98 {
100 }
101 }
102 }
103 RefreshGrid();
104 }
void RefreshGridRecursive()

References Card.IsContainer, RefreshGrid(), RefreshGridRecursive(), and Card.things.

Referenced by Game.OnLoad(), and RefreshGridRecursive().

◆ SetOwner()

void ThingContainer.SetOwner ( Card  owner)
inline

Definition at line 69 of file ThingContainer.cs.

70 {
71 this.owner = owner;
72 width = owner.c_containerSize / 100;
73 height = owner.c_containerSize % 100;
74 if (width == 0)
75 {
76 width = 8;
77 height = 5;
78 }
79 }

References height, owner, and width.

Referenced by Card._OnDeserialized(), Card.Create(), Card.Duplicate(), and SetSize().

◆ SetSize()

void ThingContainer.SetSize ( int  w,
int  h 
)
inline

Definition at line 371 of file ThingContainer.cs.

372 {
373 owner.c_containerSize = w * 100 + h;
375 }
void SetOwner(Card owner)

References owner, and SetOwner().

Referenced by TraitBaseContainer.OnCreate(), Player.OnCreateGame(), and TraitWrench.Upgrade().

◆ ShouldShowOnGrid()

bool ThingContainer.ShouldShowOnGrid ( Thing  t)
inline

Definition at line 258 of file ThingContainer.cs.

259 {
260 if (!owner.IsPC)
261 {
262 if (t.trait is TraitChestMerchant)
263 {
264 return false;
265 }
266 return true;
267 }
268 if (!t.isEquipped)
269 {
270 return !t.IsHotItem;
271 }
272 return false;
273 }
bool IsHotItem
Definition: Card.cs:122

References Thing.isEquipped, Card.IsHotItem, Card.IsPC, owner, and Card.trait.

Referenced by OnAdd(), and RefreshGrid().

◆ TryStack()

Thing ThingContainer.TryStack ( Thing  target,
int  destInvX = -1,
int  destInvY = -1 
)
inline

Definition at line 377 of file ThingContainer.cs.

378 {
379 using Enumerator enumerator = GetEnumerator();
380 while (enumerator.MoveNext())
381 {
382 Thing current = enumerator.Current;
383 if (destInvX == -1 && current.CanSearchContents && owner.GetRootCard().IsPC)
384 {
385 Thing thing = current.things.TryStack(target, destInvX, destInvY);
386 if (thing != target)
387 {
388 return thing;
389 }
390 }
391 if ((destInvX == -1 || (current.invX == destInvX && current.invY == destInvY)) && current != target && target.TryStackTo(current))
392 {
393 return current;
394 }
395 }
396 return target;
397 }
Card GetRootCard()
Definition: Card.cs:3510
bool TryStackTo(Thing to)
Definition: Card.cs:3481
Thing TryStack(Thing target, int destInvX=-1, int destInvY=-1)

References Thing.CanSearchContents, Card.GetRootCard(), Card.invX, Card.invY, Card.IsPC, owner, Card.things, TryStack(), and Card.TryStackTo().

Referenced by Card.AddThing(), InvOwner.OnShiftClick(), and TryStack().

Member Data Documentation

◆ _listContainers

List<ThingContainer> ThingContainer._listContainers = new List<ThingContainer>()
staticprivate

Definition at line 45 of file ThingContainer.cs.

Referenced by GetDest().

◆ grid

List<Thing> ThingContainer.grid

◆ height

int ThingContainer.height

◆ InvYHotbar

const int ThingContainer.InvYHotbar = 1
static

Definition at line 31 of file ThingContainer.cs.

◆ listUnassigned

List<Thing> ThingContainer.listUnassigned = new List<Thing>()
static

Definition at line 28 of file ThingContainer.cs.

Referenced by RefreshGrid().

◆ owner

Card ThingContainer.owner

◆ width

int ThingContainer.width

Property Documentation

◆ GridSize

int ThingContainer.GridSize
get

Definition at line 48 of file ThingContainer.cs.

Referenced by ChangeSize(), IsAlmostFull(), IsFull(), RefreshGrid(), and TraitWrench.Upgrade().

◆ HasGrid

bool ThingContainer.HasGrid
get

Definition at line 51 of file ThingContainer.cs.

Referenced by IsFull(), IsOverflowing(), OnAdd(), and OnRemove().

◆ IsMagicChest

bool ThingContainer.IsMagicChest
get

Definition at line 54 of file ThingContainer.cs.

Referenced by IsFull(), and IsOverflowing().

◆ MaxCapacity

int ThingContainer.MaxCapacity
get

Definition at line 57 of file ThingContainer.cs.

58 {
59 get
60 {
61 if (!IsMagicChest)
62 {
63 return GridSize;
64 }
65 return 100 + owner.c_containerUpgrade.cap;
66 }
67 }
ContainerUpgrade c_containerUpgrade
Definition: Card.cs:1909

Referenced by IsFull(), UIMagicChest.RefreshBottom(), and Zone.TryAddThingInSharedContainer().


The documentation for this class was generated from the following file: