Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit cf3a0e9

Browse files
authored
Removed all usages and support for Authority.AuthorityLossImminent (#1451)
* Removed all usages and support for Authority.AuthorityLossImminent
1 parent 515adce commit cf3a0e9

File tree

13 files changed

+18
-93
lines changed

13 files changed

+18
-93
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- ComponentUpdateSystem no longer has the API `GetAuthority`, `GetComponent`, and `HasComponent`. [#1364](https://github.com/spatialos/gdk-for-unity/pull/1364)
1010
- Use the Unity Entities `EntityManager` instead.
1111
- 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)
12+
- Removed APIs for AuthorityLossImminent. [#1451](https://github.com/spatialos/gdk-for-unity/pull/1451)
13+
- All authority changes to `AuthorityLossImminent` will now be dropped, and callbacks will no longer trigger.
1214

1315
### Added
1416

UPGRADE_GUIDE.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## From `0.3.9` to `0.3.10`
44

5+
### AuthorityLossImminent support removed
6+
7+
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.
8+
9+
To disable the feature for your worker types, please follow the [documentation](https://documentation.improbable.io/spatialos-overview/docs/component-settings).
10+
511
### ComponentUpdateSystem API changes
612

713
The methods `GetAuthority`, `GetComponent`, and `HasComponent` have been removed from the `ComponentUpdateSystem`.

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/AuthorityConstraintCallbackManager.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Improbable.Gdk.Subscriptions
77
{
8-
internal class AuthorityConstraintCallbackManager : IAuthorityCallbackManager
8+
internal class AuthorityConstraintCallbackManager : ICallbackManager
99
{
1010
private readonly CallbackCollection<AuthorityChangeReceived> callbackCollection = new CallbackCollection<AuthorityChangeReceived>();
1111
private readonly uint componentId;
@@ -35,18 +35,6 @@ public void InvokeCallbacks()
3535
}
3636
}
3737

38-
public void InvokeLossImminentCallbacks()
39-
{
40-
var changes = componentUpdateSystem.GetAuthorityChangesReceived(componentId);
41-
for (var i = 0; i < changes.Count; ++i)
42-
{
43-
if (changes[i].Authority == Authority.AuthorityLossImminent)
44-
{
45-
callbackCollection.InvokeAllReverse(changes[i]);
46-
}
47-
}
48-
}
49-
5038
public ulong RegisterCallback(Action<AuthorityChangeReceived> callback)
5139
{
5240
callbackCollection.Add(nextCallbackId, callback);

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/ComponentAuthorityCallbackManager.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Improbable.Gdk.Subscriptions
77
{
8-
internal class ComponentAuthorityCallbackManager : IAuthorityCallbackManager
8+
internal class ComponentAuthorityCallbackManager : ICallbackManager
99
{
1010
private readonly EntityCallbacks<Authority> callbacks = new EntityCallbacks<Authority>();
1111
private readonly uint componentId;
@@ -34,18 +34,6 @@ public void InvokeCallbacks()
3434
}
3535
}
3636

37-
public void InvokeLossImminentCallbacks()
38-
{
39-
var changes = componentUpdateSystem.GetAuthorityChangesReceived(componentId);
40-
for (var i = 0; i < changes.Count; ++i)
41-
{
42-
if (changes[i].Authority == Authority.AuthorityLossImminent)
43-
{
44-
callbacks.InvokeAllReverse(changes[i].EntityId, changes[i].Authority);
45-
}
46-
}
47-
}
48-
4937
public ulong RegisterCallback(EntityId entityId, Action<Authority> callback)
5038
{
5139
return callbacks.Add(entityId, callback);

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs

-7
This file was deleted.

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CallbackManagers/IAuthorityCallbackManager.cs.meta

-11
This file was deleted.

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/ComponentCallbackSystem.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,12 @@ public bool UnregisterCallback(ulong callbackKey)
7474
return keyAndManager.Item2.UnregisterCallback(keyAndManager.Item1);
7575
}
7676

77-
internal void InvokeNoLossImminent()
77+
internal void InvokeCallbacks()
7878
{
7979
componentCallbackManagers.InvokeEach(manager => manager.InvokeCallbacks());
8080
authorityCallbackManagers.InvokeEach(manager => manager.InvokeCallbacks());
8181
}
8282

83-
internal void InvokeLossImminent()
84-
{
85-
authorityCallbackManagers.InvokeEach(manager => manager.InvokeLossImminentCallbacks());
86-
}
87-
8883
protected override void OnCreate()
8984
{
9085
base.OnCreate();

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/RequireLifecycleSystem.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override void OnUpdate()
4242
{
4343
componentConstraintsCallbackSystem.Invoke();
4444

45-
componentCallbackSystem.InvokeNoLossImminent();
45+
componentCallbackSystem.InvokeCallbacks();
4646

4747
if (behavioursToEnable.Count > 0)
4848
{
@@ -59,8 +59,6 @@ protected override void OnUpdate()
5959
behavioursToEnable.Clear();
6060
}
6161

62-
componentCallbackSystem.InvokeLossImminent();
63-
6462
commandCallbackSystem.InvokeCallbacks();
6563
workerFlagCallbackSystem.InvokeCallbacks();
6664
}

workers/unity/Packages/io.improbable.gdk.core/Systems/ComponentUpdateSystem.cs

-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public List<EntityId> GetComponentsRemoved(uint componentId)
7070
return manager.GetComponentsRemoved();
7171
}
7272

73-
public void AcknowledgeAuthorityLoss(EntityId entityId, uint componentId)
74-
{
75-
worker.MessagesToSend.AcknowledgeAuthorityLoss(entityId.Id, componentId);
76-
}
77-
7873
protected override void OnCreate()
7974
{
8075
base.OnCreate();

workers/unity/Packages/io.improbable.gdk.core/Worker/MessagesToSend.cs

-14
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ private static class MessagesToSendMetadata
3535

3636
private readonly WorldCommandsToSendStorage worldCommandStorage = new WorldCommandsToSendStorage();
3737

38-
private readonly MessageList<EntityComponent> authorityLossAcks =
39-
new MessageList<EntityComponent>();
40-
4138
private readonly MessageList<LogMessageToSend> logsToSend = new MessageList<LogMessageToSend>();
4239

4340
private readonly List<Metrics> metricsToSend = new List<Metrics>();
@@ -90,16 +87,10 @@ public void Clear()
9087
storage.Clear();
9188
}
9289

93-
authorityLossAcks.Clear();
9490
logsToSend.Clear();
9591
metricsToSend.Clear();
9692
}
9793

98-
public void AcknowledgeAuthorityLoss(long entityId, uint componentId)
99-
{
100-
authorityLossAcks.Add(new EntityComponent(entityId, componentId));
101-
}
102-
10394
public void AddComponentUpdate<T>(in T update, long entityId)
10495
where T : ISpatialComponentUpdate
10596
{
@@ -152,11 +143,6 @@ internal List<Metrics> GetMetrics()
152143
return metricsToSend;
153144
}
154145

155-
internal MessageList<EntityComponent> GetAuthorityLossAcknowledgements()
156-
{
157-
return authorityLossAcks;
158-
}
159-
160146
internal IComponentDiffStorage GetComponentDiffStorage(uint componentId)
161147
{
162148
if (!componentIdToComponentStorage.TryGetValue(componentId, out var storage))

workers/unity/Packages/io.improbable.gdk.core/Worker/SerializedMessagesToSend.cs

-13
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public class SerializedMessagesToSend
4242

4343
private readonly List<Metrics> metricsToSend = new List<Metrics>();
4444

45-
private readonly MessageList<EntityComponent> authorityLossAcks =
46-
new MessageList<EntityComponent>();
47-
4845
private readonly List<IComponentSerializer> componentSerializers = new List<IComponentSerializer>();
4946
private readonly List<ICommandSerializer> commandSerializers = new List<ICommandSerializer>();
5047

@@ -106,8 +103,6 @@ public void SerializeFrom(MessagesToSend messages, CommandMetaData commandMetaDa
106103

107104
messages.GetLogMessages().CopyTo(logMessages);
108105

109-
messages.GetAuthorityLossAcknowledgements().CopyTo(authorityLossAcks);
110-
111106
foreach (var serializer in componentSerializers)
112107
{
113108
serializer.Serialize(messages, this);
@@ -126,7 +121,6 @@ public void Clear()
126121
entityQueryRequests.Clear();
127122
metricsToSend.Clear();
128123
logMessages.Clear();
129-
authorityLossAcks.Clear();
130124
netFrameStats.Clear();
131125
}
132126

@@ -203,13 +197,6 @@ public void SendAndClear(Connection connection, CommandMetaData commandMetaData,
203197
logMessage.EntityId);
204198
}
205199

206-
for (var i = 0; i < authorityLossAcks.Count; ++i)
207-
{
208-
ref readonly var entityComponent = ref authorityLossAcks[i];
209-
connection.SendAuthorityLossImminentAcknowledgement(entityComponent.EntityId,
210-
entityComponent.ComponentId);
211-
}
212-
213200
frameStats.Merge(netFrameStats);
214201
Clear();
215202
}

workers/unity/Packages/io.improbable.gdk.core/Worker/ViewDiff.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ public void SetAuthority(long entityId, uint componentId, Authority authority)
168168
{
169169
throw new ArgumentException(
170170
$"Can not set authority over component with ID {componentId} for entity with ID {entityId}. " +
171-
$"Unknown component ID");
171+
"Unknown component ID");
172+
}
173+
174+
if (authority == Authority.AuthorityLossImminent)
175+
{
176+
return;
172177
}
173178

174179
((IDiffAuthorityStorage) authorityStorage).AddAuthorityChange(

workers/unity/Packages/io.improbable.gdk.gameobjectcreation/.codegen/Source/Generators/GameObjectCreation/UnityComponentReaderWriterGenerator.cs

-7
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,6 @@ private static TypeBlock GenerateComponentWriter(UnityComponentDetails component
258258
}}
259259
");
260260
}
261-
262-
writer.Line($@"
263-
public void AcknowledgeAuthorityLoss()
264-
{{
265-
ComponentUpdateSystem.AcknowledgeAuthorityLoss(EntityId, {componentDetails.Name}.ComponentId);
266-
}}
267-
");
268261
});
269262
}
270263
}

0 commit comments

Comments
 (0)