using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # Represents simplified race-progress logic for illustration purposes. # RR devices handle this automatically in UEFN; this shows the concept in real Verse syntax. race_progress_manager := class(creative_device): # Bind these in the UEFN Details panel to your placed RR devices. @editable StartFinishLine : trigger_device = trigger_device{} @editable Checkpoints : []trigger_device = array{} # Per-agent state tracked in parallel maps. var AgentLap : [agent]int = map{} var AgentLastCheckpoint : [agent]int = map{} var AgentLapStartTime : [agent]float = map{} OnBegin() : void = # Wire the start/finish trigger. StartFinishLine.TriggeredEvent.Subscribe(OnStartFinishCrossed) # Wire every checkpoint trigger, capturing its index. for (Index -> CP : Checkpoints): CP.TriggeredEvent.Subscribe( # note: spawn a task per checkpoint to handle the subscription with the captured index. agent => { spawn { OnCheckpointCrossedAsync(agent, Index) } } ) OnCheckpointCrossedAsync(Agent : agent, Index : int) : void = OnCheckpointCrossed(Agent, Index) OnStartFinishCrossed(Agent : ?agent) : void = if (Agent2 := Agent?): if (LastCP := AgentLastCheckpoint[Agent2]): # Player completed a valid lap only when all checkpoints were hit. if (LastCP = Checkpoints.Length - 1): if (StartTime := AgentLapStartTime[Agent2]): LapTime := GetSimulationElapsedTime() - StartTime Print("Lap complete for agent. Time: {LapTime}") else: Print("Lap invalid — missed a checkpoint. Resetting.") # Reset state for the next lap regardless of outcome. if (set AgentLap[Agent2] = 0) {} if (set AgentLastCheckpoint[Agent2] = -1) {} if (set AgentLapStartTime[Agent2] = GetSimulationElapsedTime()) {} OnCheckpointCrossed(Agent : agent, Index : int) : void = Expected := if (Last := AgentLastCheckpoint[Agent]) then Last + 1 else 0 if (Index = Expected): if (set AgentLastCheckpoint[Agent] = Index) {} Print("Checkpoint {Index} validated.") else: Print("Checkpoint {Index} hit out of order — ignored.")