-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathNotOwnerRpcTarget.cs
More file actions
101 lines (93 loc) · 3.52 KB
/
NotOwnerRpcTarget.cs
File metadata and controls
101 lines (93 loc) · 3.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
namespace Unity.Netcode
{
internal class NotOwnerRpcTarget : BaseRpcTarget
{
private IGroupRpcTarget m_GroupSendTarget;
private ServerRpcTarget m_ServerRpcTarget;
private NotAuthorityRpcTarget m_NotAuthorityRpcTarget;
private LocalSendRpcTarget m_LocalSendRpcTarget;
public override void Dispose()
{
m_ServerRpcTarget.Dispose();
m_LocalSendRpcTarget.Dispose();
m_NotAuthorityRpcTarget.Dispose();
if (m_GroupSendTarget != null)
{
m_GroupSendTarget.Target.Dispose();
m_GroupSendTarget = null;
}
}
internal override void Send(NetworkBehaviour behaviour, ref RpcMessage message, NetworkDelivery delivery, RpcParams rpcParams)
{
// Not owner is the same as not authority in distributed authority mode
if (m_NetworkManager.DistributedAuthorityMode)
{
m_NotAuthorityRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
return;
}
if (m_GroupSendTarget == null)
{
if (behaviour.IsServer)
{
m_GroupSendTarget = new RpcTargetGroup(m_NetworkManager);
}
else
{
m_GroupSendTarget = new ProxyRpcTargetGroup(m_NetworkManager);
}
}
m_GroupSendTarget.Clear();
if (behaviour.IsServer)
{
foreach (var clientId in behaviour.NetworkObject.Observers)
{
if (clientId == behaviour.OwnerClientId)
{
continue;
}
if (clientId == NetworkManager.ServerClientId)
{
continue;
}
if (clientId == behaviour.NetworkManager.LocalClientId)
{
m_LocalSendRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
continue;
}
m_GroupSendTarget.Add(clientId);
}
}
else
{
foreach (var clientId in ConnectionManager.ConnectedClientIds)
{
if (clientId == behaviour.OwnerClientId)
{
continue;
}
if (clientId == NetworkManager.ServerClientId)
{
continue;
}
if (clientId == behaviour.NetworkManager.LocalClientId)
{
m_LocalSendRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
continue;
}
m_GroupSendTarget.Add(clientId);
}
}
m_GroupSendTarget.Target.Send(behaviour, ref message, delivery, rpcParams);
if (behaviour.OwnerClientId != NetworkManager.ServerClientId)
{
m_ServerRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
}
}
internal NotOwnerRpcTarget(NetworkManager manager) : base(manager)
{
m_ServerRpcTarget = new ServerRpcTarget(manager);
m_LocalSendRpcTarget = new LocalSendRpcTarget(manager);
m_NotAuthorityRpcTarget = new NotAuthorityRpcTarget(manager);
}
}
}