Elin Decompiled Documentation EA 23.102 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)
 
int GetCurrency (string id, ref int sum, SourceMaterial.Row mat=null)
 
List< ThingListCurrency (string id)
 
List< ThingList (Func< Thing, bool > func, bool onlyAccessible=false)
 
void _List (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 (string id)
 

Static Private Attributes

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

Detailed Description

Definition at line 6 of file ThingContainer.cs.

Member Function Documentation

◆ _List()

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

Definition at line 820 of file ThingContainer.cs.

821 {
822 if (onlyAccessible && !owner.trait.CanSearchContent)
823 {
824 return;
825 }
826 using Enumerator enumerator = GetEnumerator();
827 while (enumerator.MoveNext())
828 {
829 Thing current = enumerator.Current;
830 current.things._List(func, onlyAccessible);
831 if (func(current))
832 {
833 tempList.Add(current);
834 }
835 }
836 }
void Add(Act a, string s="")
Definition: ActPlan.cs:11
Trait trait
Definition: Card.cs:49
ThingContainer things
Definition: Card.cs:34
static List< Thing > tempList
void _List(Func< Thing, bool > func, bool onlyAccessible=false)
Definition: Thing.cs:8
virtual bool CanSearchContent
Definition: Trait.cs:210

References _List(), ActPlan.List.Add(), Trait.CanSearchContent, owner, tempList, Card.things, and Card.trait.

Referenced by _List(), and List().

◆ _ListCurrency()

void ThingContainer._ListCurrency ( string  id)
inlineprivate

Definition at line 796 of file ThingContainer.cs.

797 {
798 using Enumerator enumerator = GetEnumerator();
799 while (enumerator.MoveNext())
800 {
801 Thing current = enumerator.Current;
802 if (current.CanSearchContents)
803 {
804 current.things._ListCurrency(id);
805 }
806 if (current.id == id)
807 {
808 tempList.Add(current);
809 }
810 }
811 }
string id
Definition: Card.cs:31
void _ListCurrency(string id)
bool CanSearchContents
Definition: Thing.cs:80

References _ListCurrency(), ActPlan.List.Add(), Thing.CanSearchContents, Card.id, tempList, 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 529 of file ThingContainer.cs.

530 {
531 int num = a;
532 ListCurrency(id);
533 foreach (Thing temp in tempList)
534 {
535 if (!(temp.id != id) && (mat == null || temp.material == mat))
536 {
537 if (num > 0)
538 {
539 temp.ModNum(num);
540 return;
541 }
542 if (temp.Num + num >= 0)
543 {
544 temp.ModNum(num);
545 return;
546 }
547 num += temp.Num;
548 temp.ModNum(-temp.Num);
549 }
550 }
551 if (num != 0 && num > 0)
552 {
553 Thing thing = ThingGen.Create(id);
554 if (mat != null)
555 {
556 thing.ChangeMaterial(mat);
557 }
558 owner.AddThing(thing).SetNum(num);
559 }
560 }
SourceMaterial.Row material
Definition: Card.cs:1927
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2838
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
Thing SetNum(int a)
Definition: Card.cs:3242
int Num
Definition: Card.cs:154
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
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(), Card.id, ListCurrency(), Card.material, Card.ModNum(), Card.Num, owner, Card.SetNum(), and tempList.

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

◆ AddFactory()

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

Definition at line 838 of file ThingContainer.cs.

839 {
840 using Enumerator enumerator = GetEnumerator();
841 while (enumerator.MoveNext())
842 {
843 Thing current = enumerator.Current;
844 if (current.CanSearchContents)
845 {
846 current.things.AddFactory(hash);
847 }
848 if (current.trait.IsFactory)
849 {
850 hash.Add(current.id);
851 }
852 if (current.trait.ToggleType == ToggleType.Fire && current.isOn)
853 {
854 hash.Add("fire");
855 }
856 }
857 }
ToggleType
Definition: ToggleType.cs:2
bool isOn
Definition: Card.cs:514
void AddFactory(HashSet< string > hash)
virtual bool IsFactory
Definition: Trait.cs:135
virtual ToggleType ToggleType
Definition: Trait.cs:456

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

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

References Thing.CanStackTo().

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

◆ ChangeSize()

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

Definition at line 83 of file ThingContainer.cs.

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

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

◆ DestroyAll()

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

Definition at line 562 of file ThingContainer.cs.

563 {
564 this.ForeachReverse(delegate(Thing t)
565 {
566 if (funcExclude == null || !funcExclude(t))
567 {
568 t.Destroy();
569 Remove(t);
570 }
571 });
572 if (grid != null)
573 {
574 for (int i = 0; i < grid.Count; i++)
575 {
576 grid[i] = null;
577 }
578 }
579 }
void Destroy()
Definition: Card.cs:4538
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(), SerializedCards.Restore(), and Zone.SpawnLostItems().

◆ Find() [1/4]

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

Definition at line 640 of file ThingContainer.cs.

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

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

◆ Find() [2/4]

Thing ThingContainer.Find ( int  uid)
inline

Definition at line 581 of file ThingContainer.cs.

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

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

Referenced by AM_Adv._OnUpdateInput(), TraitGodStatue._OnUse(), DropdownGrid.BuildIngredients(), QuestCraft.CanDeliverToClient(), QuestLoytelFarm.CanUpdateOnTalk(), DramaOutcome.chara_hired_ticket(), DramaOutcome.check_sketch(), LayerInventory.CreateBuy(), FactionBranch.DailyOutcome(), Chara.Die(), Find(), Find< T >(), Chara.FindAmmo(), CoreDebug.Fix_LostCore(), DramaOutcome.give_sketch_special(), Chara.GiveGift(), DramaOutcome.guild_mageTrial(), Chara.MakeGrave(), Trait.OnBarter(), ShopTransaction.OnEndTransaction(), ConSleep.OnRemoved(), ConWrath.OnRemoved(), DramaManager.ParseLine(), HotItemActionSleep.Perform(), HotItemEQSet.Perform(), LayerGacha.PlayGacha(), CoreDebug.QuickStart(), UIRecipeInfo.Refresh(), LayerQuestBoard.RefreshHire(), Recipe.Ingredient.RefreshThing(), Card.RemoveBacker(), 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 669 of file ThingContainer.cs.

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

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

665 {
666 return Find(id, idMat.IsEmpty() ? (-1) : EClass.sources.materials.alias[idMat].id);
667 }
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
SourceMaterial materials

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

◆ Find< T >()

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

Definition at line 605 of file ThingContainer.cs.

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

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

References List(), tempList, and Card.trait.

◆ FindStealable()

Thing ThingContainer.FindStealable ( )
inline

Definition at line 693 of file ThingContainer.cs.

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

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

Referenced by AI_Steal.Run().

◆ Foreach() [1/2]

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

Definition at line 859 of file ThingContainer.cs.

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

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

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

◆ GetCurrency()

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

Definition at line 769 of file ThingContainer.cs.

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

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

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

References grid.

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

◆ GetThingStack() [1/4]

ThingStack ThingContainer.GetThingStack ( string  id)
inline

Definition at line 744 of file ThingContainer.cs.

745 {
746 ThingStack s = new ThingStack();
747 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
748 return GetThingStack(id, s, isOrigin);
749 }
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
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 719 of file ThingContainer.cs.

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

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

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

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

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

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

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

Referenced by FactionBranch.DailyOutcome(), 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 516 of file ThingContainer.cs.

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

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

References Card.invX, and Card.invY.

Referenced by InvOwner.PutBack().

◆ IsOverflowing()

bool ThingContainer.IsOverflowing ( )
inline

Definition at line 319 of file ThingContainer.cs.

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

790 {
791 tempList.Clear();
792 _ListCurrency(id);
793 return tempList;
794 }

References _ListCurrency(), and tempList.

Referenced by AddCurrency().

◆ OnAdd()

void ThingContainer.OnAdd ( Thing  t)
inline

Definition at line 277 of file ThingContainer.cs.

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

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

Referenced by Card.AddThing().

◆ OnRemove()

void ThingContainer.OnRemove ( Thing  t)
inline

Definition at line 356 of file ThingContainer.cs.

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

References grid, HasGrid, and Card.invY.

Referenced by Card.RemoveThing().

◆ RefreshGrid() [1/2]

void ThingContainer.RefreshGrid ( )
inline

Definition at line 108 of file ThingContainer.cs.

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

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

93 {
94 using (Enumerator enumerator = GetEnumerator())
95 {
96 while (enumerator.MoveNext())
97 {
98 Thing current = enumerator.Current;
99 if (current.IsContainer)
100 {
102 }
103 }
104 }
105 RefreshGrid();
106 }
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 71 of file ThingContainer.cs.

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

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

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

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

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

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

◆ tempList

List<Thing> ThingContainer.tempList = new List<Thing>()
staticprivate

Definition at line 47 of file ThingContainer.cs.

Referenced by _List(), _ListCurrency(), AddCurrency(), FindBest< T >(), List(), and ListCurrency().

◆ width

int ThingContainer.width

Property Documentation

◆ GridSize

int ThingContainer.GridSize
get

Definition at line 50 of file ThingContainer.cs.

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

◆ HasGrid

bool ThingContainer.HasGrid
get

Definition at line 53 of file ThingContainer.cs.

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

◆ IsMagicChest

bool ThingContainer.IsMagicChest
get

Definition at line 56 of file ThingContainer.cs.

Referenced by IsFull(), and IsOverflowing().

◆ MaxCapacity

int ThingContainer.MaxCapacity
get

Definition at line 59 of file ThingContainer.cs.

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

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


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