mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
use C#7 out variable declaration
This commit is contained in:
parent
b45d52c765
commit
6ab0a0a7c2
@ -337,8 +337,7 @@ static void OnDisconnected(int connectionId)
|
||||
{
|
||||
if (LogFilter.Debug) { Debug.Log("Server disconnect client:" + connectionId); }
|
||||
|
||||
NetworkConnection conn;
|
||||
if (connections.TryGetValue(connectionId, out conn))
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnection conn))
|
||||
{
|
||||
conn.Disconnect();
|
||||
RemoveConnection(connectionId);
|
||||
@ -365,8 +364,7 @@ static void OnDisconnected(NetworkConnection conn)
|
||||
|
||||
static void OnDataReceived(int connectionId, byte[] data)
|
||||
{
|
||||
NetworkConnection conn;
|
||||
if (connections.TryGetValue(connectionId, out conn))
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnection conn))
|
||||
{
|
||||
OnData(conn, data);
|
||||
}
|
||||
@ -459,8 +457,7 @@ public static void ClearHandlers()
|
||||
|
||||
public static void SendToClient(int connectionId, short msgType, MessageBase msg)
|
||||
{
|
||||
NetworkConnection conn;
|
||||
if (connections.TryGetValue(connectionId, out conn))
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnection conn))
|
||||
{
|
||||
conn.Send(msgType, msg);
|
||||
return;
|
||||
@ -483,8 +480,7 @@ public static void SendToClientOfPlayer(NetworkIdentity identity, short msgType,
|
||||
|
||||
public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject player, Guid assetId)
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(player, out identity))
|
||||
if (GetNetworkIdentity(player, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
}
|
||||
@ -498,8 +494,7 @@ public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject
|
||||
|
||||
public static bool AddPlayerForConnection(NetworkConnection conn, GameObject player, Guid assetId)
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(player, out identity))
|
||||
if (GetNetworkIdentity(player, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
}
|
||||
@ -798,8 +793,7 @@ static void OnCommandMessage(NetworkMessage netMsg)
|
||||
{
|
||||
CommandMessage message = netMsg.ReadMessage<CommandMessage>();
|
||||
|
||||
NetworkIdentity identity;
|
||||
if (!NetworkIdentity.spawned.TryGetValue(message.netId, out identity))
|
||||
if (!NetworkIdentity.spawned.TryGetValue(message.netId, out NetworkIdentity identity))
|
||||
{
|
||||
Debug.LogWarning("Spawned object not found when handling Command message [netId=" + message.netId + "]");
|
||||
return;
|
||||
@ -916,8 +910,7 @@ public static void DestroyPlayerForConnection(NetworkConnection conn)
|
||||
HashSet<uint> tmp = new HashSet<uint>(conn.clientOwnedObjects);
|
||||
foreach (uint netId in tmp)
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (NetworkIdentity.spawned.TryGetValue(netId, out identity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity))
|
||||
{
|
||||
Destroy(identity.gameObject);
|
||||
}
|
||||
@ -1022,8 +1015,7 @@ public static void Spawn(GameObject obj, Guid assetId)
|
||||
{
|
||||
if (VerifyCanSpawn(obj))
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(obj, out identity))
|
||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
}
|
||||
@ -1066,8 +1058,7 @@ public static void Destroy(GameObject obj)
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(obj, out identity))
|
||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
||||
{
|
||||
DestroyObject(identity, true);
|
||||
}
|
||||
@ -1081,8 +1072,7 @@ public static void UnSpawn(GameObject obj)
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(obj, out identity))
|
||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
||||
{
|
||||
DestroyObject(identity, false);
|
||||
}
|
||||
@ -1090,9 +1080,7 @@ public static void UnSpawn(GameObject obj)
|
||||
|
||||
internal static bool InvokeBytes(ULocalConnectionToServer conn, byte[] buffer)
|
||||
{
|
||||
ushort msgType;
|
||||
byte[] content;
|
||||
if (Protocol.UnpackMessage(buffer, out msgType, out content))
|
||||
if (Protocol.UnpackMessage(buffer, out ushort msgType, out byte[] content))
|
||||
{
|
||||
if (handlers.ContainsKey((short)msgType) && s_LocalConnection != null)
|
||||
{
|
||||
@ -1108,8 +1096,7 @@ internal static bool InvokeBytes(ULocalConnectionToServer conn, byte[] buffer)
|
||||
[Obsolete("Use NetworkIdentity.spawned[netId] instead.")]
|
||||
public static GameObject FindLocalObject(uint netId)
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (NetworkIdentity.spawned.TryGetValue(netId, out identity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity))
|
||||
{
|
||||
return identity.gameObject;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user