Skip to main content

DisposablePickup

A class in Root.Township, the global namespace.

Networked behaviour for a pickup that is used up: once disposed it is destroyed (after the player lets go) and not saved.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Coroutine delayCoroutineThe running DelayDispose coroutine.
private TransformEvent disposedEvent fired with the transform when the pickup is disposed, for effects.
private float disposeEffectDelaySeconds after release before it is destroyed. Defaults to 0.5.
private bool isDisposedBacking field for IsDisposed.
private MethodSync syncDisposeSync that tells clients to play the dispose effect.

Properties​

1 private and internal property
MemberWhat it is
private bool IDisposablePickup.IsDisposed { get; }Whether the pickup has been disposed.

Methods​

MemberWhat it is
void Dispose(bool isForced = false)Marks the pickup disposed and not saved, then destroys it now or once released. With isForced, the server destroys it at once.
override void Initialize()Creates the dispose sync.
override void InitializeAsServer(SpawnData spawnData)Server: if already disposed, destroys the pickup when its interaction ends.
4 private and internal methods
MemberWhat it is
private IEnumerator DelayDispose() (iterator)Waits until nobody holds the pickup, then disposeEffectDelay seconds, then destroys it.
private void Dispose(Interactable arg1, Interactor arg2)Marks the pickup disposed and not saved, then destroys it now or once released. With isForced, the server destroys it at once.
private void DisposeDestroy()Plays the dispose effect, tells clients, and destroys the entity.
private void NetworkDispose(IPlayer player, Stream stream)Client: plays the dispose effect, facing along the pickup's velocity.

Used in​

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