StorageOrganizer
A class in Root.Township, Alta.Inventory.
Shows a storage dock's contents as a baked stack of item meshes (such as a pile of logs on a rack), with a matching collider, and draws it only while visible. Component next to the dock on storage prefabs; both sides bake the collider, only clients draw.
- Listed in Items, inventory and logic
- Inherits or implements
MonoBehaviour,IUpdateOnMove - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
StorageOrganizer() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
17 private and internal fields
| Member | What it is |
|---|---|
private Matrix4x4 androidMeshPosition | World matrix the stack is drawn and laid out with. |
private Bounds bounds | Local box the items are stacked inside. |
private Mesh collisionMesh | Mesh baked into the collider: the item's collision mesh, or its first rendering mesh. |
private int cullingIndex | Index of this stack's sphere in the culling group. |
private int currentQuantity | How many item meshes are shown now. |
private PickupDock dock | The dock whose contents are shown. |
private AnimationCurve dockedToItems | Curve from stored quantity to the number of meshes shown. |
private bool hasDynamicVisibility | Use the visibility detector instead of a static culling sphere, for storage that moves. |
private BoxCollider interactionCollider | Box collider resized to fit the baked stack. |
private static Logger logger | Logger for this class. |
private Material[] materials | Materials for each rendering mesh, from the item's renderers. |
private MeshCollider meshCollider | Collider that gets the baked stack mesh. |
private Mesh[] meshes | The item's source meshes, one per rendering filter. |
private IUnityUpdateMethod render | Handle for the per-frame Render call. |
private Mesh[] renderingMeshes | Baked stack meshes drawn on clients. |
private StackingInstructionSetup stackingSetup | Layout from the item's StackingComponent, holding the item positions and max count. |
private VisibilityDetector visibilityDetector | Detector used when hasDynamicVisibility is on. |
Methods
16 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Turns the colliders off and hooks the dock's quantity, docked and undocked events. |
private void BecameInvisible() | Stops drawing when the visibility detector says the stack is off screen. |
private void BecameVisible() | Starts drawing each frame when the visibility detector says the stack is on screen. |
private void CheckQuantities() | Works out how many items to show from the stored quantity and rebakes the collider and rendering meshes when that changes. |
private void Clean(Interactor interactor, Pickup pickup, PickupDock dock) | On undock, clears the setup once the dock is empty. |
private void CleanStaticVisibility() | Removes this stack's sphere from the culling group. |
private void ClearSetup() | Forgets the stacking setup, sets the shown count to 0 and turns the colliders off. |
private void IUpdateOnMove.Moved() | When the storage is moved, re-registers its culling sphere at the new spot (static visibility only). |
private void OnDestroy() | Frees the baked meshes and unhooks visibility and the draw call. |
private void OnDrawGizmosSelected() | Editor: draws the stacking bounds as a wire box. |
private void Render() | Draws the baked meshes each frame while visible, updating positions first if the storage has moved. |
private void SetMeshEnabled(bool isEnabled) | Turns the mesh collider and interaction collider on or off. |
private void Setup(Interactor interactor, Pickup pickup, PickupDock dock) | When an item is first docked, reads its StackingComponent meshes and materials and builds the stacking layout for bounds. |
private void SetupStaticCulling() | Registers a culling sphere around the bounds so UpdateVisibility starts and stops drawing. |
private void Start() | Client: hooks the visibility detector when hasDynamicVisibility is on. |
private void UpdateVisibility(CullingGroupEvent sphere) | Culling group callback: starts drawing when the sphere becomes visible, stops otherwise. |