Elin Decompiled Documentation EA 23.299 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 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 823 of file ThingContainer.cs.

824 {
825 if (onlyAccessible && !owner.trait.CanSearchContent)
826 {
827 return;
828 }
829 using Enumerator enumerator = GetEnumerator();
830 while (enumerator.MoveNext())
831 {
832 Thing current = enumerator.Current;
833 current.things._List(tempList, func, onlyAccessible);
834 if (func(current))
835 {
836 tempList.Add(current);
837 }
838 }
839 }
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 798 of file ThingContainer.cs.

799 {
800 using Enumerator enumerator = GetEnumerator();
801 while (enumerator.MoveNext())
802 {
803 Thing current = enumerator.Current;
804 if (current.CanSearchContents)
805 {
806 current.things._ListCurrency(tempList, id);
807 }
808 if (current.id == id)
809 {
810 tempList.Add(current);
811 }
812 }
813 }
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 527 of file ThingContainer.cs.

528 {
529 int num = a;
530 foreach (Thing item in ListCurrency(id))
531 {
532 if (!(item.id != id) && (mat == null || item.material == mat) && (num <= 0 || item.Num + num > 0))
533 {
534 if (num > 0)
535 {
536 item.ModNum(num);
537 return;
538 }
539 if (item.Num + num >= 0)
540 {
541 item.ModNum(num);
542 return;
543 }
544 num += item.Num;
545 item.ModNum(-item.Num);
546 }
547 }
548 if (num != 0 && num > 0)
549 {
550 Thing thing = ThingGen.Create(id);
551 if (mat != null)
552 {
553 thing.ChangeMaterial(mat);
554 }
555 owner.AddThing(thing, tryStack: false).SetNum(num);
556 }
557 }
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 841 of file ThingContainer.cs.

842 {
843 using Enumerator enumerator = GetEnumerator();
844 while (enumerator.MoveNext())
845 {
846 Thing current = enumerator.Current;
847 if (current.CanSearchContents)
848 {
849 current.things.AddFactory(hash);
850 }
851 if (current.trait.IsFactory)
852 {
853 hash.Add(current.id);
854 }
855 if (current.trait.ToggleType == ToggleType.Fire && current.isOn)
856 {
857 hash.Add("fire");
858 }
859 }
860 }
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 394 of file ThingContainer.cs.

395 {
396 using Enumerator enumerator = GetEnumerator();
397 while (enumerator.MoveNext())
398 {
399 Thing current = enumerator.Current;
400 if (current != target && target.CanStackTo(current))
401 {
402 return current;
403 }
404 }
405 return target;
406 }
override bool CanStackTo(Thing to)
Definition: Thing.cs:1668

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 559 of file ThingContainer.cs.

560 {
561 this.ForeachReverse(delegate(Thing t)
562 {
563 if (funcExclude == null || !funcExclude(t))
564 {
565 t.Destroy();
566 Remove(t);
567 }
568 });
569 if (grid != null)
570 {
571 for (int i = 0; i < grid.Count; i++)
572 {
573 grid[i] = null;
574 }
575 }
576 }
void Destroy()
Definition: Card.cs:5184
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 637 of file ThingContainer.cs.

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

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

◆ Find() [2/4]

Thing ThingContainer.Find ( int  uid)
inline

Definition at line 578 of file ThingContainer.cs.

579 {
580 using (Enumerator enumerator = GetEnumerator())
581 {
582 while (enumerator.MoveNext())
583 {
584 Thing current = enumerator.Current;
585 if (current.CanSearchContents)
586 {
587 Thing thing = current.things.Find(uid);
588 if (thing != null)
589 {
590 return thing;
591 }
592 }
593 if (current.uid == uid)
594 {
595 return current;
596 }
597 }
598 }
599 return null;
600 }
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 666 of file ThingContainer.cs.

667 {
668 using (Enumerator enumerator = GetEnumerator())
669 {
670 while (enumerator.MoveNext())
671 {
672 Thing current = enumerator.Current;
673 if (current.CanSearchContents)
674 {
675 Thing thing = current.things.Find(id, idMat, refVal);
676 if (thing != null)
677 {
678 return thing;
679 }
680 }
681 if (current.id == id && (idMat == -1 || current.material.id == idMat) && (refVal == -1 || current.refVal == refVal))
682 {
683 return current;
684 }
685 }
686 }
687 return null;
688 }
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 661 of file ThingContainer.cs.

662 {
663 return Find(id, idMat.IsEmpty() ? (-1) : EClass.sources.materials.alias[idMat].id);
664 }
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 602 of file ThingContainer.cs.

602 : Trait
603 {
604 using (Enumerator enumerator = GetEnumerator())
605 {
606 while (enumerator.MoveNext())
607 {
608 Thing current = enumerator.Current;
609 if (current.CanSearchContents)
610 {
611 Thing thing = current.things.Find<T>();
612 if (thing != null)
613 {
614 return thing;
615 }
616 }
617 if (current.trait is T)
618 {
619 return current;
620 }
621 }
622 }
623 return null;
624 }
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 626 of file ThingContainer.cs.

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

References List(), and Card.trait.

◆ FindStealable()

Thing ThingContainer.FindStealable ( )
inline

Definition at line 690 of file ThingContainer.cs.

691 {
692 List<Thing> list = new List<Thing>();
693 using (Enumerator enumerator = GetEnumerator())
694 {
695 while (enumerator.MoveNext())
696 {
697 Thing current = enumerator.Current;
698 if (!current.IsContainer && current.trait.CanBeStolen && !current.HasTag(CTAG.gift) && (!current.IsEquipmentOrRangedOrAmmo || !current.IsUnique))
699 {
700 list.Add(current);
701 }
702 }
703 }
704 if (list.Count == 0)
705 {
706 return null;
707 }
708 list.Sort((Thing a, Thing b) => Compare(a) - Compare(b));
709 return list[0];
710 static int Compare(Thing a)
711 {
712 return a.SelfWeight + (a.isEquipped ? 10000 : 0);
713 }
714 }
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 862 of file ThingContainer.cs.

863 {
864 using Enumerator enumerator = GetEnumerator();
865 while (enumerator.MoveNext())
866 {
867 Thing current = enumerator.Current;
868 if (!onlyAccessible || current.CanSearchContents)
869 {
870 current.things.Foreach(action);
871 }
872 action(current);
873 }
874 }
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 876 of file ThingContainer.cs.

877 {
878 using Enumerator enumerator = GetEnumerator();
879 while (enumerator.MoveNext())
880 {
881 Thing current = enumerator.Current;
882 if (!onlyAccessible || current.CanSearchContents)
883 {
884 current.things.Foreach(action);
885 }
886 if (action(current))
887 {
888 break;
889 }
890 }
891 }

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

◆ GetCurrency()

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

Definition at line 766 of file ThingContainer.cs.

767 {
768 using (Enumerator enumerator = GetEnumerator())
769 {
770 while (enumerator.MoveNext())
771 {
772 Thing current = enumerator.Current;
773 if (current.CanSearchContents)
774 {
775 current.things.GetCurrency(id, ref sum, mat);
776 }
777 if (current.id == id && (mat == null || current.material == mat))
778 {
779 sum += current.Num;
780 }
781 }
782 }
783 if (sum < 0)
784 {
785 sum = 2147483647L;
786 }
787 return sum;
788 }
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 408 of file ThingContainer.cs.

409 {
410 DestData d = default(DestData);
411 if (!owner.IsPC)
412 {
413 SearchDest(this, searchEmpty: true, searchStack: true);
414 return d;
415 }
416 if (t.trait.CanOnlyCarry && IsFull())
417 {
418 return d;
419 }
420 ContainerFlag flag = t.category.GetRoot().id.ToEnum<ContainerFlag>();
421 if (flag == ContainerFlag.none)
422 {
423 flag = ContainerFlag.other;
424 }
425 _listContainers.Clear();
426 _listContainers.Add(this);
427 TrySearchContainer(owner);
428 _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)));
429 if (tryStack)
430 {
431 foreach (ThingContainer listContainer in _listContainers)
432 {
433 SearchDest(listContainer, searchEmpty: false, searchStack: true);
434 if (d.IsValid)
435 {
436 return d;
437 }
438 }
439 }
440 foreach (ThingContainer listContainer2 in _listContainers)
441 {
442 SearchDest(listContainer2, searchEmpty: true, searchStack: false);
443 if (d.IsValid)
444 {
445 return d;
446 }
447 }
448 return d;
449 void SearchDest(ThingContainer things, bool searchEmpty, bool searchStack)
450 {
451 if (!t.IsContainer || t.things.Count <= 0 || !things.owner.IsContainer || things.owner.trait is TraitToolBelt)
452 {
453 if (searchStack && tryStack)
454 {
455 Thing thing = things.CanStack(t);
456 if (thing != t)
457 {
458 d.stack = thing;
459 return;
460 }
461 }
462 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))
463 {
464 d.container = things.owner;
465 }
466 }
467 }
468 void TrySearchContainer(Card c)
469 {
470 foreach (Thing thing2 in c.things)
471 {
472 if (thing2.CanSearchContents)
473 {
474 TrySearchContainer(thing2);
475 }
476 }
477 if (c.things != this)
478 {
479 Window.SaveData windowSaveData = c.GetWindowSaveData();
480 if (windowSaveData != null && (!windowSaveData.noRotten || !t.IsDecayed) && (!windowSaveData.onlyRottable || t.trait.Decay != 0))
481 {
482 if (windowSaveData.userFilter)
483 {
484 switch (windowSaveData.IsFilterPass(t.GetName(NameStyle.Full, 1)))
485 {
486 case Window.SaveData.FilterResult.Block:
487 return;
488 case Window.SaveData.FilterResult.PassWithoutFurtherTest:
489 _listContainers.Add(c.things);
490 return;
491 }
492 }
493 if (windowSaveData.advDistribution)
494 {
495 foreach (int cat in windowSaveData.cats)
496 {
497 if (t.category.uid == cat)
498 {
499 _listContainers.Add(c.things);
500 break;
501 }
502 }
503 return;
504 }
505 if (!windowSaveData.flag.HasFlag(flag))
506 {
507 _listContainers.Add(c.things);
508 }
509 }
510 }
511 }
512 }
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 342 of file ThingContainer.cs.

343 {
344 for (int i = 0; i < grid.Count; i++)
345 {
346 if (grid[i] == null)
347 {
348 return i;
349 }
350 }
351 return -1;
352 }

References grid.

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

◆ GetThingStack() [1/4]

ThingStack ThingContainer.GetThingStack ( string  id)
inline

Definition at line 741 of file ThingContainer.cs.

742 {
743 ThingStack s = new ThingStack();
744 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
745 return GetThingStack(id, s, isOrigin);
746 }
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 716 of file ThingContainer.cs.

717 {
718 ThingStack s = new ThingStack();
719 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
720 return GetThingStack(id, s, isOrigin, refVal);
721 }

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 748 of file ThingContainer.cs.

749 {
750 using Enumerator enumerator = GetEnumerator();
751 while (enumerator.MoveNext())
752 {
753 Thing current = enumerator.Current;
754 if (current.CanSearchContents)
755 {
756 current.things.GetThingStack(id, s, isOrigin);
757 }
758 if (current.id == id || (isOrigin && current.source._origin == id))
759 {
760 s.Add(current);
761 }
762 }
763 return s;
764 }
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 723 of file ThingContainer.cs.

724 {
725 using Enumerator enumerator = GetEnumerator();
726 while (enumerator.MoveNext())
727 {
728 Thing current = enumerator.Current;
729 if (current.CanSearchContents)
730 {
731 current.things.GetThingStack(id, s, isOrigin, refVal);
732 }
733 if ((refVal == -1 || current.refVal == refVal) && current.IsIdentified && (current.id == id || (isOrigin && current.source._origin == id)))
734 {
735 s.Add(current);
736 }
737 }
738 return s;
739 }
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.

◆ IsFull() [1/2]

bool ThingContainer.IsFull ( int  y = 0)
inline

Definition at line 288 of file ThingContainer.cs.

289 {
290 if (IsMagicChest)
291 {
292 if (base.Count < MaxCapacity)
293 {
294 if (owner.trait.IsFridge)
295 {
296 return !owner.isOn;
297 }
298 return false;
299 }
300 return true;
301 }
302 if (y != 0)
303 {
304 return false;
305 }
307 {
308 return true;
309 }
310 if (!HasGrid)
311 {
312 return base.Count >= GridSize;
313 }
314 return GetFreeGridIndex() == -1;
315 }
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 514 of file ThingContainer.cs.

515 {
516 if (!IsFull() || (tryStack && CanStack(t) != t))
517 {
518 return false;
519 }
520 if (!recursive)
521 {
522 return true;
523 }
524 return !GetDest(t, tryStack).IsValid;
525 }
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 317 of file ThingContainer.cs.

318 {
319 if (!HasGrid || IsMagicChest)
320 {
321 return false;
322 }
323 int num = 0;
324 using (Enumerator enumerator = GetEnumerator())
325 {
326 while (enumerator.MoveNext())
327 {
328 Thing current = enumerator.Current;
329 if (current.invY != 1 && !current.isEquipped)
330 {
331 num++;
332 }
333 }
334 }
335 if (num > grid.Count)
336 {
337 return true;
338 }
339 return false;
340 }
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 790 of file ThingContainer.cs.

791 {
792 List<Thing> list = new List<Thing>();
793 list.Clear();
794 _ListCurrency(list, id);
795 return list;
796 }

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 354 of file ThingContainer.cs.

355 {
356 if (HasGrid && t.invY == 0)
357 {
358 int num = grid.IndexOf(t);
359 if (num != -1)
360 {
361 grid[num] = null;
362 }
363 }
364 }

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:2149
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 366 of file ThingContainer.cs.

367 {
368 owner.c_containerSize = w * 100 + h;
370 }
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 372 of file ThingContainer.cs.

373 {
374 using Enumerator enumerator = GetEnumerator();
375 while (enumerator.MoveNext())
376 {
377 Thing current = enumerator.Current;
378 if (destInvX == -1 && current.CanSearchContents && owner.GetRootCard().IsPC)
379 {
380 Thing thing = current.things.TryStack(target, destInvX, destInvY);
381 if (thing != target)
382 {
383 return thing;
384 }
385 }
386 if ((destInvX == -1 || (current.invX == destInvX && current.invY == destInvY)) && current != target && target.TryStackTo(current))
387 {
388 return current;
389 }
390 }
391 return target;
392 }
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(), 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: