public MDReplicatorNetworkKeyIdMap(bool ShowBufferSize) { if (ShowBufferSize) { MDOnScreenDebug.AddOnScreenDebugInfo(DEBUG_CAT, "NetworkIDToKeyMap Buffer Size", () => ClockedValueBuffer.Count.ToString()); } }
///<summary>Starts the player ping request cycle</summary> private void StartClientPingCycle() { if (!GameSynchronizer.IsActivePingEnabled()) { return; } // Onscreen debug for ping MDOnScreenDebug.AddOnScreenDebugInfo(DEBUG_CAT, $"Ping({PeerId})", () => MDStatics.GetGameSynchronizer().GetPlayerPing(PeerId).ToString()); PingTimer = GameSynchronizer.CreateUnpausableTimer($"PingTimer{PeerId}", false, GameSynchronizer.GetPingInterval(), false, GameSynchronizer, MDGameSynchronizer.METHOD_ON_PING_TIMER_TIMEOUT, PeerId); PingTimer.Start(); }
public void Initialize() { MDLog.AddLogCategoryProperties(LOG_CAT, new MDLogProperties(MDLogLevel.Info)); MDOnScreenDebug.AddOnScreenDebugInfo("KeyToMemberMap Size", () => KeyToMemberMap.Count.ToString()); MDOnScreenDebug.AddOnScreenDebugInfo("NetworkIDToKeyMap Size", () => NetworkIdKeyMap.GetCount().ToString()); this.GetGameSession().OnSessionEndedEvent += OnSessionEnded; this.GetGameSession().OnPlayerJoinedEvent += OnPlayerJoined; PauseMode = PauseModeEnum.Process; RpcSenderId = -1; GroupManager = new MDReplicatorGroupManager(GetReplicationFrameInterval()); NetworkIdKeyMap = new MDReplicatorNetworkKeyIdMap(ShouldShowBufferSize()); GameClock = this.GetGameClock(); }
private void OnSessionStartedEvent() { if (this.IsClient()) { // Add max ping information between this client and any other client // Roundtrip is: client 1 -> server -> client 2 -> server -> client 1. // TODO: Max ping should be not identical for each player we ping MDOnScreenDebug.AddOnScreenDebugInfo(DEBUG_CAT, "MaxRoundtripPing: ", () => MaxPing.ToString()); PauseGame(); SynchronizationState = SynchronizationStates.SYNCHRONIZING_IN_PROGRESS; } else { SynchronizationState = SynchronizationStates.SYNCRHONIZED; } // Reset to tick 0 at start of session GameClock?.SetCurrentTick(0); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { MDLog.AddLogCategoryProperties(LOG_CAT, new MDLogProperties(MDLogLevel.Info)); LoadConfig(); GameSynchronizer = this.GetGameSynchronizer(); CurrentRemoteTickOffset = MinimumOffset; CurrentRemoteTickOffsetTarget = MinimumOffset; LastRemoteTickOffset = MinimumOffset; GameSynchronizer.OnPlayerPingUpdatedEvent += OnPlayerPingUpdatedEvent; // TODO: Remove this, only here for debug MDOnScreenDebug.AddOnScreenDebugInfo("GameClock Current Tick", () => CurrentTick.ToString()); MDOnScreenDebug.AddOnScreenDebugInfo("OS GetTickMsec", () => OS.GetTicksMsec().ToString()); MDOnScreenDebug.AddOnScreenDebugInfo("GameClock Remote Offset", () => $"{CurrentRemoteTickOffset} ({(int) (CurrentRemoteTickOffset * TICK_INTERVAL_MILLISECONDS)} Msec)"); MDOnScreenDebug.AddOnScreenDebugInfo("GameClock Remote Target Offset", () => $"{CurrentRemoteTickOffsetTarget} ({(int) (CurrentRemoteTickOffsetTarget * TICK_INTERVAL_MILLISECONDS)} Msec)"); }