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
| Member | What it is |
|---|
DockArray() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|
private HashSet<DockArray> children | Dock arrays whose Parent is this one, included in TotalCount and TotalDocks. |
private List<PickupDock> docks | The docks in this array. |
private DockArray parent | Backing field for Parent. |
Properties
| Member | What 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
| Member | What it is |
|---|
event Action WeightChanged | Raised when a dock's weight changes or docks are added or removed. |
Methods
| Member | What 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
| Member | What 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: