public override void AddLocalInput(BackrollPlayerHandle player, ref T input) { GameInput gameInput; gameInput = GameInput.Create <T>(GameInput.kNullFrame, ref input); _current_input = gameInput; }
// Called only as the result of a local decision to disconnect. The remote // decisions to disconnect are a result of us parsing the peer_connect_settings // blob in every endpoint periodically. public override void DisconnectPlayer(BackrollPlayerHandle player) { int queue = PlayerHandleToQueue(player); if (_localConnectStatus[queue].Disconnected) { throw new BackrollException(BackrollErrorCode.PlayerDisconnected); } if (_players[queue].IsLocal) { int current_frame = _sync.FrameCount; // xxx: we should be tracking who the local player is, but for now assume // that if the endpoint is not initalized, this must be the local player. Debug.LogFormat("Disconnecting local player {} at frame {} by user request.", queue, _localConnectStatus[queue].LastFrame); for (int i = 0; i < PlayerCount; i++) { if (!_players[i].IsLocal) { DisconnectPlayerQueue(i, current_frame); } } } else { Debug.LogFormat("Disconnecting queue {} at frame {} by user request.", queue, _localConnectStatus[queue].LastFrame); DisconnectPlayerQueue(queue, _localConnectStatus[queue].LastFrame); } }
protected int PlayerHandleToQueue(BackrollPlayerHandle player) { int offset = ((int)player.Id - 1); if (offset < 0 || offset >= PlayerCount) { throw new BackrollException(BackrollErrorCode.InvalidPlayerHandle); } return(offset); }
public override void AddLocalInput(BackrollPlayerHandle player, ref T playerInput) { int queue; GameInput input; if (_sync.InRollback) { throw new BackrollException(BackrollErrorCode.InRollback); } if (IsSynchronizing) { throw new BackrollException(BackrollErrorCode.NotSynchronized); } queue = PlayerHandleToQueue(player); input = GameInput.Create <T>(GameInput.kNullFrame, ref playerInput); // Feed the input for the current frame into the synchronzation layer. if (!_sync.AddLocalInput(queue, ref input)) { throw new BackrollException(BackrollErrorCode.PredictionThreshold); } if (input.Frame == GameInput.kNullFrame) { return; } // xxx: <- comment why this is the case // Update the local connect status state to indicate that we've got a // confirmed local frame for this player. this must come first so it // gets incorporated into the next packet we send. Debug.LogFormat("setting local connect status for local queue {} to {}", queue, input.Frame); _localConnectStatus[queue].LastFrame = input.Frame; // Send the input to all the remote players. for (int i = 0; i < PlayerCount; i++) { if (!_players[i].IsLocal) { _players[i].SendInput(input); } } }
public override void SetFrameDelay(BackrollPlayerHandle player, int Frame_delay) => throw new NotSupportedException();
public override BackrollNetworkStats GetNetworkStats(BackrollPlayerHandle player) => throw new NotSupportedException();
public override void DisconnectPlayer(BackrollPlayerHandle player) => throw new NotSupportedException();
public override void SetFrameDelay(BackrollPlayerHandle player, int delay) { _sync.SetFrameDelay(PlayerHandleToQueue(player), delay); }
public override BackrollNetworkStats GetNetworkStats(BackrollPlayerHandle player) { return(_players[PlayerHandleToQueue(player)].GetNetworkStats()); }
public override void AddLocalInput(BackrollPlayerHandle player, ref T input) { }
public abstract void AddLocalInput(BackrollPlayerHandle player, ref T input);
// Change the amount of frames ggpo will delay local input. Must be called // before the first call to SynchronizeInput. public abstract void SetFrameDelay(BackrollPlayerHandle player, int frame_delay);
// Used to fetch some statistics about the quality of the network connection. // // player - The player handle returned from the ggpo_add_player function you // used to add the remote player. // // Returns the network statistics. public abstract BackrollNetworkStats GetNetworkStats(BackrollPlayerHandle player);
// Disconnects a remote player from a game. Will return Backroll_ERRORCODE_PLAYER_DISCONNECTED // if you try to disconnect a player who has already been disconnected. public abstract void DisconnectPlayer(BackrollPlayerHandle player);