private void UpdateRaceData(RaceMessage msg) { if (Race == null) { Race = msg.Race; RaceChanged?.Invoke(this, new EventArgs()); GoalChanged?.Invoke(this, new EventArgs()); UserListRefreshed?.Invoke(this, new EventArgs()); return; } switch (msg.Race?.State) { case RaceState.Starting: Model.CurrentState.Run.Offset = -msg.Race.StartDelay; Model.Start(); break; case RaceState.Cancelled: Model.Reset(); break; } if (RacetimeAPI.Instance.Authenticator.Identity == null) { return; } if ((Race.State == RaceState.Open || Race.State == RaceState.OpenInviteOnly) && Model.CurrentState.Run.Offset < TimeSpan.Zero && (msg.Race.StartDelay != Race.StartDelay)) { Model.CurrentState.Run.Offset = -msg.Race.StartDelay; } Race = msg.Race ?? Race; var newIdentity = msg.Race.Entrants?.FirstOrDefault(x => x.Name.ToLower() == RacetimeAPI.Instance.Authenticator.Identity.Name?.ToLower()); switch (newIdentity?.Status) { case UserStatus.Racing: Model.CurrentState.Run.Offset = DateTime.UtcNow - msg.Race.StartedAt; if (Model.CurrentState.CurrentPhase == TimerPhase.Ended) { Model.UndoSplit(); } if (Model.CurrentState.CurrentPhase == TimerPhase.Paused) { Model.Pause(); } if (Model.CurrentState.CurrentPhase == TimerPhase.NotRunning) { Model.Start(); } break; case UserStatus.Disqualified: Model.Reset(); break; case UserStatus.Finished: Model.Split(); break; case UserStatus.Forfeit: Model.Reset(); break; } RaceChanged?.Invoke(this, new EventArgs()); StateChanged?.Invoke(this, Race.State); UserListRefreshed?.Invoke(this, new EventArgs()); GoalChanged?.Invoke(this, new EventArgs()); }
void RaceChannel_TopicChanged(object sender, EventArgs e) { ChannelTopic = RaceChannel.Topic; GoalChanged?.Invoke(null, null); }
private void OnGoalChanged(GoalChangedEventArgs e) { GoalChanged?.Invoke(SourceGrid, e); }