PullPickupGroup
A class in Root.Township, the global namespace.
A group of pickups parented to one holder that players pull off one at a time by grabbing and drawing the hand away (used by PotatoSapling). Both sides; the server decides when a pull succeeds and syncs adds and removes.
- Listed in Global namespace: P
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
PullPickupGroup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
17 private and internal fields
| Member | What it is |
|---|---|
private Transform cachedTransform | The group's transform, cached in Initialize. Grouped pickups are parented to it. |
private float directionWeighting | 0 to 1. How much the pull is measured along pullDirection rather than wherever the hand moves. |
private float hapticStrength | Strength of the hand vibration while pulling, scaled by how close the pull is to done. |
private Interactable interactable | The interactable on this object that grouped pickups forward their grabs to. |
private Dictionary<Pickup, Interactor> interactors | Which hand is holding each grouped pickup, so Remove can hand it over. |
private bool isAdding | Whether the next SyncAdd is an add (true) or a remove. |
private Interactor nextInteraction | The last remote hand that started an interaction, waiting for SyncSelection to say which pickup. |
private uint nextSelection | Identifier of the pickup to send or just received in SyncSelection (0 for none). |
private uint nextSpawn | Identifier of the pickup to send or just received in SyncAdd. |
private Pickup pickup | Optional parent pickup found on the prefab root. When set, grabs only work while the other hand holds it. |
private List<Pickup> pickups | The pickups currently in the group. |
private Dictionary<Interactor, Coroutine> pullCoroutines | Running CheckPull coroutine for each hand. |
private Vector3 pullDirection | Local direction the hand has to move to pull a pickup off. Defaults to up. |
private float pullDistance | How far (minimum 0.05) the hand must move along the pull direction before the server removes the pickup. |
private MethodSync syncAdd | Message (SyncA) for SyncAdd. |
private MethodSync syncAddAll | Message (SyncB) for SyncAddAll. |
private MethodSync syncSelection | Message (SyncC) for SyncSelection. |
Properties
| Member | What it is |
|---|---|
int Count { get; } | Number of pickups still in the group. |
Events
| Member | What it is |
|---|---|
event Action<Pickup> OnPulled | Fires with the pickup each time one leaves the group, on both sides. |
Methods
| Member | What it is |
|---|---|
void Add(Pickup child) | Parents a pickup to the group, makes it kinematic and forwards its grabs here. On the server also saves it as a child and syncs the add. |
override void Initialize() | Sets up the three sync messages and hooks the interactable's start and end events. |
override void OnConnected(Player player) | Resends the full pickup list. Note it sends to all chunks, not only the new player. |
void Remove(Pickup child) | Unparents a pickup, turns its physics back on and fires OnPulled. On the server syncs it and hands it to the pulling hand. |
void RemoveRandom() | Server: removes one pickup at random, if any are left. |
8 private and internal methods
| Member | What it is |
|---|---|
private IEnumerator CheckPull(Interactor interactor, Pickup pickup) (iterator) | Coroutine while a hand holds a grouped pickup: slides it along the pull direction with haptics. Server removes it past pullDistance. |
private void IfHeld(Interactor interactor, Interactable interactable, ref bool result) | Interaction filter, set when pickup is set: only allows a grab if the other hand is holding that pickup. |
private void InteractionEnded(Interactable interactable, Interactor interactor) | Stops the pull coroutine for that hand and detaches the hand from the pickup. |
private void InteractionStarted(Interactable interactable, Interactor interactor) | On the local hand, sends which pickup was grabbed and starts the pull. For remote hands, waits for SyncSelection. |
private void SyncAdd(IPlayer player, Stream stream) | Sends one pickup identifier and whether it was added or removed. Remote clients apply it. |
private void SyncAddAll(IPlayer player, Stream stream) | Sends every grouped pickup identifier (count in 8 bits, so at most 255). Remote clients add them all. |
private void SyncSelection(IPlayer player, Stream stream) | Sends which pickup a hand grabbed. The server relays it to the others, who start the grab for that remote hand. |
private void TryGrab(Interactor interactor, Pickup pickup) | Puts the pickup in the hand without a joint and starts CheckPull for that hand. |
Used in
Members of other types that take, return or hold a PullPickupGroup: