ClimbingHand
A class in Root.Township, Features.Climbing.
One hand's climbing state: grabbing a climbable surface, holding the grip and working out how hard the hand pulls the body. Made per hand by ClimbingHandler; the grip is synced to other players.
- Listed in ATT, Features and other game namespaces
Constructors
| Member | What it is |
|---|---|
ClimbingHand(Controller controller, ClimbingHandler handler, PlayerUnlock unlock) | Creates a ClimbingHand from controller, handler and unlock. |
Fields
31 private and internal fields
| Member | What it is |
|---|---|
private const int CheckFrameCount | Frames a closed hand keeps trying to grab after a failed first try (5). |
private int checkFrames | Frames left to keep retrying a grab. |
private IClimbable climbable | The climbable currently gripped. |
private Collider collider | The collider currently gripped. |
private int currentlyGrabbingObjectLayer | Original layer of the gripped object, synced to others. |
private Vector3 currentPressure | Smoothed pressure the hand is applying this frame. |
private float currentPressureMagnitude | Size of currentPressure, exposed as CurrentForce while climbing. |
private int frameIndex | Index into lastFrames. |
private readonly MemoizeComponentOne<IClimbable> getColliderClimbable | Cached lookup of IClimbable on a collider. |
private readonly MemoizeComponentOne<IClimbable> getRigidbodyClimbable | Cached lookup of IClimbable on a collider's rigidbody. |
private readonly Vector3 grabPositionOffset | The controller's grip point offset from the hand. |
private static readonly Collider[] grabResults | Shared buffer for overlap results. |
private float gravityBoost | How much of gravity skips the pressure cap, set from the climbable and surface normal. |
private RelativePoint? grip | Where the hand holds, relative to the gripped collider; null when not climbing. |
private readonly ClimbingHandler handler | The climbing handler that owns this hand. |
private float incorrectHandStrengthModifier | Grip strength from 0 to 1 that drops when the hand pulls wrongly; the grip breaks at 0. |
private bool isHandClosed | Whether the interact input is held. |
private bool isHanging | Whether the arm is at full stretch this frame. |
private Vector3 lastArmDirection | Direction from shoulder to grip, from the last check. |
private float lastArmLength | Distance from shoulder to grip, capped at the hang distance. |
private int lastFrameProcessRan | Declared but not used. |
private readonly Vector3[] lastFrames | Recent hand positions used for pressure; holds one frame. |
private readonly Transform masterHand | Root of the tracked hand. |
private readonly Player player | The network player who owns the hand, used to check sync permission. |
private readonly Transform shoulder | The arm's shoulder (or the head if there is no arm IK). |
private RelativePoint shoulderCache | Shoulder position relative to the gripped collider from the last frame. |
private static SphereCollider sphere | Shared sphere collider used for penetration tests. |
private readonly MethodSync sync | Method sync for grip and release messages. |
private readonly ThrottledMethodSync syncImmediateGrabFail | Throttled sync for failed grabs. |
private bool syncVoluntaryBreak | Whether the last release was voluntary, sent with the release so others skip the break effect. |
private readonly PlayerUnlock unlock | Unlock required to climb, or null. |
Properties
| Member | What it is |
|---|---|
Vector3 ActualHandPosition { get; set; } | Where the real (tracked) hand is while gripping, corrected for body velocity. Used for stamina drain by distance. |
Controller Controller { get; } | The hand's Controller. |
float CurrentForce { get; } | Size of the pressure this hand applied this frame. 0 when not climbing. |
Vector3 CurrentGripPosition { get; } | World position of the grip point. Zero when not climbing. |
Quaternion CurrentGripRotation { get; } | World rotation of the grip point. Identity when not climbing. |
int CurrentlyGrabbingObjectLayer { get; } | Physics layer of the object last grabbed. Picks the stamina use multiplier. |
bool IsClimbing { get; } | True while the hand holds a grip. |
bool IsHanging { get; } | True while climbing and the arm is stretched to the hang distance. |
Vector3 LastArmDirection { get; } | Direction from shoulder to grip at the last hang check. |
Vector3 OldGripPosition { get; private set; } | Grip world position from before this frame's update. |
Quaternion OldGripRotation { get; private set; } | Grip world rotation from before this frame's update. |
Events
| Member | What it is |
|---|---|
event Action startedClimbing | Raised when the hand takes a grip. |
event Action stoppedClimbing | Raised when the hand lets go. |
Methods
14 private and internal methods
| Member | What it is |
|---|---|
private void BreakGrip() | Lets go: detaches the hand, plays the grab broken effect if not voluntary, syncs it and raises stoppedClimbing. |
private bool CheckGrab(float armReduce = 0) | Looks for a climbable surface near the hand within arm reach and grips it if found. Retries once with a shorter reach. |
private bool CheckStreamReadPermission(IPlayer player, Stream stream) | True when reading: on the server only from the owning player, always on clients. |
private Vector3 EvaluateArmStrength(Vector3 pressure, float pressureDirectionPower) | Scales a pressure by how closely it lines up with the arm direction. |
private float EvaluateBestGrip(int overlap) | Picks the overlapping climbable with the highest grip priority, falling back to the default climbable; returns that priority. |
private Vector3 GetClosestPointToGrip(bool isRight, Quaternion handRotation, ref Vector3 handPosition) | Finds the closest surface point to the palm, using penetration tests for terrain and concave meshes. |
private void GetGrabAssistBlock(ref bool isBlocked) | Blocks the interactor's grab assist while the player is climbing. |
private bool IsReleasingCurrentClimbableImmediately() | True when the current climbable can't be held and releases at once. |
private void PlayReleaseImmediatelyEffects() | Plays the grab-broken effect and syncs the failed grab to others. |
private void ProcessTightGrip(RaycastHit hit, bool isRight, Quaternion handRotation) | Attaches the hand to the hit point facing the surface, plays grab effects and syncs the new grip. |
private void Serialize(IPlayer player, Stream stream) | Syncs grip or release: climbable entity, position, rotation, layer and grip pose. The server only accepts it from the owner and relays it. |
private void SerializePosition(Stream stream, ref Vector3 position) | Syncs the grip position with the controller's chunk. |
private bool ShouldBreakCurrentGrip(bool hasStamina) | True when out of stamina or the climbable releases immediately. |
private void SyncImmediateGrabFail(IPlayer player, Stream stream) | Plays the grab-broken effect for others; the server relays it. |
Used in
Members of other types that take, return or hold a ClimbingHand: