@@ -9,18 +9,6 @@ namespace Unity.Netcode.Prototyping
9
9
[ AddComponentMenu ( "Netcode/" + nameof ( NetworkTransform ) ) ]
10
10
public class NetworkTransform : NetworkBehaviour
11
11
{
12
- /// <summary>
13
- /// Server authority allows only the server to update this transform
14
- /// Client authority allows only the owner client to update this transform
15
- /// Shared authority allows everyone to update this transform
16
- /// </summary>
17
- public enum NetworkAuthority
18
- {
19
- Server = 0 ,
20
- Client ,
21
- Shared
22
- }
23
-
24
12
internal class NetworkState : INetworkSerializable
25
13
{
26
14
internal const int InLocalSpaceBit = 0 ;
@@ -140,13 +128,6 @@ public void NetworkSerialize(NetworkSerializer serializer)
140
128
}
141
129
}
142
130
143
- /// <summary>
144
- /// TODO this will need refactoring
145
- /// Specifies who can update this transform
146
- /// </summary>
147
- [ Tooltip ( "Defines who can update this transform" ) ]
148
- public NetworkAuthority Authority = NetworkAuthority . Server ;
149
-
150
131
/// <summary>
151
132
/// The network channel to use send updates
152
133
/// </summary>
@@ -178,14 +159,6 @@ public void NetworkSerialize(NetworkSerializer serializer)
178
159
internal readonly NetworkVariable < NetworkState > ReplNetworkState = new NetworkVariable < NetworkState > ( new NetworkState ( ) ) ;
179
160
internal NetworkState PrevNetworkState ;
180
161
181
- /// <summary>
182
- /// Does this instance (client or server) has authority to update transform?
183
- /// </summary>
184
- public bool CanUpdateTransform =>
185
- Authority == NetworkAuthority . Client && IsClient && IsOwner ||
186
- Authority == NetworkAuthority . Server && IsServer ||
187
- Authority == NetworkAuthority . Shared ;
188
-
189
162
// updates `NetworkState` properties if they need to and returns a `bool` indicating whether or not there was any changes made
190
163
// returned boolean would be useful to change encapsulating `NetworkVariable<NetworkState>`'s dirty state, e.g. ReplNetworkState.SetDirty(isDirty);
191
164
internal bool UpdateNetworkState ( NetworkState networkState )
@@ -390,39 +363,13 @@ private void OnNetworkStateChanged(NetworkState oldState, NetworkState newState)
390
363
return ;
391
364
}
392
365
393
- if ( Authority == NetworkAuthority . Client && IsClient && IsOwner )
394
- {
395
- // todo MTT-768 this shouldn't happen anymore with new tick system (tick written will be higher than tick read, so netvar wouldn't change in that case)
396
- return ;
397
- }
398
-
399
366
ApplyNetworkState ( newState ) ;
400
367
}
401
368
402
- private void UpdateNetVarPerms ( )
403
- {
404
- switch ( Authority )
405
- {
406
- default :
407
- throw new NotImplementedException ( $ "Authority: { Authority } is not handled") ;
408
- case NetworkAuthority . Server :
409
- ReplNetworkState . Settings . WritePermission = NetworkVariablePermission . ServerOnly ;
410
- break ;
411
- case NetworkAuthority . Client :
412
- ReplNetworkState . Settings . WritePermission = NetworkVariablePermission . OwnerOnly ;
413
- break ;
414
- case NetworkAuthority . Shared :
415
- ReplNetworkState . Settings . WritePermission = NetworkVariablePermission . Everyone ;
416
- break ;
417
- }
418
- }
419
-
420
369
private void Awake ( )
421
370
{
422
371
m_Transform = transform ;
423
372
424
- UpdateNetVarPerms ( ) ;
425
-
426
373
ReplNetworkState . Settings . SendNetworkChannel = Channel ;
427
374
ReplNetworkState . Settings . SendTickrate = FixedSendsPerSecond ;
428
375
@@ -446,7 +393,7 @@ private void FixedUpdate()
446
393
return ;
447
394
}
448
395
449
- if ( CanUpdateTransform )
396
+ if ( IsServer )
450
397
{
451
398
ReplNetworkState . SetDirty ( UpdateNetworkState ( ReplNetworkState . Value ) ) ;
452
399
}
@@ -459,17 +406,6 @@ private void FixedUpdate()
459
406
}
460
407
}
461
408
462
- /// <summary>
463
- /// Updates the NetworkTransform's authority model at runtime
464
- /// </summary>
465
- internal void SetAuthority ( NetworkAuthority authority )
466
- {
467
- Authority = authority ;
468
- UpdateNetVarPerms ( ) ;
469
- // todo this should be synced with the other side.
470
- // let's wait for a more final solution before adding more code here
471
- }
472
-
473
409
/// <summary>
474
410
/// Teleports the transform to the given values without interpolating
475
411
/// </summary>
0 commit comments