Staged Countdown Test
Class-based test mode implementation for the staged countdown system. Simulates rally epoch timing and scheduled event scheduling without requiring a full rally loop manager. Used for testing countdow
Class-based test mode implementation for the staged countdown system. Simulates rally epoch timing and scheduled event scheduling without requiring a full rally loop manager. Used for testing countdown behavior in isolation.
Constructor
local StagedCountdownTest = require('gameplay/rally/loop/stagedCountdownTest')
local test = StagedCountdownTest()Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | () | nil | Reads environment time, calculates initial scheduled event |
calculateScheduledEventTime | () | nil | Sets next event to upcoming minute boundary (skips if <15s away) |
reschedule | (slotSizeMinutes, rescheduleCount, maxReschedules, defaultWarningTimes, warningsTriggered) | success, newTime | Reschedules to next minute boundary + slot offset |
getWallClockTime | () | number|nil | Current wall clock in seconds of day |
Internals
State
| Field | Description |
|---|---|
epoch | Simulated rally epoch time (starts at 0) |
environmentStartTimeSecs | Environment time of day converted to seconds |
scheduledEventTime | Next event time in epoch seconds |
Environment Time Conversion
Same formula as rallyLoopManager:
local timeIn24 = tod.time * 24
local adjustedHours = (timeIn24 + 12) % 24 -- noon = 0 in tod system
self.environmentStartTimeSecs = adjustedHours * 3600Scheduling Logic
- Computes current wall clock:
environmentStartTimeSecs + epoch - Finds next minute boundary:
math.ceil(currentWallClock / 60) * 60 - If less than 15 seconds until that boundary, skips to the minute after
- Converts back to epoch:
targetWallClock - environmentStartTimeSecs
Rescheduling
When called by the countdown node after a reschedule request:
- Converts old scheduled time to wall clock
- Finds next minute boundary after old time
- Adds
slotSizeMinutes * 60seconds - Converts back to epoch
- Marks any warning times that are already in the past as triggered
How It Works
- On init, reads
core_environment.getTimeOfDay()to establish environment start time - Calculates first scheduled event at the next comfortable minute boundary
- External code advances
test.epocheach frame - Countdown node reads
test.scheduledEventTimeandtest.epochto determine countdown state - If reschedule is needed (vehicle not staged), calls
reschedule()to push to next slot
Usage Example
local StagedCountdownTest = require('gameplay/rally/loop/stagedCountdownTest')
local test = StagedCountdownTest()
-- Simulate time advancement
test.epoch = test.epoch + dtSim
-- Check if event is approaching
local timeUntil = test.scheduledEventTime - test.epoch
-- Reschedule if needed
local ok, newTime = test:reschedule(1, 0, 3, {10, 5, 3}, {})See Also
- Rally Loop Penalties - Related reference
- Rally Attempts - Related reference
- Rally Event Log - Related reference
- Gameplay Systems Guide - Guide
Speeding Detector
Class-based speed monitoring system for rally road sections. Samples vehicle speed into a ring buffer, computes a rolling average, and applies stochastic speeding penalties with configurable probabili
Staged Countdown Utilities
Shared utility functions for the staged countdown system. Provides debug drawing helpers (plane visualization, vehicle-to-plane distance, vehicle point), vehicle freeze/unfreeze controls, and ImGui de