Skip to content

Commit 2e0dca9

Browse files
authored
Merge pull request #266 from Ganon-M/feature/networked_transform_channels
feat: Exposed channels in NetworkedTransform
2 parents 549db64 + 53ee470 commit 2e0dca9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

MLAPI/Prototyping/NetworkedTransform.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.IO;
33
using MLAPI.Messaging;
44
using MLAPI.Serialization.Pooled;
@@ -61,6 +61,11 @@ internal class ClientSendInfo
6161
/// A higher value will result in continued extrapolation after an object has stopped moving
6262
/// </summary>
6363
public float MaxSendsToExtrapolate = 5;
64+
/// <summary>
65+
/// The channel to send the data on
66+
/// </summary>
67+
[Tooltip("The channel to send the data on. Uses the default channel if left unspecified")]
68+
public string Channel = null;
6469

6570
private float lerpT;
6671
private Vector3 lerpStartPos;
@@ -156,9 +161,9 @@ private void Update()
156161
writer.WriteSinglePacked(transform.rotation.eulerAngles.z);
157162

158163
if (IsServer)
159-
InvokeClientRpcOnEveryoneExceptPerformance(ApplyTransform, OwnerClientId, stream);
164+
InvokeClientRpcOnEveryoneExceptPerformance(ApplyTransform, OwnerClientId, stream, string.IsNullOrEmpty(Channel) ? "MLAPI_DEFAULT_MESSAGE" : Channel);
160165
else
161-
InvokeServerRpcPerformance(SubmitTransform, stream);
166+
InvokeServerRpcPerformance(SubmitTransform, stream, string.IsNullOrEmpty(Channel) ? "MLAPI_DEFAULT_MESSAGE" : Channel);
162167
}
163168
}
164169

@@ -283,7 +288,7 @@ private void SubmitTransform(ulong clientId, Stream stream)
283288
info.lastMissedPosition = null;
284289
info.lastMissedRotation = null;
285290

286-
InvokeClientRpcOnClientPerformance(ApplyTransform, NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, writeStream);
291+
InvokeClientRpcOnClientPerformance(ApplyTransform, NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, writeStream, string.IsNullOrEmpty(Channel) ? "MLAPI_DEFAULT_MESSAGE" : Channel);
287292
}
288293
else
289294
{
@@ -294,7 +299,7 @@ private void SubmitTransform(ulong clientId, Stream stream)
294299
}
295300
else
296301
{
297-
InvokeClientRpcOnEveryoneExceptPerformance(ApplyTransform, OwnerClientId, writeStream);
302+
InvokeClientRpcOnEveryoneExceptPerformance(ApplyTransform, OwnerClientId, writeStream, string.IsNullOrEmpty(Channel) ? "MLAPI_DEFAULT_MESSAGE" : Channel);
298303
}
299304
}
300305
}
@@ -340,7 +345,7 @@ private void CheckForMissedSends()
340345
writer.WriteSinglePacked(rot.y);
341346
writer.WriteSinglePacked(rot.z);
342347

343-
InvokeClientRpcOnClientPerformance(ApplyTransform, NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, stream);
348+
InvokeClientRpcOnClientPerformance(ApplyTransform, NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, stream, string.IsNullOrEmpty(Channel) ? "MLAPI_DEFAULT_MESSAGE" : Channel);
344349
}
345350
}
346351
}

0 commit comments

Comments
 (0)