Skip to main content

PickupHolder

A class in Root.Township, the global namespace.

Holds one pickup in place at an interaction point, frozen and parented to this entity, and syncs which pickup it holds. Used by DecraftingDeck. The server decides what is held.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private Transform interactionPointTransform the held pickup is grabbed to.
private Coroutine moveToPositionRunning MoveToPosition coroutine, if any.
private float moveToPositionDurationSeconds the held pickup takes to ease into place. Defaults to 0.5.
private MethodSyncStruct<uint> syncHeldPickupMethod sync on SyncA for the held pickup's ID.

Properties​

MemberWhat it is
Pickup HeldPickup { get; private set; }The pickup currently held, or null.

Events​

MemberWhat it is
event PickupHolderFilter HoldFilterLets listeners refuse a pickup before it is held by setting the ref valid flag to false.
event OnHeld OnHeldRaised after HoldPickup with the pickup.

Methods​

MemberWhat it is
void HoldPickup(Pickup pickup)Holds the pickup and fires OnHeld. On a client it also sends the ID to the server, but the server ignores incoming syncs.
override void Initialize()Creates the syncHeldPickup method sync.
override void OnConnected(Player player)Sends the held pickup's ID (or 0) to a joining player.
void ReleasePickup()Unfreezes and unparents the held pickup; the server restores its save mode and syncs the release.
4 private and internal methods
MemberWhat it is
private void InternalHoldPickup(Pickup pickup)Releases the old pickup, checks HoldFilter, then freezes and parents the new one; the server saves it as a child and syncs it.
private IEnumerator MoveToPosition() (iterator)Client coroutine that eases the held pickup into its grab pose over moveToPositionDuration, with colliders off.
private void SetCollidersEnabled(bool isEnabled)Turns all of the held pickup's colliders on or off.
private void SyncHeldPickup(IPlayer player, Stream stream, uint heldIdentifier)Method sync with the held entity ID. Clients wait for that entity to spawn and hold it, or release on 0.

Used in​

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