You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add a SessionOwner ObjectStatus and allow InScenePlaced network objects to be distributed (#3175)
* Initial pass on SessionOwner ownership flag
* feat: Add SessionOwner OwnershipStatus flag
* update
removing additional session owner accessor.
* Add OwnershipPermissions tests
* fix client connect
* Revert "fix client connect"
This reverts commit 3c3b354.
* update
object distribution for in-scene placed NetworkObjects needs to use the InScenePlacedSourceGlobalObjectIdHash when building an object distribution list.
* Add changelog
* Remove unnecessary change
* Remove Settings.json
* Reword CHANGELOG
* fix
DAHost should not distribute session owner permission NetworkObjects.
When client is promoted to session owner, for now newly promoted client takes ownership of NetworkObjects that have the SessionOwner permission set.
Only prevent non-session owners from taking ownership of a NetworkObject with the SessionOwner permission set.
* test fix
Avoid the RemoveOwnership client-server only method.
* style
Visual studio code cleanup likes to sort by alpha... fixing for our standards.
* update
Adding check for session owner trying to change ownership to a non-session owner client.
* test
Adding an additional validation that a non-session owner cannot change ownership and that a session owner cannot change ownership to a non-session owner when the NetworkObject in question has the SessionOwner permissions set.
---------
Co-authored-by: NoelStephensUnity <[email protected]>
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
10
10
11
11
### Added
12
12
13
+
- Added `NetworkObject.OwnershipStatus.SessionOwner` to allow Network Objects to be distributable and only owned by the Session Owner. This flag will override all other `OwnershipStatus` flags. (#3175)
13
14
- Added `UnityTransport.GetEndpoint` method to provide a way to obtain `NetworkEndpoint` information of a connection via client identifier. (#3130)
14
15
- Added `NetworkTransport.OnEarlyUpdate` and `NetworkTransport.OnPostLateUpdate` methods to provide more control over handling transport related events at the start and end of each frame. (#3113)
15
16
@@ -30,6 +31,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
30
31
31
32
### Changed
32
33
34
+
- In-scene placed `NetworkObject`s have been made distributable when balancing object distribution after a connection event. (#3175)
33
35
- Optimised `NetworkVariable` and `NetworkTransform` related packets when in Distributed Authority mode.
34
36
- The Debug Simulator section of the Unity Transport component was removed. This section was not functional anymore and users are now recommended to use the more featureful [Network Simulator](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/) tool from the Multiplayer Tools package instead. (#3121)
/// When true, the <see cref="NetworkObject"/> can only be owned by the current Session Owner.
444
+
/// To set <see cref="OwnershipStatus.SessionOwner"/> during runtime, use <see cref="ChangeOwnership(ulong)"/> to ensure the session owner owns the object.
445
+
/// Once the session owner owns the object, then use <see cref="SetOwnershipStatus(OwnershipStatus, bool, OwnershipLockActions)"/>.
/// <see cref="None"/>: If nothing is set, then ownership is considered "static" and cannot be redistributed, requested, or transferred (i.e. a Player would have this).
482
489
/// <see cref="Distributable"/>: When set, this instance will be automatically redistributed when a client joins (if not locked or no request is pending) or leaves.
483
490
/// <see cref="Transferable"/>: When set, a non-owner can obtain ownership immediately (without requesting and as long as it is not locked).
484
-
/// <see cref="RequestRequired"/>: When set, When set, a non-owner must request ownership from the owner (will always get locked once ownership is transferred).
491
+
/// <see cref="RequestRequired"/>: When set, a non-owner must request ownership from the owner (will always get locked once ownership is transferred).
492
+
/// <see cref="SessionOwner"/>: When set, only the current session owner may have ownership over this object.
485
493
/// </summary>
486
494
// Ranges from 1 to 8 bits
487
495
[Flags]
@@ -491,6 +499,7 @@ public enum OwnershipStatus
491
499
Distributable=1<<0,
492
500
Transferable=1<<1,
493
501
RequestRequired=1<<2,
502
+
SessionOwner=1<<3,
494
503
}
495
504
496
505
/// <summary>
@@ -549,7 +558,7 @@ public bool SetOwnershipLock(bool lockOwnership = true)
549
558
}
550
559
551
560
// If we don't have the Transferable flag set and it is not a player object, then it is the same as having a static lock on ownership
NetworkLog.LogWarning($"Trying to add or remove ownership lock on [{name}] which does not have the {nameof(OwnershipStatus.Transferable)} flag set!");
555
564
returnfalse;
@@ -582,13 +591,15 @@ public bool SetOwnershipLock(bool lockOwnership = true)
582
591
/// <see cref="RequestRequired"/>: The <see cref="NetworkObject"/> requires an ownership request via <see cref="RequestOwnership"/>.
583
592
/// <see cref="RequestInProgress"/>: The <see cref="NetworkObject"/> is already processing an ownership request and ownership cannot be acquired at this time.
584
593
/// <see cref="NotTransferrable"/>: The <see cref="NetworkObject"/> does not have the <see cref="OwnershipStatus.Transferable"/> flag set and ownership cannot be acquired.
594
+
/// <see cref="SessionOwnerOnly"/>: The <see cref="NetworkObject"/> has the <see cref="OwnershipStatus.SessionOwner"/> flag set and ownership cannot be acquired.
585
595
/// </summary>
586
596
publicenumOwnershipPermissionsFailureStatus
587
597
{
588
598
Locked,
589
599
RequestRequired,
590
600
RequestInProgress,
591
-
NotTransferrable
601
+
NotTransferrable,
602
+
SessionOwnerOnly
592
603
}
593
604
594
605
/// <summary>
@@ -610,6 +621,7 @@ public enum OwnershipPermissionsFailureStatus
610
621
/// <see cref="RequestRequiredNotSet"/>: The <see cref="OwnershipStatus.RequestRequired"/> flag is not set on this <see cref="NetworkObject"/>
611
622
/// <see cref="Locked"/>: The current owner has locked ownership which means requests are not available at this time.
612
623
/// <see cref="RequestInProgress"/>: There is already a known request in progress. You can scan for ownership changes and try upon
624
+
/// <see cref="SessionOwnerOnly"/>: This object is marked as SessionOwnerOnly and therefore cannot be requested
613
625
/// a change in ownership or just try again after a specific period of time or no longer attempt to request ownership.
614
626
/// </summary>
615
627
publicenumOwnershipRequestStatus
@@ -619,6 +631,7 @@ public enum OwnershipRequestStatus
619
631
RequestRequiredNotSet,
620
632
Locked,
621
633
RequestInProgress,
634
+
SessionOwnerOnly,
622
635
}
623
636
624
637
/// <summary>
@@ -631,6 +644,7 @@ public enum OwnershipRequestStatus
631
644
/// <see cref="OwnershipRequestStatus.RequestRequiredNotSet"/>: The <see cref="OwnershipStatus.RequestRequired"/> flag is not set on this <see cref="NetworkObject"/>
632
645
/// <see cref="OwnershipRequestStatus.Locked"/>: The current owner has locked ownership which means requests are not available at this time.
633
646
/// <see cref="OwnershipRequestStatus.RequestInProgress"/>: There is already a known request in progress. You can scan for ownership changes and try upon
647
+
/// <see cref="OwnershipRequestStatus.SessionOwnerOnly"/>: This object can only belong the the session owner and so cannot be requested
634
648
/// a change in ownership or just try again after a specific period of time or no longer attempt to request ownership.
// DANGO-TODO: Review over don't destroy with owner being set but DistributeOwnership not being set
1630
1668
if(NetworkManager.LogLevel==LogLevel.Developer)
1631
1669
{
1632
-
NetworkLog.LogWarning("DANGO-TODO: Review over don't destroy with owner being set but DistributeOwnership not being set. For now, if the NetworkObject does not destroy with the owner it will automatically set DistributeOwnership.");
1670
+
NetworkLog.LogWarning("DANGO-TODO: Review over don't destroy with owner being set but DistributeOwnership not being set. For now, if the NetworkObject does not destroy with the owner it will set ownership to SessionOwner.");
0 commit comments