-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathNetcodeHelpers.cs
More file actions
43 lines (38 loc) · 1.33 KB
/
NetcodeHelpers.cs
File metadata and controls
43 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) Meta Platforms, Inc. and affiliates.
using System;
using System.Collections.Generic;
using System.Linq;
using Meta.Multiplayer.PlayerManagement;
using Meta.Utilities;
using Unity.Netcode;
namespace Meta.Multiplayer.Networking
{
public static class NetcodeHelpers
{
public static ClientRpcParams CreateSendRpcParams(ulong targetClientId) =>
new()
{
Send = new()
{
// don't use NativeArray because of Unity Issue #UUM-17174
TargetClientIds = new[] { targetClientId },
}
};
public static ClientRpcParams CreateSendRpcParams(PlayerId playerId) =>
CreateSendRpcParams(playerId.ClientId.Value);
public static ClientRpcParams CreateSendRpcParams(PlayerId[] playerIds) =>
new()
{
Send = new()
{
TargetClientIds = playerIds.Select(playerID => playerID.ClientId).WhereNonNull().ToList(),
}
};
public static IEnumerable<T> AsEnumerable<T>(this NetworkList<T> list) where T : unmanaged, IEquatable<T>
{
var enumerator = list.GetEnumerator();
while (enumerator.MoveNext())
yield return enumerator.Current;
}
}
}