CapPickup
A class in Root.Township, the global namespace.
The grabbable cap on a potion bottle. While the same player holds the bottle, pulling the cap far enough off removes the lid, which the server applies.
- Listed in Global namespace: C to D
- Inherits or implements
Pickup - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
CapPickup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private Pickup bottlePickup | The bottle this cap belongs to. |
private AltaCoroutine checkingPop | The running CheckPop coroutine, if any. |
private LiquidContainerLid lid | The bottle's LiquidContainerLid, removed when the cap pops. |
private Vector3 popDirection | Local direction the hand has to pull to pop the cap. |
private float popDistance | How far (0.1 by default) the hand has to pull along popDirection to pop the cap. |
private MethodSync syncCapRemoved | Method sync that sends the cap removal from client to server. |
Methods
| Member | What it is |
|---|---|
override bool AssessScore(Interactor interactor, out float score) | Only lets the cap be grabbed while its lid is on and the bottle is held by the same player. Gives it top priority when allowed. |
override void Initialize() | Creates the PotionCapRemoved method sync. |
protected override void Awake() | Hooks InteractionStarted to start checking for the pop. |
protected override void OnDisable() | Turns off the cap's colliders. |
protected override void OnEnable() | Turns the cap's colliders back on. |
protected override void Start() | Hooks the bottle's release and dock events. |
6 private and internal methods
| Member | What it is |
|---|---|
private IEnumerator CheckPop() (iterator) | Local coroutine: once the hand has moved popDistance along popDirection, lets go and tells the server the cap came off. |
private void Release(Interactable interactable, Interactor interactor) | Lets go of the cap when the bottle is let go. |
private void ReleaseDocked(Interactor interactor, Pickup pickup, PickupDock dock) | Lets go of the cap when the bottle is docked. |
private void StartCheck(Interactable interactable, Interactor interactor) | Restarts the pop check coroutine when the local player grabs the cap. |
private void SyncCapRemoved(IPlayer player, Stream stream) | Server: removes the lid when the message comes from the player who last held the cap. |
private void ToggleColliders(bool isEnabled) | Turns all the cap's colliders on or off. |