Skip to main content

ClimbingHandlerAnalytics

A class in Root.Township, Features.Climbing.

Editor-only climbing telemetry: records jump-off speeds and stamina used per climb for the local player. Sending to the API is stubbed out; Ctrl+U writes the records to CSV files in the data folder.

Constructors​

MemberWhat it is
ClimbingHandlerAnalytics()Creates a ClimbingHandlerAnalytics with default values.

Fields​

13 private and internal fields
MemberWhat it is
private IAnalyticsService analyticsServiceThe injected analytics service. Not used in this build.
private float climbingEndTimerReal time at which the grace period after letting go runs out, or 0.
private IUnityUpdateMethod climbingMovementTrackHandle of the registered per-frame tracking method while a climb is recorded.
private const float gracePeriodForContinuingClimbing0.5 seconds of not climbing before a climb record is finished.
private ClimbingHandler handlerThe local player's climbing handler being tracked.
private List<float> jumpVelocityRecordsRecorded jump-off speeds.
private Vector3 lastPositionLocomotion position on the last tick.
private const int minimumRecordsToSendToAPI10, the record count meant to trigger a send.
private const float minimumVelocityToRecordSquaredSquared speed below which a let-go is not recorded as a jump.
private ClimbingHandlerAnalytics.StaminaTracker staminaTrackerLeftHandTracks stamina used by the left hand this climb.
private ClimbingHandlerAnalytics.StaminaTracker staminaTrackerRightHandTracks stamina used by the right hand this climb.
private List<StaminaUsageRecord> staminaUsageRecordsRecorded climbs with distance and stamina used.
private float travelledDistanceDistance climbed. Never reset between climbs in this code.

Methods​

MemberWhat it is
void Inject(IAnalyticsService analyticsService)Receives the analytics service from VContainer.
10 private and internal methods
MemberWhat it is
private async void CheckForCurrentPlayer(PlayerController currentPlayer)When the current player changes to a PlayerCharacter with a Climber, sets up tracking on its climbing handler.
private bool CheckGracePeriodForFinishClimbing()Returns true until 0.5 seconds after climbing stops, so short let-gos do not end the climb record.
private void FinishClimbingTrack()Stops tracking and stores the climb's distance and per-hand stamina used.
private void HandStartedClimbing()Starts per-climb tracking of stamina and position when the first hand grabs.
private void HandStoppedClimbing()When both hands have let go, records the jump-off speed if it is above the minimum.
private void PrintLocal(Key key)On Ctrl+U, writes the jump and stamina records to two CSV files in Application.dataPath.
private void SendAnalyticsEventIfFull()Meant to send once there are 10 records; its body is empty in this build.
private void Setup(ClimbingHandler handler)Hooks both hands' climbing start and stop events and registers the Ctrl+U dump key.
private void TickPositionTracking()Adds the distance moved since last frame to travelledDistance.
private void TrackClimbingMovement()Per-frame update during a climb: ticks stamina and distance, or ends the record after the grace period.