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.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour,IChildSyncable<GhostSnapSlot, GhostSnapSlotCollectionSaveData.Element>,IChildSyncable<GhostSnapSlot> - Derived types
GhostSnapSlot,GhostSnapSlotCollection
Constructors
| Member | What it is |
|---|---|
GhostSnapSlot() | Creates a GhostSnapSlot with default values. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private GhostSnapChannel[] channels | Channels this slot accepts; an object matches if its channel is in the list. |
private ChildSyncableCollectionBase<GhostSnapSlot> collection | The child-sync collection this slot belongs to, used to sync it. |
private float ejectVelocity | Speed of the random push given to an ejected object (default 5). |
private NetworkEntity entity | Serialized entity reference for the slot. |
private Dictionary<Collider, GhostSnapObject> ghostSnapObjects | Objects currently inside the trigger, keyed by collider. |
private bool isAllowingReplace | Whether a new object can push out the one already snapped. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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: