private void ApplyTransformClientRpc(Vector3 position, Vector3 eulerAngles, ClientRpcParams rpcParams = default) { if (enabled) { ApplyTransformInternal(position, Quaternion.Euler(eulerAngles)); } }
public override void NetworkStart() { base.NetworkStart(); // Bind to OnValueChanged to display in log the remaining lives of this player // And to update InvadersGame singleton client-side m_Lives.OnValueChanged += OnLivesChanged; m_Score.OnValueChanged += OnScoreChanged; if (IsServer) { m_OwnerRPCParams = new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new[] { OwnerClientId } } } } ; if (!InvadersGame.Singleton) { InvadersGame.OnSingletonReady += SubscribeToDelegatesAndUpdateValues; } else { SubscribeToDelegatesAndUpdateValues(); } if (IsServer) { SceneTransitionHandler.sceneTransitionHandler.OnClientLoadedScene += SceneTransitionHandler_clientLoadedScene; } SceneTransitionHandler.sceneTransitionHandler.OnSceneStateChanged += SceneTransitionHandler_sceneStateChanged; }
public void __endSendClientRpc(NetworkSerializer serializer, ClientRpcParams clientRpcParams, RpcDelivery rpcDelivery) #endif #pragma warning restore IDE1006 // restore naming rule violation check { if (serializer == null) { return; } var rpcQueueContainer = NetworkManager.RpcQueueContainer; if (IsHost) { ulong[] clientIds = clientRpcParams.Send.TargetClientIds ?? NetworkManager.ConnectedClientsList.Select(c => c.ClientId).ToArray(); if (clientRpcParams.Send.TargetClientIds != null && clientRpcParams.Send.TargetClientIds.Length == 0) { clientIds = NetworkManager.ConnectedClientsList.Select(c => c.ClientId).ToArray(); } var containsServerClientId = clientIds.Contains(NetworkManager.ServerClientId); if (containsServerClientId && clientIds.Length == 1) { rpcQueueContainer.EndAddQueueItemToFrame(serializer.Writer, RpcQueueHistoryFrame.QueueFrameType.Inbound, clientRpcParams.Send.UpdateStage); return; } } rpcQueueContainer.EndAddQueueItemToFrame(serializer.Writer, RpcQueueHistoryFrame.QueueFrameType.Outbound, NetworkUpdateStage.PostLateUpdate); }
public void __endSendClientRpc(NetworkSerializer serializer, ClientRpcParams clientRpcParams, RpcDelivery rpcDelivery) #endif { if (serializer == null) { return; } var rpcQueueContainer = NetworkManager.Singleton.RpcQueueContainer; if (IsHost) { ulong[] ClientIds = clientRpcParams.Send.TargetClientIds ?? NetworkManager.Singleton.ConnectedClientsList.Select(c => c.ClientId).ToArray(); if (clientRpcParams.Send.TargetClientIds != null && clientRpcParams.Send.TargetClientIds.Length == 0) { ClientIds = NetworkManager.Singleton.ConnectedClientsList.Select(c => c.ClientId).ToArray(); } var ContainsServerClientId = ClientIds.Contains(NetworkManager.Singleton.ServerClientId); if (ContainsServerClientId && ClientIds.Length == 1) { rpcQueueContainer.EndAddQueueItemToFrame(serializer.Writer, RpcQueueHistoryFrame.QueueFrameType.Inbound, clientRpcParams.Send.UpdateStage); return; } } rpcQueueContainer.EndAddQueueItemToFrame(serializer.Writer, RpcQueueHistoryFrame.QueueFrameType.Outbound, NetworkUpdateStage.PostLateUpdate); }
public void PongClientRPC(int pingId, ClientRpcParams clientParams = default) { var startTime = m_PingHistoryStartTimes[pingId]; m_PingHistoryStartTimes.Remove(pingId); m_MovingWindow.Enqueue(Time.realtimeSinceStartup - startTime); UpdateRTTSlidingWindowAverage(); }
private void PingMySelfClientRpc(int currentCount, ClientRpcParams parameters = default) { Debug.Log($"{nameof(PingMySelfClientRpc)}: [HostServer][ClientRpc][{currentCount}] invoked during the {parameters.Receive.UpdateStage} stage. (previous output line should confirm this)"); m_ClientStagesReceived.Add(parameters.Receive.UpdateStage); //If we reached the last update state, then go ahead and increment our iteration counter if (parameters.Receive.UpdateStage == NetworkUpdateStage.PostLateUpdate) { m_Counter++; } m_ClientReceivedRpc = true; }
public override void NetworkStart() { bool isClientOnly = IsClient && !IsServer; if (!IsOwner && isClientOnly) // we don't want to track player ghost stats, only our own { Destroy(this); return; } if (IsOwner) { CreateNetworkStatsText(); } m_PongClientParams = new ClientRpcParams() { Send = new ClientRpcSendParams() { TargetClientIds = new[] { OwnerClientId } } }; }
private void OnSendNoParametersClientRpc(ClientRpcParams parameters = default) { m_MultiParameterNoneCount++; }
// RuntimeAccessModifiersILPP will make this `protected` internal NetworkSerializer __beginSendClientRpc(ClientRpcParams clientRpcParams, RpcDelivery rpcDelivery)
public void NotifyDeathClientRpc(ClientRpcParams clientParams) { m_HasGameStarted = false; InvadersGame.Singleton.DisplayGameOverText("You Are Dead!"); }
private void OnNavMeshCorrectionUpdateClientRpc(Vector3 velocity, Vector3 position, ClientRpcParams rpcParams = default) { m_Agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage)); m_Agent.velocity = velocity; }
public NetworkSerializer __beginSendClientRpc(ClientRpcParams clientRpcParams, RpcDelivery rpcDelivery) #endif #pragma warning restore IDE1006 // restore naming rule violation check { PooledNetworkWriter writer; // This will start a new queue item entry and will then return the writer to the current frame's stream var rpcQueueContainer = NetworkManager.RpcQueueContainer; var isUsingBatching = rpcQueueContainer.IsUsingBatching(); var transportChannel = rpcDelivery == RpcDelivery.Reliable ? NetworkChannel.ReliableRpc : NetworkChannel.UnreliableRpc; ulong[] clientIds = clientRpcParams.Send.TargetClientIds ?? NetworkManager.ConnectedClientsList.Select(c => c.ClientId).ToArray(); if (clientRpcParams.Send.TargetClientIds != null && clientRpcParams.Send.TargetClientIds.Length == 0) { clientIds = NetworkManager.ConnectedClientsList.Select(c => c.ClientId).ToArray(); } //NOTES ON BELOW CHANGES: //The following checks for IsHost and whether the host client id is part of the clients to recieve the RPC //Is part of a patch-fix to handle looping back RPCs into the next frame's inbound queue. //!!! This code is temporary and will change (soon) when NetworkSerializer can be configured for mutliple NetworkWriters!!! var containsServerClientId = clientIds.Contains(NetworkManager.ServerClientId); if (IsHost && containsServerClientId) { //Always write to the next frame's inbound queue writer = rpcQueueContainer.BeginAddQueueItemToFrame(RpcQueueContainer.QueueItemType.ClientRpc, Time.realtimeSinceStartup, transportChannel, NetworkManager.ServerClientId, null, RpcQueueHistoryFrame.QueueFrameType.Inbound, clientRpcParams.Send.UpdateStage); //Handle sending to the other clients, if so the above notes explain why this code is here (a temporary patch-fix) if (clientIds.Length > 1) { //Set the loopback frame rpcQueueContainer.SetLoopBackFrameItem(clientRpcParams.Send.UpdateStage); //Switch to the outbound queue writer = rpcQueueContainer.BeginAddQueueItemToFrame(RpcQueueContainer.QueueItemType.ClientRpc, Time.realtimeSinceStartup, transportChannel, NetworkObjectId, clientIds, RpcQueueHistoryFrame.QueueFrameType.Outbound, NetworkUpdateStage.PostLateUpdate); if (!isUsingBatching) { writer.WriteByte(NetworkConstants.CLIENT_RPC); // MessageType } } else { if (!isUsingBatching) { writer.WriteByte(NetworkConstants.CLIENT_RPC); // MessageType } } } else { writer = rpcQueueContainer.BeginAddQueueItemToFrame(RpcQueueContainer.QueueItemType.ClientRpc, Time.realtimeSinceStartup, transportChannel, NetworkObjectId, clientIds, RpcQueueHistoryFrame.QueueFrameType.Outbound, NetworkUpdateStage.PostLateUpdate); if (!isUsingBatching) { writer.WriteByte(NetworkConstants.CLIENT_RPC); // MessageType } } writer.WriteUInt64Packed(NetworkObjectId); // NetworkObjectId writer.WriteUInt16Packed(NetworkBehaviourId); // NetworkBehaviourId writer.WriteByte((byte)clientRpcParams.Send.UpdateStage); // NetworkUpdateStage return(writer.Serializer); }
private void OnNavMeshStateUpdateClientRpc(Vector3 destination, Vector3 velocity, Vector3 position, ClientRpcParams rpcParams = default) { m_Agent.Warp(WarpOnDestinationChange ? position : Vector3.Lerp(transform.position, position, DriftCorrectionPercentage)); m_Agent.SetDestination(destination); m_Agent.velocity = velocity; }
private void OnSendDirectCounterClientRpc(int counter, ClientRpcParams parameters = default) { m_GlobalDirectCounter = counter; }
private void OnSendMultiParametersClientRpc(int count, float floatValue, long longValue, ClientRpcParams parameters = default) { if (m_MultiParameterIntValue == count && floatValue == m_MultiParameterFloatValue && m_MultiParameterLongValue == longValue) { m_MultiParameterValuesCount++; } else { m_MultiParameterValuesCount--; } m_MultiParameterIntValue = Random.Range(0, 100); m_MultiParameterFloatValue = Random.Range(0.0f, 1.0f); m_MultiParameterLongValue = (long)Random.Range(0, 10000); }
public void FatalLobbyErrorClientRpc(FatalLobbyError error, ClientRpcParams clientParams = default) { OnFatalLobbyError?.Invoke(error); }
// RuntimeAccessModifiersILPP will make this `protected` internal void __endSendClientRpc(NetworkSerializer serializer, ClientRpcParams clientRpcParams, RpcDelivery rpcDelivery)