Skip to content

Commit 42c7a12

Browse files
committed
Use internal network manager instead of property
1 parent 7c515b3 commit 42c7a12

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ internal void DeregisterUpdate()
194194
internal NetworkAnimatorStateChangeHandler(NetworkAnimator networkAnimator)
195195
{
196196
m_NetworkAnimator = networkAnimator;
197-
m_IsServer = networkAnimator.NetworkManager.IsServer;
197+
m_IsServer = networkAnimator.LocalNetworkManager.IsServer;
198198
NetworkUpdateLoop.RegisterNetworkUpdate(this, NetworkUpdateStage.PreUpdate);
199199
}
200200
}
@@ -279,7 +279,7 @@ public Animator Animator
279279
private Dictionary<int, Dictionary<int, TransitionStateinfo>> m_DestinationStateToTransitioninfo = new Dictionary<int, Dictionary<int, TransitionStateinfo>>();
280280

281281
// Named differently to avoid serialization conflicts with NetworkBehaviour
282-
private NetworkManager m_LocalNetworkManager;
282+
internal NetworkManager LocalNetworkManager;
283283

284284
internal bool DistributedAuthorityMode;
285285

@@ -915,8 +915,8 @@ internal AnimationMessage GetAnimationMessage()
915915
internal override void InternalOnNetworkPreSpawn(ref NetworkManager networkManager)
916916
{
917917
// Save internal state references
918-
m_LocalNetworkManager = networkManager;
919-
DistributedAuthorityMode = m_LocalNetworkManager.DistributedAuthorityMode;
918+
LocalNetworkManager = networkManager;
919+
DistributedAuthorityMode = LocalNetworkManager.DistributedAuthorityMode;
920920
}
921921

922922
/// <inheritdoc/>
@@ -1176,7 +1176,7 @@ internal void CheckForAnimatorChanges()
11761176

11771177
if (m_Animator.runtimeAnimatorController == null)
11781178
{
1179-
if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
1179+
if (LocalNetworkManager.LogLevel == LogLevel.Developer)
11801180
{
11811181
Debug.LogError($"[{GetType().Name}] Could not find an assigned {nameof(RuntimeAnimatorController)}! Cannot check {nameof(Animator)} for changes in state!");
11821182
}
@@ -1211,9 +1211,9 @@ internal void CheckForAnimatorChanges()
12111211
{
12121212
// Just notify all remote clients and not the local server
12131213
m_TargetGroup.Clear();
1214-
foreach (var clientId in m_LocalNetworkManager.ConnectionManager.ConnectedClientIds)
1214+
foreach (var clientId in LocalNetworkManager.ConnectionManager.ConnectedClientIds)
12151215
{
1216-
if (clientId == m_LocalNetworkManager.LocalClientId || !NetworkObject.Observers.Contains(clientId))
1216+
if (clientId == LocalNetworkManager.LocalClientId || !NetworkObject.Observers.Contains(clientId))
12171217
{
12181218
continue;
12191219
}
@@ -1241,7 +1241,7 @@ private void SendParametersUpdate(RpcParams rpcParams = default, bool sendDirect
12411241
}
12421242
else
12431243
{
1244-
Debug.LogError($"[{name}][Client-{m_LocalNetworkManager.LocalClientId}] Attempting to send parameter updates but not the owner!");
1244+
Debug.LogError($"[{name}][Client-{LocalNetworkManager.LocalClientId}] Attempting to send parameter updates but not the owner!");
12451245
}
12461246
}
12471247
else
@@ -1491,18 +1491,18 @@ internal void UpdateAnimationState(AnimationState animationState)
14911491
// Cross fade from the current to the destination state for the transitions duration while starting at the server's current normalized time of the transition
14921492
m_Animator.CrossFade(transitionStateInfo.DestinationState, transitionStateInfo.TransitionDuration, transitionStateInfo.Layer, 0.0f, animationState.NormalizedTime);
14931493
}
1494-
else if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
1494+
else if (LocalNetworkManager.LogLevel == LogLevel.Developer)
14951495
{
14961496
NetworkLog.LogWarning($"Current State Hash ({currentState.fullPathHash}) != AnimationState.StateHash ({animationState.StateHash})");
14971497
}
14981498
}
1499-
else if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
1499+
else if (LocalNetworkManager.LogLevel == LogLevel.Developer)
15001500
{
15011501
NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) sub-table does not contain destination state ({animationState.DestinationStateHash})!");
15021502
}
15031503
}
15041504
// For reference, it is valid to have no transition information
1505-
//else if (NetworkManager.LogLevel == LogLevel.Developer)
1505+
//else if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
15061506
//{
15071507
// NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) does not exist!");
15081508
//}
@@ -1539,7 +1539,7 @@ private unsafe void SendServerParametersUpdateRpc(ParametersUpdateMessage parame
15391539
return;
15401540
}
15411541
UpdateParameters(ref parametersUpdate);
1542-
var connectedClientIds = m_LocalNetworkManager.ConnectionManager.ConnectedClientIds;
1542+
var connectedClientIds = LocalNetworkManager.ConnectionManager.ConnectedClientIds;
15431543
if (connectedClientIds.Count <= (IsHost ? 2 : 1))
15441544
{
15451545
return;
@@ -1605,7 +1605,7 @@ private void SendServerAnimStateRpc(AnimationMessage animationMessage, RpcParams
16051605
UpdateAnimationState(animationState);
16061606
}
16071607

1608-
var connectedClientIds = m_LocalNetworkManager.ConnectionManager.ConnectedClientIds;
1608+
var connectedClientIds = LocalNetworkManager.ConnectionManager.ConnectedClientIds;
16091609
if (connectedClientIds.Count <= (IsHost ? 2 : 1))
16101610
{
16111611
return;
@@ -1652,7 +1652,7 @@ private void ProcessAnimStates(AnimationMessage animationMessage)
16521652
{
16531653
if (HasAuthority)
16541654
{
1655-
if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
1655+
if (LocalNetworkManager.LogLevel == LogLevel.Developer)
16561656
{
16571657
var hostOrOwner = DistributedAuthorityMode ? "Owner" : "Host";
16581658
var clientServerOrDAMode = DistributedAuthorityMode ? "distributed authority" : "client-server";
@@ -1677,7 +1677,7 @@ internal void SendServerAnimTriggerRpc(AnimationTriggerMessage animationTriggerM
16771677
// Ignore if a non-owner sent this.
16781678
if (rpcParams.Receive.SenderClientId != OwnerClientId)
16791679
{
1680-
if (m_LocalNetworkManager.LogLevel == LogLevel.Developer)
1680+
if (LocalNetworkManager.LogLevel == LogLevel.Developer)
16811681
{
16821682
NetworkLog.LogWarning($"[Owner Authoritative] Detected the a non-authoritative client is sending the server animation trigger updates. If you recently changed ownership of the {name} object, then this could be the reason.");
16831683
}
@@ -1687,7 +1687,7 @@ internal void SendServerAnimTriggerRpc(AnimationTriggerMessage animationTriggerM
16871687
// set the trigger locally on the server
16881688
InternalSetTrigger(animationTriggerMessage.Hash, animationTriggerMessage.IsTriggerSet);
16891689

1690-
var connectedClientIds = m_LocalNetworkManager.ConnectionManager.ConnectedClientIds;
1690+
var connectedClientIds = LocalNetworkManager.ConnectionManager.ConnectedClientIds;
16911691

16921692
m_TargetGroup.Clear();
16931693
foreach (var clientId in connectedClientIds)

0 commit comments

Comments
 (0)