Skip to main content

PickupInteractionScaler

A class in Root.Township, the global namespace.

Shrinks a pickup while it's held and scales it back up when released, optionally showing a shrunken stand-in visual. Pickup creates one when its item scales on grab.

Constructors​

MemberWhat it is
PickupInteractionScaler(Pickup pickup)Creates a PickupInteractionScaler from pickup.

Fields​

9 private and internal fields
MemberWhat it is
private float currentScaleFactorThe scale factor the pickup is at now, relative to its normal size.
private bool isScaledDownTrue while the pickup is shrunk.
private Vector3 normalSizeThe pickup's local scale when the scaler was made.
private Pickup pickupThe pickup being scaled.
private float pickupScaleFactorThe factor the pickup shrinks to when grabbed.
private AltaCoroutine scalingAnimationThe running scale coroutine, if any.
private Collider[] shrunkenVisualCollidersColliders from the shrunken visual, added to the pickup while it's shown.
private PooledObject spawnedVisualThe shrunken visual currently spawned.
private float visualScaleFactorScale applied to the shrunken visual so it fits the pickup.

Methods​

MemberWhat it is
void DrawGizmos()Empty.
13 private and internal methods
MemberWhat it is
private void AddShrunkenVisual()Spawns the item's shrunken visual (or the default one) on the pickup and adds its colliders to the pickup.
private void CalculateTargetSize()Works out the scale factor for the shrunken pickup, from the item override or the global shrunken size.
private void CalculateVisualScalingFactor()Works out how much to scale the shrunken visual from the pickup's and visual's bounds, or the item's override. Uses a fixed 10 on headless servers.
private IEnumerator ReleaseParticles(PooledObject particles, float waitTime) (iterator)Coroutine that returns the scaling particles to the pool after a wait.
private void RemoveShrunkenVisual()Releases the shrunken visual and takes its colliders off the pickup.
private void ResetScaleOnPickup(Interactable pickupInteractable, Interactor interactor)On release, scales the pickup back to normal over the global duration, unless a dock is scaling it, and removes the shrunken visual.
private IEnumerator ScaleOverTime(Transform pickupTransform, float targetScale, float duration) (iterator)Coroutine that lerps the pickup's scale to a target. Stops if the pickup is docked.
private void ScalePickup(Transform pickupTransform, float scaleFactor, float duration)Scales the pickup to a factor of its normal size, at once or over time, and spawns scaling particles on clients.
private void ScalePickupAfterUndock(Interactor interactor, Pickup pickup, PickupDock dock)Shrinks the pickup once it has left its dock.
private void ScalePickupDown(Interactable pickupInteractable, Interactor interactor)On grab, shrinks the pickup at once and adds the shrunken visual. If docked, waits for the undock first.
private void SetPickupColliderActive(bool isActive)Turns all the pickup's colliders on or off.
private void SpawnScalingParticles()Spawns the global shrinking particles at the pickup and releases them after half a second.
private void WaitForPickupToBeUndocked()Subscribes ScalePickupAfterUndock to the pickup's Undocked event.

Used in​

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