mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
4.x syntax
This commit is contained in:
parent
7d081da541
commit
138dfaa6e1
@ -19,9 +19,9 @@ public static class NetworkServer
|
||||
// original HLAPI has .localConnections list with only m_LocalConnection in it
|
||||
// (for downwards compatibility because they removed the real localConnections list a while ago)
|
||||
// => removed it for easier code. use .localConection now!
|
||||
public static NetworkConnection localConnection { get { return s_LocalConnection; } }
|
||||
public static NetworkConnection localConnection => s_LocalConnection;
|
||||
|
||||
public static int serverHostId { get { return s_ServerHostId; } }
|
||||
public static int serverHostId => s_ServerHostId;
|
||||
|
||||
// <connectionId, NetworkConnection>
|
||||
public static Dictionary<int, NetworkConnection> connections = new Dictionary<int, NetworkConnection>();
|
||||
@ -29,8 +29,8 @@ public static class NetworkServer
|
||||
|
||||
public static bool dontListen;
|
||||
|
||||
public static bool active { get { return s_Active; } }
|
||||
public static bool localClientActive { get { return s_LocalClientActive; } }
|
||||
public static bool active => s_Active;
|
||||
public static bool localClientActive => s_LocalClientActive;
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
@ -141,8 +141,10 @@ internal static int AddLocalClient(LocalClient localClient)
|
||||
return -1;
|
||||
}
|
||||
|
||||
s_LocalConnection = new ULocalConnectionToClient(localClient);
|
||||
s_LocalConnection.connectionId = 0;
|
||||
s_LocalConnection = new ULocalConnectionToClient(localClient)
|
||||
{
|
||||
connectionId = 0
|
||||
};
|
||||
AddConnection(s_LocalConnection);
|
||||
|
||||
s_LocalConnection.InvokeHandlerNoData((short)MsgType.Connect);
|
||||
@ -412,8 +414,10 @@ static void GenerateError(NetworkConnection conn, byte error)
|
||||
{
|
||||
if (handlers.ContainsKey((short)MsgType.Error))
|
||||
{
|
||||
ErrorMessage msg = new ErrorMessage();
|
||||
msg.value = error;
|
||||
ErrorMessage msg = new ErrorMessage
|
||||
{
|
||||
value = error
|
||||
};
|
||||
|
||||
// write the message to a local buffer
|
||||
NetworkWriter writer = new NetworkWriter();
|
||||
@ -589,8 +593,10 @@ static void FinishPlayerForConnection(NetworkConnection conn, NetworkIdentity id
|
||||
Spawn(playerGameObject);
|
||||
}
|
||||
|
||||
OwnerMessage owner = new OwnerMessage();
|
||||
owner.netId = identity.netId;
|
||||
OwnerMessage owner = new OwnerMessage
|
||||
{
|
||||
netId = identity.netId
|
||||
};
|
||||
conn.Send((short)MsgType.Owner, owner);
|
||||
}
|
||||
|
||||
@ -732,8 +738,10 @@ internal static void ShowForConnection(NetworkIdentity identity, NetworkConnecti
|
||||
|
||||
internal static void HideForConnection(NetworkIdentity identity, NetworkConnection conn)
|
||||
{
|
||||
ObjectDestroyMessage msg = new ObjectDestroyMessage();
|
||||
msg.netId = identity.netId;
|
||||
ObjectDestroyMessage msg = new ObjectDestroyMessage
|
||||
{
|
||||
netId = identity.netId
|
||||
};
|
||||
conn.Send((short)MsgType.ObjectHide, msg);
|
||||
}
|
||||
|
||||
@ -848,14 +856,16 @@ internal static void SendSpawnMessage(NetworkIdentity identity, NetworkConnectio
|
||||
// 'identity' is a prefab that should be spawned
|
||||
if (identity.sceneId == 0)
|
||||
{
|
||||
SpawnPrefabMessage msg = new SpawnPrefabMessage();
|
||||
msg.netId = identity.netId;
|
||||
msg.assetId = identity.assetId;
|
||||
msg.position = identity.transform.position;
|
||||
msg.rotation = identity.transform.rotation;
|
||||
SpawnPrefabMessage msg = new SpawnPrefabMessage
|
||||
{
|
||||
netId = identity.netId,
|
||||
assetId = identity.assetId,
|
||||
position = identity.transform.position,
|
||||
rotation = identity.transform.rotation,
|
||||
|
||||
// serialize all components with initialState = true
|
||||
msg.payload = identity.OnSerializeAllSafely(true);
|
||||
// serialize all components with initialState = true
|
||||
payload = identity.OnSerializeAllSafely(true)
|
||||
};
|
||||
|
||||
// conn is != null when spawning it for a client
|
||||
if (conn != null)
|
||||
@ -871,14 +881,16 @@ internal static void SendSpawnMessage(NetworkIdentity identity, NetworkConnectio
|
||||
// 'identity' is a scene object that should be spawned again
|
||||
else
|
||||
{
|
||||
SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage();
|
||||
msg.netId = identity.netId;
|
||||
msg.sceneId = identity.sceneId;
|
||||
msg.position = identity.transform.position;
|
||||
msg.rotation = identity.transform.rotation;
|
||||
SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage
|
||||
{
|
||||
netId = identity.netId,
|
||||
sceneId = identity.sceneId,
|
||||
position = identity.transform.position,
|
||||
rotation = identity.transform.rotation,
|
||||
|
||||
// include synch data
|
||||
msg.payload = identity.OnSerializeAllSafely(true);
|
||||
// include synch data
|
||||
payload = identity.OnSerializeAllSafely(true)
|
||||
};
|
||||
|
||||
// conn is != null when spawning it for a client
|
||||
if (conn != null)
|
||||
@ -1031,8 +1043,10 @@ static void DestroyObject(NetworkIdentity identity, bool destroyServerObject)
|
||||
identity.clientAuthorityOwner.RemoveOwnedObject(identity);
|
||||
}
|
||||
|
||||
ObjectDestroyMessage msg = new ObjectDestroyMessage();
|
||||
msg.netId = identity.netId;
|
||||
ObjectDestroyMessage msg = new ObjectDestroyMessage
|
||||
{
|
||||
netId = identity.netId
|
||||
};
|
||||
SendToObservers(identity, (short)MsgType.ObjectDestroy, msg);
|
||||
|
||||
identity.ClearObservers();
|
||||
|
Loading…
Reference in New Issue
Block a user