diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b5da371d..057879987d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - ComponentUpdateSystem no longer has the API `GetAuthority`, `GetComponent`, and `HasComponent`. [#1364](https://github.com/spatialos/gdk-for-unity/pull/1364) - Use the Unity Entities `EntityManager` instead. - The GDK now depends on .NET Core v3.1.3xx instead of v2.2.2xx. [#1443](https://github.com/spatialos/gdk-for-unity/pull/1443) +- Removed APIs for AuthorityLossImminent. [#1451](https://github.com/spatialos/gdk-for-unity/pull/1451) + - All authority changes to `AuthorityLossImminent` will now be dropped, and callbacks will no longer trigger. ### Added diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md index 49bf1d03da..39d21b39dd 100644 --- a/UPGRADE_GUIDE.md +++ b/UPGRADE_GUIDE.md @@ -2,6 +2,12 @@ ## From `0.3.9` to `0.3.10` +### AuthorityLossImminent support removed + +The GDK for Unity no longer supports the `AuthorityLossImminent` authority state. If this feature is currently enabled, it will not trigger the authority state for any reader or writer. The methods to `Ack` the authority state have also been removed. + +To disable the feature for your worker types, please follow the [documentation](https://documentation.improbable.io/spatialos-overview/docs/component-settings). + ### ComponentUpdateSystem API changes The methods `GetAuthority`, `GetComponent`, and `HasComponent` have been removed from the `ComponentUpdateSystem`. diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/AuthorityConstraintCallbackManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/AuthorityConstraintCallbackManager.cs index 7722029832..6917f0ac13 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/AuthorityConstraintCallbackManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/AuthorityConstraintCallbackManager.cs @@ -5,7 +5,7 @@ namespace Improbable.Gdk.Subscriptions { - internal class AuthorityConstraintCallbackManager : IAuthorityCallbackManager + internal class AuthorityConstraintCallbackManager : ICallbackManager { private readonly CallbackCollection callbackCollection = new CallbackCollection(); private readonly uint componentId; @@ -35,18 +35,6 @@ public void InvokeCallbacks() } } - public void InvokeLossImminentCallbacks() - { - var changes = componentUpdateSystem.GetAuthorityChangesReceived(componentId); - for (var i = 0; i < changes.Count; ++i) - { - if (changes[i].Authority == Authority.AuthorityLossImminent) - { - callbackCollection.InvokeAllReverse(changes[i]); - } - } - } - public ulong RegisterCallback(Action callback) { callbackCollection.Add(nextCallbackId, callback); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/ComponentAuthorityCallbackManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/ComponentAuthorityCallbackManager.cs index 92ac1475c7..424158164b 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/ComponentAuthorityCallbackManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/ComponentAuthorityCallbackManager.cs @@ -5,7 +5,7 @@ namespace Improbable.Gdk.Subscriptions { - internal class ComponentAuthorityCallbackManager : IAuthorityCallbackManager + internal class ComponentAuthorityCallbackManager : ICallbackManager { private readonly EntityCallbacks callbacks = new EntityCallbacks(); private readonly uint componentId; @@ -34,18 +34,6 @@ public void InvokeCallbacks() } } - public void InvokeLossImminentCallbacks() - { - var changes = componentUpdateSystem.GetAuthorityChangesReceived(componentId); - for (var i = 0; i < changes.Count; ++i) - { - if (changes[i].Authority == Authority.AuthorityLossImminent) - { - callbacks.InvokeAllReverse(changes[i].EntityId, changes[i].Authority); - } - } - } - public ulong RegisterCallback(EntityId entityId, Action callback) { return callbacks.Add(entityId, callback); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs deleted file mode 100644 index 0f79a8e380..0000000000 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Improbable.Gdk.Subscriptions -{ - internal interface IAuthorityCallbackManager : ICallbackManager - { - void InvokeLossImminentCallbacks(); - } -} diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs.meta b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs.meta deleted file mode 100644 index 74323a22dd..0000000000 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7fe01432bdcfac0438f0ac78cab5da86 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/ComponentCallbackSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/ComponentCallbackSystem.cs index fd60acf918..777d12944b 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/ComponentCallbackSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/ComponentCallbackSystem.cs @@ -74,17 +74,12 @@ public bool UnregisterCallback(ulong callbackKey) return keyAndManager.Item2.UnregisterCallback(keyAndManager.Item1); } - internal void InvokeNoLossImminent() + internal void InvokeCallbacks() { componentCallbackManagers.InvokeEach(manager => manager.InvokeCallbacks()); authorityCallbackManagers.InvokeEach(manager => manager.InvokeCallbacks()); } - internal void InvokeLossImminent() - { - authorityCallbackManagers.InvokeEach(manager => manager.InvokeLossImminentCallbacks()); - } - protected override void OnCreate() { base.OnCreate(); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/RequireLifecycleSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/RequireLifecycleSystem.cs index 58d37d36fd..79b2868ba6 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/RequireLifecycleSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/RequireLifecycleSystem.cs @@ -42,7 +42,7 @@ protected override void OnUpdate() { componentConstraintsCallbackSystem.Invoke(); - componentCallbackSystem.InvokeNoLossImminent(); + componentCallbackSystem.InvokeCallbacks(); if (behavioursToEnable.Count > 0) { @@ -59,8 +59,6 @@ protected override void OnUpdate() behavioursToEnable.Clear(); } - componentCallbackSystem.InvokeLossImminent(); - commandCallbackSystem.InvokeCallbacks(); workerFlagCallbackSystem.InvokeCallbacks(); } diff --git a/workers/unity/Packages/io.improbable.gdk.core/Systems/ComponentUpdateSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Systems/ComponentUpdateSystem.cs index b0dd205b47..143f0fef09 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Systems/ComponentUpdateSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Systems/ComponentUpdateSystem.cs @@ -70,11 +70,6 @@ public List GetComponentsRemoved(uint componentId) return manager.GetComponentsRemoved(); } - public void AcknowledgeAuthorityLoss(EntityId entityId, uint componentId) - { - worker.MessagesToSend.AcknowledgeAuthorityLoss(entityId.Id, componentId); - } - protected override void OnCreate() { base.OnCreate(); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Worker/MessagesToSend.cs b/workers/unity/Packages/io.improbable.gdk.core/Worker/MessagesToSend.cs index 9ded30b190..eaff6db806 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Worker/MessagesToSend.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Worker/MessagesToSend.cs @@ -35,9 +35,6 @@ private static class MessagesToSendMetadata private readonly WorldCommandsToSendStorage worldCommandStorage = new WorldCommandsToSendStorage(); - private readonly MessageList authorityLossAcks = - new MessageList(); - private readonly MessageList logsToSend = new MessageList(); private readonly List metricsToSend = new List(); @@ -90,16 +87,10 @@ public void Clear() storage.Clear(); } - authorityLossAcks.Clear(); logsToSend.Clear(); metricsToSend.Clear(); } - public void AcknowledgeAuthorityLoss(long entityId, uint componentId) - { - authorityLossAcks.Add(new EntityComponent(entityId, componentId)); - } - public void AddComponentUpdate(in T update, long entityId) where T : ISpatialComponentUpdate { @@ -152,11 +143,6 @@ internal List GetMetrics() return metricsToSend; } - internal MessageList GetAuthorityLossAcknowledgements() - { - return authorityLossAcks; - } - internal IComponentDiffStorage GetComponentDiffStorage(uint componentId) { if (!componentIdToComponentStorage.TryGetValue(componentId, out var storage)) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Worker/SerializedMessagesToSend.cs b/workers/unity/Packages/io.improbable.gdk.core/Worker/SerializedMessagesToSend.cs index 4a22139ff8..7e46339c9a 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Worker/SerializedMessagesToSend.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Worker/SerializedMessagesToSend.cs @@ -42,9 +42,6 @@ public class SerializedMessagesToSend private readonly List metricsToSend = new List(); - private readonly MessageList authorityLossAcks = - new MessageList(); - private readonly List componentSerializers = new List(); private readonly List commandSerializers = new List(); @@ -106,8 +103,6 @@ public void SerializeFrom(MessagesToSend messages, CommandMetaData commandMetaDa messages.GetLogMessages().CopyTo(logMessages); - messages.GetAuthorityLossAcknowledgements().CopyTo(authorityLossAcks); - foreach (var serializer in componentSerializers) { serializer.Serialize(messages, this); @@ -126,7 +121,6 @@ public void Clear() entityQueryRequests.Clear(); metricsToSend.Clear(); logMessages.Clear(); - authorityLossAcks.Clear(); netFrameStats.Clear(); } @@ -203,13 +197,6 @@ public void SendAndClear(Connection connection, CommandMetaData commandMetaData, logMessage.EntityId); } - for (var i = 0; i < authorityLossAcks.Count; ++i) - { - ref readonly var entityComponent = ref authorityLossAcks[i]; - connection.SendAuthorityLossImminentAcknowledgement(entityComponent.EntityId, - entityComponent.ComponentId); - } - frameStats.Merge(netFrameStats); Clear(); } diff --git a/workers/unity/Packages/io.improbable.gdk.core/Worker/ViewDiff.cs b/workers/unity/Packages/io.improbable.gdk.core/Worker/ViewDiff.cs index f5c5376b3f..54c571b142 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Worker/ViewDiff.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Worker/ViewDiff.cs @@ -168,7 +168,12 @@ public void SetAuthority(long entityId, uint componentId, Authority authority) { throw new ArgumentException( $"Can not set authority over component with ID {componentId} for entity with ID {entityId}. " + - $"Unknown component ID"); + "Unknown component ID"); + } + + if (authority == Authority.AuthorityLossImminent) + { + return; } ((IDiffAuthorityStorage) authorityStorage).AddAuthorityChange( diff --git a/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/.codegen/Source/Generators/GameObjectCreation/UnityComponentReaderWriterGenerator.cs b/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/.codegen/Source/Generators/GameObjectCreation/UnityComponentReaderWriterGenerator.cs index bfa5402c5c..5fd25ab068 100644 --- a/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/.codegen/Source/Generators/GameObjectCreation/UnityComponentReaderWriterGenerator.cs +++ b/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/.codegen/Source/Generators/GameObjectCreation/UnityComponentReaderWriterGenerator.cs @@ -258,13 +258,6 @@ private static TypeBlock GenerateComponentWriter(UnityComponentDetails component }} "); } - - writer.Line($@" -public void AcknowledgeAuthorityLoss() -{{ - ComponentUpdateSystem.AcknowledgeAuthorityLoss(EntityId, {componentDetails.Name}.ComponentId); -}} -"); }); } }