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

Commit

Permalink
Removed all usages and support for Authority.AuthorityLossImminent (#…
Browse files Browse the repository at this point in the history
…1451)

* Removed all usages and support for Authority.AuthorityLossImminent
  • Loading branch information
zeroZshadow authored Aug 11, 2020
1 parent 515adce commit cf3a0e9
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 93 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Improbable.Gdk.Subscriptions
{
internal class AuthorityConstraintCallbackManager : IAuthorityCallbackManager
internal class AuthorityConstraintCallbackManager : ICallbackManager
{
private readonly CallbackCollection<AuthorityChangeReceived> callbackCollection = new CallbackCollection<AuthorityChangeReceived>();
private readonly uint componentId;
Expand Down Expand Up @@ -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<AuthorityChangeReceived> callback)
{
callbackCollection.Add(nextCallbackId, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Improbable.Gdk.Subscriptions
{
internal class ComponentAuthorityCallbackManager : IAuthorityCallbackManager
internal class ComponentAuthorityCallbackManager : ICallbackManager
{
private readonly EntityCallbacks<Authority> callbacks = new EntityCallbacks<Authority>();
private readonly uint componentId;
Expand Down Expand Up @@ -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<Authority> callback)
{
return callbacks.Add(entityId, callback);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override void OnUpdate()
{
componentConstraintsCallbackSystem.Invoke();

componentCallbackSystem.InvokeNoLossImminent();
componentCallbackSystem.InvokeCallbacks();

if (behavioursToEnable.Count > 0)
{
Expand All @@ -59,8 +59,6 @@ protected override void OnUpdate()
behavioursToEnable.Clear();
}

componentCallbackSystem.InvokeLossImminent();

commandCallbackSystem.InvokeCallbacks();
workerFlagCallbackSystem.InvokeCallbacks();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public List<EntityId> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ private static class MessagesToSendMetadata

private readonly WorldCommandsToSendStorage worldCommandStorage = new WorldCommandsToSendStorage();

private readonly MessageList<EntityComponent> authorityLossAcks =
new MessageList<EntityComponent>();

private readonly MessageList<LogMessageToSend> logsToSend = new MessageList<LogMessageToSend>();

private readonly List<Metrics> metricsToSend = new List<Metrics>();
Expand Down Expand Up @@ -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<T>(in T update, long entityId)
where T : ISpatialComponentUpdate
{
Expand Down Expand Up @@ -152,11 +143,6 @@ internal List<Metrics> GetMetrics()
return metricsToSend;
}

internal MessageList<EntityComponent> GetAuthorityLossAcknowledgements()
{
return authorityLossAcks;
}

internal IComponentDiffStorage GetComponentDiffStorage(uint componentId)
{
if (!componentIdToComponentStorage.TryGetValue(componentId, out var storage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public class SerializedMessagesToSend

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

private readonly MessageList<EntityComponent> authorityLossAcks =
new MessageList<EntityComponent>();

private readonly List<IComponentSerializer> componentSerializers = new List<IComponentSerializer>();
private readonly List<ICommandSerializer> commandSerializers = new List<ICommandSerializer>();

Expand Down Expand Up @@ -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);
Expand All @@ -126,7 +121,6 @@ public void Clear()
entityQueryRequests.Clear();
metricsToSend.Clear();
logMessages.Clear();
authorityLossAcks.Clear();
netFrameStats.Clear();
}

Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ private static TypeBlock GenerateComponentWriter(UnityComponentDetails component
}}
");
}

writer.Line($@"
public void AcknowledgeAuthorityLoss()
{{
ComponentUpdateSystem.AcknowledgeAuthorityLoss(EntityId, {componentDetails.Name}.ComponentId);
}}
");
});
}
}
Expand Down

0 comments on commit cf3a0e9

Please sign in to comment.