コード例 #1
0
ファイル: DateTimeSystem.cs プロジェクト: Orden4/WCSharp
        private void HandleDateTimeSyncMessage(DateTimeSyncMessage message)
        {
            this.timestamps[message.PlayerId] = new WcDateTime(message.Seconds);

            if (Util.EnumeratePlayers(PLAYER_SLOT_STATE_PLAYING, MAP_CONTROL_USER).All(x => this.timestamps.ContainsKey(GetPlayerId(x))))
            {
                var sync = this.method switch
                {
                    DateTimeSyncMethod.Earliest => ResolveEarliest(),
                    DateTimeSyncMethod.Latest => ResolveLatest(),
                    DateTimeSyncMethod.Average => ResolveAverage(),
                    _ => ResolveBestFit(),
                };

                SyncSystem.Unsubscribe <DateTimeSyncMessage>(HandleDateTimeSyncMessage);
                WcDateTime.StoreSynchronisedTime(sync.TotalSeconds, this.method);

                this.action?.Invoke(sync);
            }
        }
コード例 #2
0
 /// <inheritdoc/>
 public void Dispose()
 {
     SyncSystem.Unsubscribe <SaveLoadedMessage <T> >(HandleSaveLoadedMessage);
 }