Skip to main content

GhostSnapSlot

A class in Root.Township, the global namespace.

A slot that shows a ghost preview when a matching GhostSnapObject is brought near and holds it when snapped. The held object rides on this entity and saves as its child.

Constructors​

MemberWhat it is
GhostSnapSlot()Creates a GhostSnapSlot with default values.

Fields​

6 private and internal fields
MemberWhat it is
private GhostSnapChannel[] channelsChannels this slot accepts; an object matches if its channel is in the list.
private ChildSyncableCollectionBase<GhostSnapSlot> collectionThe child-sync collection this slot belongs to, used to sync it.
private float ejectVelocitySpeed of the random push given to an ejected object (default 5).
private NetworkEntity entitySerialized entity reference for the slot.
private Dictionary<Collider, GhostSnapObject> ghostSnapObjectsObjects currently inside the trigger, keyed by collider.
private bool isAllowingReplaceWhether a new object can push out the one already snapped.

Properties​

MemberWhat it is
GhostSnapObject Contains { get; private set; }The object in the slot, or null. Cleared when a player grabs it out.
NetworkEntity Entity { get; set; }The entity the slot belongs to, which becomes the held object's chunking parent.
uint Index { get; set; }The slot's index in its collection.

Methods​

MemberWhat it is
bool AttemptSnap(GhostSnapObject snapObject)Snaps the object in if its channel matches. Returns false otherwise.
void Eject()Pushes the held object out in a random direction and gives it back its own save.
bool Matches(GhostSnapObject snapObject)Whether the object's snap channel is one this slot accepts.
5 private and internal methods
MemberWhat it is
private void Connect(GhostSnapObject snapObject)Snaps the object in: ejects the old one if replacing is allowed, parents and freezes it, and makes it save as a child. Server syncs the slot.
private void Empty(Interactable interactable, Interactor interactor)Runs when the snapped object is grabbed; frees it from the slot and restores its normal save mode.
private IEnumerator HideGhost(Collider other, GhostSnapObject snapObject) (iterator)Coroutine: after 0.1 seconds, hides the ghost if the object hasn't re-entered and the ghost is still at this slot.
private void OnTriggerEnter(Collider other)Shows the ghost preview for a matching GhostSnapObject whose collider's parent enters the trigger.
private void OnTriggerExit(Collider other)Starts HideGhost for an object leaving the trigger.

Used in​

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