GachaHandle
A class in Root.Township, the global namespace.
A crank or lever handle turned by grabbing it. Turning past a threshold fires onActivated; let go and it springs back. Rotation runs locally for the holder.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
GachaHandle() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
21 private and internal fields
| Member | What it is |
|---|---|
private AnimationCurve activationCurve | Maps the raw hand angle to the handle angle. |
private bool alignsPickupWithHand | Position-based option shown in the inspector. Not read in this code. |
private float angleActivationThreshold | Angle (after the curve) that activates the handle. |
private float currentAngle | Current handle angle in degrees. |
private Interactor currentInteractor | Hand holding the handle, or null. |
private Quaternion inputRotation | Accumulated hand rotation since the grab. |
private bool isActivated | True after the threshold was passed, until reset. |
private bool isInverted | Turns the handle the other way around Z. |
private bool isPositionBased | Follows the hand's position around positionCenter instead of the hand's facing. |
private bool isResettingAutomatic | Clears activation when the handle returns to rest. Otherwise call ResetActivation. |
private Vector3 latestHandForward | Hand direction or position from the last frame, in the parent's space. |
private float maxAngle | Largest angle the handle can turn (1 to 180). |
private AltaEvent onActivated | Event fired when the handle passes the threshold. |
private AltaEvent onReset | Event fired by ResetActivation. |
private Transform positionCenter | Pivot rotated in position-based mode. |
private float revertSpeed | Degrees per second the handle springs back. |
private MethodSyncStruct<float> sync | Method sync for the angle. |
private Transform target | Transform of the handle pickup, rotated in facing mode. |
private Pickup targetPickup | The pickup players grab. |
private IUnityUpdateMethod updateRotation | Registered update method (turning or reverting). |
private Matrix4x4 worldToLocal | Parent's world to local matrix captured on grab. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the angle sync message. |
override void InitializeAsServer(SpawnData spawnData) | Server: starts at angle 0. |
override void OnConnected(Player player) | Sends the current angle to a joining player. This is the only place the angle is sent. |
void ResetActivation() | If activated, clears it, snaps the handle back and fires onReset. |
9 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the handle pickup's filter, grab and release events. |
private void FilterInteraction(Interactor interactor, Interactable interactable, ref bool result) | Blocks grabbing while activated. |
private void OnDestroy() | Stops the update method. |
private void OnDrawGizmosSelected() | Empty. |
private void RevertRotation() | Each frame after release, turns the handle back to rest; at rest clears activation if isResettingAutomatic. |
private void StartCheck(Interactable pickup, Interactor interactor) | On grab, records the hand's start direction and starts UpdateRotation. |
private void StopCheck(Interactable pickup, Interactor interactor) | On release, switches to RevertRotation. |
private void Sync(IPlayer player, Stream stream, float angle) | Sync handler: clients apply the received angle to the handle. |
private void UpdateRotation() | Each frame while held, turns the handle with the hand around Z; past the threshold, activates and locks at maxAngle. |