Skip to main content

DockArray

A class in Root.Township, Alta.Inventory.

A group of pickup docks (a bag's or belt's slots) with totals for count, stored quantity and weight. Arrays can nest, so a parent includes its children's docks.

Constructors​

MemberWhat it is
DockArray()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private HashSet<DockArray> childrenDock arrays whose Parent is this one, included in TotalCount and TotalDocks.
private List<PickupDock> docksThe docks in this array.
private DockArray parentBacking field for Parent.

Properties​

MemberWhat it is
int Count { get; }Number of docks directly in this array.
IEnumerable<PickupDock> Docks { get; }Docks directly in this array.
PickupDock this[int index] { get; }Indexer: the dock at an index in this array.
DockArray Parent { get; set; }The array this one is nested in. Setting it moves it between parents' child lists.
int QuantityStored { get; }Total items stored across all docks, nested ones included.
int TotalCount { get; }Dock count including nested arrays.
IEnumerable<PickupDock> TotalDocks { get; }All docks including nested arrays.
float WeightMultiplier { get; set; }Multiplier for docks whose settings match the pickup's storage weight settings. 1 by default.

Events​

MemberWhat it is
event Action WeightChangedRaised when a dock's weight changes or docks are added or removed.

Methods​

MemberWhat it is
bool Add(PickupDock dock)Adds one or more docks, skipping ones already in. The single version returns false if already present.
void Add(IEnumerable<PickupDock> docks)Adds one or more docks, skipping ones already in. The single version returns false if already present.
float CalculateWeight(Pickup pickup)Total weight of this array's docks, applying the multiplier where the pickup's storage settings match.
bool Remove(PickupDock dock)Removes one or more docks. The single version returns false if not present.
void Remove(IEnumerable<PickupDock> docks)Removes one or more docks. The single version returns false if not present.
2 private and internal methods
MemberWhat it is
private void Awake()Listens for weight changes on the docks set on the prefab.
private void OnWeightChanged()Raises WeightChanged. Called when a dock's weight changes or docks are added or removed.

Used in​

Members of other types that take, return or hold a DockArray: