A class in Root.Township, Alta.QuickAccessActions.
Tracks one quick-access action item spawned for a player: fades it in and out, and despawns it when the player walks away, leaves or the item lands in the global chunk.
Constructors
Fields
8 private and internal fields
| Member | What it is |
|---|
private readonly Action<int, IPlayer> destroyItem | Callback that destroys the item, given its index and player. |
private ActionItem Item | The spawned action item, or null before it spawns. |
private readonly int ItemIndex | Index of this item in the action item list, passed back to the destroy callback. |
private readonly float maxDistanceSquared | Squared distance from the head beyond which the despawn timer runs. |
private readonly float outOfRangeHaptic | Haptic strength used while the item is out of range. |
private float timer | Seconds left before an out-of-range item is destroyed; reset while in range. |
private readonly float timeToDespawn | Seconds the item may stay out of range before it is destroyed. |
private IUnityUpdateMethod updateDistance | Handle for the registered late-update distance check. |
Properties
| Member | What it is |
|---|
bool ItemIsActive { get; } | True while an item is attached. |
Vector3 ItemPosition { get; } | The item's world position, or zero when there is no item. |
1 private and internal property
| Member | What it is |
|---|
private IPlayer Player { get; } | The player the item belongs to. |
Methods
| Member | What it is |
|---|
void Dispose() | Fades the item out and stops the distance check. Note it unhooks PlayerDestroyed from the item rather than ItemDestroyed. |
void SetupSpawnedActionItem(ActionItem item) | Attaches a freshly spawned item, hooks its destroy and chunk events, and fades it in. Starts the distance check for the local player. |
4 private and internal methods
| Member | What it is |
|---|
private void ItemDestroyed(NetworkEntity _, bool __) | When the item entity is destroyed, calls Dispose. |
private void OnAddedToChunk(Chunk chunk) | Destroys the item if it is moved into the global chunk. |
private void PlayerDestroyed(NetworkEntity entity, bool isUnload) | Destroys the item when the owning player's entity is destroyed. |
private void UpdateDistance() | Client: each late update, buzzes both controllers while the item is too far from the head and destroys it once the timer runs out. |
Used in
Members of other types that take, return or hold a ActionItemHandler: