From c090a634d6101fa0fda6fc06ede0f9eca1c3a453 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Wed, 18 Mar 2020 14:38:17 +0000 Subject: [PATCH 1/8] Add Worker.GetEntity which throws is Entity does not exist Replace TryGetEntity with GetEntity in area's where we do not test if the entity exists --- .../Generators/Core/UnityEcsViewManagerGenerator.cs | 10 +++++----- .../CommandSenderReceiverSubscriptionManagerBase.cs | 7 +++---- .../Subscriptions/ReaderSubscriptionManager.cs | 2 -- .../EntitySubscriptionManager.cs | 2 +- .../StandardSubscriptionManagers/WorldCommands.cs | 3 ++- .../Subscriptions/WriterSubscriptionManager.cs | 4 +--- .../io.improbable.gdk.core/Systems/WorkerSystem.cs | 11 +++++++++++ .../GameObjectInitializationSystem.cs | 2 +- 8 files changed, 24 insertions(+), 17 deletions(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs b/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs index b34ff7e5a8..10324891df 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs @@ -105,7 +105,7 @@ public void Init(World world) { m.Line(new[] { - "workerSystem.TryGetEntity(entityId, out var entity);", + "var entity = workerSystem.GetEntity(entityId);", $"var component = new {componentNamespace}.Component();" }); @@ -126,7 +126,7 @@ public void Init(World world) { m.Line(new[] { - "workerSystem.TryGetEntity(entityId, out var entity);", + "var entity = workerSystem.GetEntity(entityId);", "entityManager.RemoveComponent(entity);" }); @@ -145,7 +145,7 @@ public void Init(World world) evm.Method("private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity)", m => { m.Line(@" -workerSystem.TryGetEntity(update.EntityId, out var entity); +var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -177,13 +177,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CommandSenderReceiverSubscriptionManagerBase.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CommandSenderReceiverSubscriptionManagerBase.cs index 2329a21ee1..aef4d978ab 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CommandSenderReceiverSubscriptionManagerBase.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/CommandSenderReceiverSubscriptionManagerBase.cs @@ -37,7 +37,8 @@ protected CommandSenderSubscriptionManagerBase(World world) : base(world) return; } - WorkerSystem.TryGetEntity(entityId, out var entity); + var entity = WorkerSystem.GetEntity(entityId); + foreach (var subscription in subscriptions) { if (!subscription.HasValue) @@ -152,7 +153,7 @@ protected CommandReceiverSubscriptionManagerBase(World world, uint componentId) return; } - WorkerSystem.TryGetEntity(authorityChange.EntityId, out var entity); + var entity = WorkerSystem.GetEntity(authorityChange.EntityId); foreach (var subscription in entityIdToReceiveSubscriptions[authorityChange.EntityId]) { @@ -169,8 +170,6 @@ protected CommandReceiverSubscriptionManagerBase(World world, uint componentId) return; } - WorkerSystem.TryGetEntity(authorityChange.EntityId, out var entity); - foreach (var subscription in entityIdToReceiveSubscriptions[authorityChange.EntityId]) { ResetValue(subscription); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs index 9fd738c7e2..9dfa6ca0a3 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs @@ -55,8 +55,6 @@ private void RegisterComponentCallbacks() return; } - WorkerSystem.TryGetEntity(entityId, out _); - foreach (var subscription in entityIdToReaderSubscriptions[entityId]) { ResetValue(subscription); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/EntitySubscriptionManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/EntitySubscriptionManager.cs index 4184bd9d38..d6ade27c57 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/EntitySubscriptionManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/EntitySubscriptionManager.cs @@ -33,7 +33,7 @@ public EntitySubscriptionManager(World world) : base(world) return; } - WorkerSystem.TryGetEntity(entityId, out var entity); + var entity = WorkerSystem.GetEntity(entityId); foreach (var subscription in subscriptions) { if (!subscription.HasValue) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/WorldCommands.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/WorldCommands.cs index 4dcd178870..71e668a373 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/WorldCommands.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/StandardSubscriptionManagers/WorldCommands.cs @@ -25,7 +25,8 @@ public WorldCommandSenderSubscriptionManager(World world) : base(world) return; } - WorkerSystem.TryGetEntity(entityId, out var entity); + var entity = WorkerSystem.GetEntity(entityId); + foreach (var subscription in subscriptions) { subscription.SetAvailable(new WorldCommandSender(entity, world)); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/WriterSubscriptionManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/WriterSubscriptionManager.cs index 23c459648c..122f1f4539 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/WriterSubscriptionManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/WriterSubscriptionManager.cs @@ -39,7 +39,7 @@ private void RegisterComponentCallbacks() return; } - WorkerSystem.TryGetEntity(authorityChange.EntityId, out var entity); + var entity = WorkerSystem.GetEntity(authorityChange.EntityId); foreach (var subscription in entityIdToWriterSubscriptions[authorityChange.EntityId]) { @@ -56,8 +56,6 @@ private void RegisterComponentCallbacks() return; } - WorkerSystem.TryGetEntity(authorityChange.EntityId, out _); - foreach (var subscription in entityIdToWriterSubscriptions[authorityChange.EntityId]) { ResetValue(subscription); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs index d6bd4daa20..baffdaf61b 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Improbable.Gdk.Core.NetworkStats; using Improbable.Worker.CInterop; @@ -66,6 +67,16 @@ public bool TryGetEntity(EntityId entityId, out Entity entity) { return EntityIdToEntity.TryGetValue(entityId, out entity); } + + public Entity GetEntity(EntityId entityId) + { + if (!EntityIdToEntity.TryGetValue(entityId, out var entity)) + { + throw new ArgumentException($"Unknown EntityId {entityId}", nameof(entityId)); + } + + return entity; + } /// /// Checks whether a SpatialOS entity is checked out on this worker. diff --git a/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/GameObjectInitializationSystem.cs b/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/GameObjectInitializationSystem.cs index 372aec2835..203f0dc3a2 100644 --- a/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/GameObjectInitializationSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.gameobjectcreation/GameObjectInitializationSystem.cs @@ -60,7 +60,7 @@ protected override void OnUpdate() { foreach (var entityId in entitySystem.GetEntitiesAdded()) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); gameObjectCreator.OnEntityCreated(new SpatialOSEntity(entity, EntityManager), Linker); } From b33dfd8ccc2ecaf850c53c65ff0afbd137367530 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Wed, 18 Mar 2020 14:40:39 +0000 Subject: [PATCH 2/8] Add validation checks for adding callbacks to Readers. Avoid capturing component for linking MonoBehaviours, enforce linked component is used. --- .../Subscriptions/EntityGameObjectLinker.cs | 6 ++---- .../Subscriptions/Reader.cs | 5 +++++ .../RequiredSubscriptionsInjector.cs | 16 ++++++++-------- .../UnityComponentReaderWriterGenerator.cs | 10 ++++++++++ 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/EntityGameObjectLinker.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/EntityGameObjectLinker.cs index 0895b6efb8..86a5da5984 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/EntityGameObjectLinker.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/EntityGameObjectLinker.cs @@ -99,8 +99,8 @@ public void LinkGameObjectToSpatialOSEntity(EntityId entityId, GameObject gameOb { // todo this should possibly happen when the command buffer is flushed too injectors.Add(new RequiredSubscriptionsInjector(component, entityId, subscriptionSystem, - () => lifecycleSystem.EnableMonoBehaviour(component), - () => lifecycleSystem.DisableMonoBehaviour(component))); + target => lifecycleSystem.EnableMonoBehaviour((MonoBehaviour) target), + target => lifecycleSystem.DisableMonoBehaviour((MonoBehaviour) target))); } } @@ -178,8 +178,6 @@ public void UnlinkAllGameObjectsFromEntityId(EntityId entityId) return; } - workerSystem.TryGetEntity(entityId, out var entity); - while (gameObjectSet.Count > 0) { UnlinkGameObjectFromEntity(entityId, gameObjectSet[gameObjectSet.Count - 1]); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Reader.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Reader.cs index 2459ac30cd..d73500e9f2 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Reader.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Reader.cs @@ -76,6 +76,11 @@ public event Action OnUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add OnUpdate callback when Reader is not valid."); + } + if (updateCallbackToCallbackKey == null) { updateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs index 0fda24ab9d..46b3f850d1 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs @@ -12,13 +12,13 @@ public class RequiredSubscriptionsInjector private readonly RequiredSubscriptionsInfo info; private readonly object target; - private readonly Action onEnable; - private readonly Action onDisable; + private readonly Action onEnable; + private readonly Action onDisable; // todo should either special case monobehaviours or not use callbacks // for non monobehaviours we could use functors public RequiredSubscriptionsInjector(object target, EntityId entityId, SubscriptionSystem subscriptionSystem, - Action onEnable = null, Action onDisable = null) + Action onEnable = null, Action onDisable = null) { this.target = target; this.onEnable = onEnable; @@ -28,7 +28,7 @@ public RequiredSubscriptionsInjector(object target, EntityId entityId, Subscript if (info == null || info.RequiredTypes.Length == 0) { - onEnable?.Invoke(); + onEnable?.Invoke(target); return; } @@ -41,14 +41,14 @@ public void CancelSubscriptions() { if (subscriptions == null) { - onDisable?.Invoke(); + onDisable?.Invoke(target); return; } Handler.Pool.Return((Handler) subscriptions.GetAvailabilityHandler()); subscriptions.Cancel(); - onDisable?.Invoke(); + onDisable?.Invoke(target); if (target == null) { @@ -68,12 +68,12 @@ private void HandleSubscriptionsSatisfied() field.SetValue(target, subscriptions.GetErasedValue(field.FieldType)); } - onEnable?.Invoke(); + onEnable?.Invoke(target); } private void HandleSubscriptionsNoLongerSatisfied() { - onDisable?.Invoke(); + onDisable?.Invoke(target); foreach (var field in info.RequiredFields) { 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 77121a33ea..bfa5402c5c 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 @@ -103,6 +103,11 @@ public event Action<{fieldDetails.Type}> On{fieldDetails.PascalCaseName}Update {{ add {{ + if (!IsValid) + {{ + throw new InvalidOperationException(""Cannot add field update callback when Reader is not valid.""); + }} + if ({fieldDetails.CamelCaseName}UpdateCallbackToCallbackKey == null) {{ {fieldDetails.CamelCaseName}UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -141,6 +146,11 @@ public event Action<{eventDetails.FqnPayloadType}> On{eventDetails.PascalCaseNam {{ add {{ + if (!IsValid) + {{ + throw new InvalidOperationException(""Cannot add event callback when Reader is not valid.""); + }} + if ({eventDetails.CamelCaseName}EventCallbackToCallbackKey == null) {{ {eventDetails.CamelCaseName}EventCallbackToCallbackKey = new Dictionary, ulong>(); From ba2a5c1338cd6a0081761e231949e0f51ba80396 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Thu, 19 Mar 2020 16:21:51 +0000 Subject: [PATCH 3/8] Add tests for removed and re-added components breaking AggregateSubscriptions --- .../Subscriptions/RequireablesDisableTests.cs | 68 +++++++++++++++++++ .../MockConnectionHandler.cs | 6 ++ 2 files changed, 74 insertions(+) diff --git a/test-project/Assets/EditmodeTests/Subscriptions/RequireablesDisableTests.cs b/test-project/Assets/EditmodeTests/Subscriptions/RequireablesDisableTests.cs index 925e3c92a7..7eb2649cb7 100644 --- a/test-project/Assets/EditmodeTests/Subscriptions/RequireablesDisableTests.cs +++ b/test-project/Assets/EditmodeTests/Subscriptions/RequireablesDisableTests.cs @@ -2,6 +2,7 @@ using Improbable.Gdk.Subscriptions; using Improbable.Gdk.Test; using Improbable.Gdk.TestUtils; +using Improbable.Tests; using Improbable.Worker.CInterop; using NUnit.Framework; using UnityEngine; @@ -38,6 +39,66 @@ public void Reader_is_disabled_if_component_removed() }); } + [Test] + public void Reader_is_reenabled_if_component_regained() + { + World + .Step(world => + { + world.Connection.CreateEntity(EntityId, GetTemplate()); + }) + .Step(world => + { + var (_, readerBehaviour) = world.CreateGameObject(EntityId); + return readerBehaviour; + }) + .Step(world => + { + world.Connection.RemoveComponent(EntityId, Position.ComponentId); + }) + .Step(world => + { + world.Connection.AddComponent(EntityId, Position.ComponentId, new Position.Update()); + }) + .Step((world, context) => + { + var readerBehaviour = context; + + Assert.IsNotNull(readerBehaviour.Reader); + Assert.IsTrue(readerBehaviour.Reader.IsValid); + }); + } + + [Test] + public void Reader_is_reenabled_if_component_regained_with_aggregate() + { + World + .Step(world => + { + world.Connection.CreateEntity(EntityId, GetTemplate()); + }) + .Step(world => + { + var (_, readerBehaviour) = world.CreateGameObject(EntityId); + return readerBehaviour; + }) + .Step(world => + { + world.Connection.RemoveComponent(EntityId, Position.ComponentId); + }) + .Step(world => + { + world.Connection.AddComponent(EntityId, Position.ComponentId, new Position.Update()); + }) + .Step((world, context) => + { + var readerBehaviour = context; + + Assert.IsNotNull(readerBehaviour.DependencyTestReader); + Assert.IsTrue(readerBehaviour.DependencyTestReader.IsValid); + }); + } + [Test] public void Writer_is_disabled_if_loses_auth() { @@ -148,6 +209,7 @@ private static EntityTemplate GetTemplate() { var template = new EntityTemplate(); template.AddComponent(new Position.Snapshot(), "worker"); + template.AddComponent(new DependencyTest.Snapshot(), "worker"); template.AddComponent(new TestCommands.Snapshot(), "worker"); return template; } @@ -179,6 +241,12 @@ private class MultipleReaderBehaviour : MonoBehaviour [Require] public PositionReader PositionReader; [Require] public TestCommandsReader TestCommandsReader; } + + private class MultipleComponentBehaviour : MonoBehaviour + { + [Require] public PositionReader PositionReader; + [Require] public DependencyTestReader DependencyTestReader; + } #pragma warning restore 649 diff --git a/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs b/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs index 66698d29e9..663306261f 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs @@ -67,6 +67,12 @@ public void RemoveComponent(long entityId, uint componentId) { currentDiff.RemoveComponent(entityId, componentId); } + + public void AddComponent(long entityId, uint componentId, T component) + where T : ISpatialComponentUpdate + { + currentDiff.AddComponent(component, entityId, componentId); + } public void UpdateComponentAndAddEvents(long entityId, uint componentId, TUpdate update, params TEvent[] events) From a0b7e6832ca0536f0664c2c272a3c04f98218cc5 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Thu, 19 Mar 2020 16:22:16 +0000 Subject: [PATCH 4/8] Forgot GetEntity safety check --- .../Subscriptions/ReaderSubscriptionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs index 9dfa6ca0a3..c9f3d3b094 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/ReaderSubscriptionManager.cs @@ -37,7 +37,7 @@ private void RegisterComponentCallbacks() return; } - WorkerSystem.TryGetEntity(entityId, out var entity); + var entity = WorkerSystem.GetEntity(entityId); foreach (var subscription in entityIdToReaderSubscriptions[entityId]) { From 0249cfbff7f2e2d93c68a1159b37bd0a134815c6 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Thu, 19 Mar 2020 16:22:51 +0000 Subject: [PATCH 5/8] Make readers valid when AggregateSubscription becomes valid --- .../Subscriptions/RequiredSubscriptionsInjector.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs index 46b3f850d1..f5b26ddd66 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs @@ -65,7 +65,13 @@ private void HandleSubscriptionsSatisfied() { foreach (var field in info.RequiredFields) { - field.SetValue(target, subscriptions.GetErasedValue(field.FieldType)); + var obj = subscriptions.GetErasedValue(field.FieldType); + if (obj is IRequireable requireable) + { + requireable.IsValid = true; + } + + field.SetValue(target, obj); } onEnable?.Invoke(target); From aa3211f22a962a9f66c75b76c30933ccfb47990c Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Thu, 19 Mar 2020 16:24:07 +0000 Subject: [PATCH 6/8] Generated Code --- ...DependentComponentComponentReaderWriter.cs | 25 +++++ .../DependentComponentEcsViewManager.cs | 10 +- ...ndentDataComponentComponentReaderWriter.cs | 95 +++++++++++++++++++ .../DependentDataComponentEcsViewManager.cs | 10 +- ...ependencyTestChildComponentReaderWriter.cs | 5 + .../DependencyTestChildEcsViewManager.cs | 10 +- .../DependencyTestComponentReaderWriter.cs | 5 + .../tests/DependencyTestEcsViewManager.cs | 10 +- ...encyTestGrandchildComponentReaderWriter.cs | 5 + .../DependencyTestGrandchildEcsViewManager.cs | 10 +- ...NestedTypeSameNameComponentReaderWriter.cs | 15 +++ ...ntUsingNestedTypeSameNameEcsViewManager.cs | 10 +- .../ExhaustiveEntityComponentReaderWriter.cs | 25 +++++ .../ExhaustiveEntityEcsViewManager.cs | 10 +- .../ExhaustiveMapKeyComponentReaderWriter.cs | 90 ++++++++++++++++++ .../ExhaustiveMapKeyEcsViewManager.cs | 10 +- ...ExhaustiveMapValueComponentReaderWriter.cs | 90 ++++++++++++++++++ .../ExhaustiveMapValueEcsViewManager.cs | 10 +- ...ExhaustiveOptionalComponentReaderWriter.cs | 90 ++++++++++++++++++ .../ExhaustiveOptionalEcsViewManager.cs | 10 +- ...ExhaustiveRepeatedComponentReaderWriter.cs | 90 ++++++++++++++++++ .../ExhaustiveRepeatedEcsViewManager.cs | 10 +- ...ExhaustiveSingularComponentReaderWriter.cs | 90 ++++++++++++++++++ .../ExhaustiveSingularEcsViewManager.cs | 10 +- ...RecursiveComponentComponentReaderWriter.cs | 15 +++ .../RecursiveComponentEcsViewManager.cs | 10 +- 26 files changed, 705 insertions(+), 65 deletions(-) diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs index e46d5d0b70..993c7f4906 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs @@ -57,6 +57,11 @@ internal DependentComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (aUpdateCallbackToCallbackKey == null) { aUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -87,6 +92,11 @@ internal DependentComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (bUpdateCallbackToCallbackKey == null) { bUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -117,6 +127,11 @@ internal DependentComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (cUpdateCallbackToCallbackKey == null) { cUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -147,6 +162,11 @@ internal DependentComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (dUpdateCallbackToCallbackKey == null) { dUpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -177,6 +197,11 @@ internal DependentComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (eUpdateCallbackToCallbackKey == null) { eUpdateCallbackToCallbackKey = new Dictionary>, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentEcsViewManager.cs index dd09ce9ba7..616af7de7c 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentEcsViewManager.cs @@ -88,7 +88,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.DependentSchema.DependentComponent.Component(); component.aHandle = global::Improbable.DependentSchema.DependentComponent.ReferenceTypeProviders.AProvider.Allocate(world); @@ -106,7 +106,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -124,7 +124,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -167,13 +167,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs index 5e9d5ab68a..8df2f80968 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs @@ -83,6 +83,11 @@ public event Action OnField1Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -113,6 +118,11 @@ public event Action OnField2Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -143,6 +153,11 @@ public event Action OnField2Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -173,6 +188,11 @@ public event Action OnField4Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -203,6 +223,11 @@ public event Action OnField5Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -233,6 +258,11 @@ public event Action OnField6Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -263,6 +293,11 @@ public event Action OnField6Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -293,6 +328,11 @@ public event Action OnField8Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -323,6 +363,11 @@ public event Action OnField9Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -353,6 +398,11 @@ public event Action OnField10Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -383,6 +433,11 @@ public event Action OnField11Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -413,6 +468,11 @@ public event Action OnField12Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -443,6 +503,11 @@ public event Action OnField13Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -473,6 +538,11 @@ public event Action OnField14Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -503,6 +573,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -533,6 +608,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -563,6 +643,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -593,6 +678,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -624,6 +714,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add event callback when Reader is not valid."); + } + if (fooEventEventCallbackToCallbackKey == null) { fooEventEventCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentEcsViewManager.cs index ea06a63576..2aef5a05cd 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentEcsViewManager.cs @@ -116,7 +116,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.DependentSchema.DependentDataComponent.Component(); component.field1Handle = global::Improbable.DependentSchema.DependentDataComponent.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -162,7 +162,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -208,7 +208,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -316,13 +316,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs index 1c47b574fb..1856b5b12a 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs @@ -49,6 +49,11 @@ public event Action OnChildUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (childUpdateCallbackToCallbackKey == null) { childUpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildEcsViewManager.cs index a0f43d5fec..09817504e8 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildEcsViewManager.cs @@ -81,7 +81,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.Tests.DependencyTestChild.Component(); component.MarkDataClean(); @@ -91,7 +91,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); entityManager.RemoveComponent(entity); @@ -99,7 +99,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -122,13 +122,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs index c4af4d76a6..8202984f56 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs @@ -49,6 +49,11 @@ public event Action OnRootUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (rootUpdateCallbackToCallbackKey == null) { rootUpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestEcsViewManager.cs index 0c57d3461f..9790c70571 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestEcsViewManager.cs @@ -81,7 +81,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.Tests.DependencyTest.Component(); component.MarkDataClean(); @@ -91,7 +91,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); entityManager.RemoveComponent(entity); @@ -99,7 +99,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -122,13 +122,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs index 859432b977..020714ca82 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs @@ -49,6 +49,11 @@ public event Action OnGrandchildUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (grandchildUpdateCallbackToCallbackKey == null) { grandchildUpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildEcsViewManager.cs index 2b34558efd..1624a52951 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildEcsViewManager.cs @@ -81,7 +81,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.Tests.DependencyTestGrandchild.Component(); component.MarkDataClean(); @@ -91,7 +91,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); entityManager.RemoveComponent(entity); @@ -99,7 +99,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -122,13 +122,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs index e7a9f20efa..65733d563b 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs @@ -53,6 +53,11 @@ public event Action OnNestedFieldUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (nestedFieldUpdateCallbackToCallbackKey == null) { nestedFieldUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -83,6 +88,11 @@ public event Action OnNestedFieldUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (other0FieldUpdateCallbackToCallbackKey == null) { other0FieldUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -113,6 +123,11 @@ public event Action OnNestedFieldUpdate { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (other1FieldUpdateCallbackToCallbackKey == null) { other1FieldUpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameEcsViewManager.cs index 36bab94eda..a67e2c501a 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameEcsViewManager.cs @@ -81,7 +81,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ComponentUsingNestedTypeSameName.Component(); component.MarkDataClean(); @@ -91,7 +91,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); entityManager.RemoveComponent(entity); @@ -99,7 +99,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -132,13 +132,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs index 0def0e92f9..4320e58bf4 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs @@ -57,6 +57,11 @@ internal ExhaustiveEntityReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -87,6 +92,11 @@ internal ExhaustiveEntityReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -117,6 +127,11 @@ internal ExhaustiveEntityReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -147,6 +162,11 @@ internal ExhaustiveEntityReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -177,6 +197,11 @@ internal ExhaustiveEntityReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityEcsViewManager.cs index f20046fa72..a8d34d09bc 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityEcsViewManager.cs @@ -90,7 +90,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveEntity.Component(); component.field1Handle = global::Improbable.TestSchema.ExhaustiveEntity.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -110,7 +110,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -130,7 +130,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -173,13 +173,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs index 65fcc6759d..b1147f2f08 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs @@ -83,6 +83,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -113,6 +118,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -143,6 +153,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -173,6 +188,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -203,6 +223,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -233,6 +258,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -263,6 +293,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -293,6 +328,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -323,6 +363,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -353,6 +398,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -383,6 +433,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -413,6 +468,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -443,6 +503,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -473,6 +538,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -503,6 +573,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -533,6 +608,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -563,6 +643,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -593,6 +678,11 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId) : { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyEcsViewManager.cs index 195388b688..1b3f3bdbd1 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyEcsViewManager.cs @@ -116,7 +116,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveMapKey.Component(); component.field1Handle = global::Improbable.TestSchema.ExhaustiveMapKey.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -162,7 +162,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -208,7 +208,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -316,13 +316,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs index 3af0cbf455..b15001d974 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs @@ -83,6 +83,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -113,6 +118,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -143,6 +153,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -173,6 +188,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -203,6 +223,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -233,6 +258,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -263,6 +293,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -293,6 +328,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -323,6 +363,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -353,6 +398,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -383,6 +433,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -413,6 +468,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -443,6 +503,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -473,6 +538,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -503,6 +573,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -533,6 +608,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -563,6 +643,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -593,6 +678,11 @@ internal ExhaustiveMapValueReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueEcsViewManager.cs index 0a05fc8671..e00ff7e929 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueEcsViewManager.cs @@ -116,7 +116,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveMapValue.Component(); component.field1Handle = global::Improbable.TestSchema.ExhaustiveMapValue.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -162,7 +162,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -208,7 +208,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -316,13 +316,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs index deca2ee182..de898eaa90 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs @@ -83,6 +83,11 @@ public event Action OnField1Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -113,6 +118,11 @@ public event Action OnField2Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -143,6 +153,11 @@ public event Action OnField2Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -173,6 +188,11 @@ public event Action OnField4Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -203,6 +223,11 @@ public event Action OnField5Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -233,6 +258,11 @@ public event Action OnField6Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -263,6 +293,11 @@ public event Action OnField6Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -293,6 +328,11 @@ public event Action OnField8Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -323,6 +363,11 @@ public event Action OnField9Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -353,6 +398,11 @@ public event Action OnField10Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -383,6 +433,11 @@ public event Action OnField11Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -413,6 +468,11 @@ public event Action OnField12Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -443,6 +503,11 @@ public event Action OnField13Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -473,6 +538,11 @@ public event Action OnField14Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -503,6 +573,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -533,6 +608,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -563,6 +643,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -593,6 +678,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalEcsViewManager.cs index 8a0a1869b8..803a6758ba 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalEcsViewManager.cs @@ -116,7 +116,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveOptional.Component(); component.field1Handle = global::Improbable.TestSchema.ExhaustiveOptional.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -162,7 +162,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -208,7 +208,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -316,13 +316,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs index d894dffc86..c22af8464f 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs @@ -83,6 +83,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -113,6 +118,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -143,6 +153,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -173,6 +188,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -203,6 +223,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -233,6 +258,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -263,6 +293,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -293,6 +328,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -323,6 +363,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -353,6 +398,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -383,6 +433,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -413,6 +468,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -443,6 +503,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -473,6 +538,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -503,6 +573,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -533,6 +608,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -563,6 +643,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); @@ -593,6 +678,11 @@ internal ExhaustiveRepeatedReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary>, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedEcsViewManager.cs index 8927672ea5..e1066e0d60 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedEcsViewManager.cs @@ -116,7 +116,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveRepeated.Component(); component.field1Handle = global::Improbable.TestSchema.ExhaustiveRepeated.ReferenceTypeProviders.Field1Provider.Allocate(world); @@ -162,7 +162,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -208,7 +208,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -316,13 +316,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs index f49dc0dd40..39d8b9b356 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs @@ -83,6 +83,11 @@ public event Action OnField1Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field1UpdateCallbackToCallbackKey == null) { field1UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -113,6 +118,11 @@ public event Action OnField2Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field2UpdateCallbackToCallbackKey == null) { field2UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -143,6 +153,11 @@ public event Action OnField3Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field3UpdateCallbackToCallbackKey == null) { field3UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -173,6 +188,11 @@ public event Action OnField4Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field4UpdateCallbackToCallbackKey == null) { field4UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -203,6 +223,11 @@ public event Action OnField5Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field5UpdateCallbackToCallbackKey == null) { field5UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -233,6 +258,11 @@ public event Action OnField6Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field6UpdateCallbackToCallbackKey == null) { field6UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -263,6 +293,11 @@ public event Action OnField7Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field7UpdateCallbackToCallbackKey == null) { field7UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -293,6 +328,11 @@ public event Action OnField8Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field8UpdateCallbackToCallbackKey == null) { field8UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -323,6 +363,11 @@ public event Action OnField9Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field9UpdateCallbackToCallbackKey == null) { field9UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -353,6 +398,11 @@ public event Action OnField10Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field10UpdateCallbackToCallbackKey == null) { field10UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -383,6 +433,11 @@ public event Action OnField11Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field11UpdateCallbackToCallbackKey == null) { field11UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -413,6 +468,11 @@ public event Action OnField12Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field12UpdateCallbackToCallbackKey == null) { field12UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -443,6 +503,11 @@ public event Action OnField13Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field13UpdateCallbackToCallbackKey == null) { field13UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -473,6 +538,11 @@ public event Action OnField14Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field14UpdateCallbackToCallbackKey == null) { field14UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -503,6 +573,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field15UpdateCallbackToCallbackKey == null) { field15UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -533,6 +608,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field16UpdateCallbackToCallbackKey == null) { field16UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -563,6 +643,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field17UpdateCallbackToCallbackKey == null) { field17UpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -593,6 +678,11 @@ public event Action OnField15Update { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (field18UpdateCallbackToCallbackKey == null) { field18UpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularEcsViewManager.cs index 2fc6e37db1..e28830f2a9 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularEcsViewManager.cs @@ -84,7 +84,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.ExhaustiveSingular.Component(); component.field3Handle = global::Improbable.TestSchema.ExhaustiveSingular.ReferenceTypeProviders.Field3Provider.Allocate(world); @@ -98,7 +98,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -112,7 +112,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -220,13 +220,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs index 8e588ef4c5..1de0968eaa 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs @@ -53,6 +53,11 @@ internal RecursiveComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (aUpdateCallbackToCallbackKey == null) { aUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -83,6 +88,11 @@ internal RecursiveComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (bUpdateCallbackToCallbackKey == null) { bUpdateCallbackToCallbackKey = new Dictionary, ulong>(); @@ -113,6 +123,11 @@ internal RecursiveComponentReader(World world, Entity entity, EntityId entityId) { add { + if (!IsValid) + { + throw new InvalidOperationException("Cannot add field update callback when Reader is not valid."); + } + if (cUpdateCallbackToCallbackKey == null) { cUpdateCallbackToCallbackKey = new Dictionary, ulong>(); diff --git a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentEcsViewManager.cs b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentEcsViewManager.cs index de710a3c59..d71a9c27b6 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentEcsViewManager.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentEcsViewManager.cs @@ -86,7 +86,7 @@ public void Clean(World world) private void AddComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); var component = new global::Improbable.TestSchema.RecursiveComponent.Component(); component.aHandle = global::Improbable.TestSchema.RecursiveComponent.ReferenceTypeProviders.AProvider.Allocate(world); @@ -102,7 +102,7 @@ private void AddComponent(EntityId entityId) private void RemoveComponent(EntityId entityId) { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.RemoveComponent(entity); var data = entityManager.GetComponentData(entity); @@ -118,7 +118,7 @@ private void RemoveComponent(EntityId entityId) private void ApplyUpdate(in ComponentUpdateReceived update, ComponentDataFromEntity dataFromEntity) { - workerSystem.TryGetEntity(update.EntityId, out var entity); + var entity = workerSystem.GetEntity(update.EntityId); if (!dataFromEntity.Exists(entity)) { return; @@ -151,13 +151,13 @@ private void SetAuthority(EntityId entityId, Authority authority) { case Authority.NotAuthoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.NotAuthoritative); break; } case Authority.Authoritative: { - workerSystem.TryGetEntity(entityId, out var entity); + var entity = workerSystem.GetEntity(entityId); entityManager.SetSharedComponentData(entity, ComponentAuthority.Authoritative); break; } From 49791fd96f41c6b9787d69e133d7d63cd4711f65 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Thu, 19 Mar 2020 17:41:45 +0000 Subject: [PATCH 7/8] Linting --- .../Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs | 2 +- .../Worker/ConnectionHandlers/MockConnectionHandler.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs index baffdaf61b..f1321f7042 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Systems/WorkerSystem.cs @@ -67,7 +67,7 @@ public bool TryGetEntity(EntityId entityId, out Entity entity) { return EntityIdToEntity.TryGetValue(entityId, out entity); } - + public Entity GetEntity(EntityId entityId) { if (!EntityIdToEntity.TryGetValue(entityId, out var entity)) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs b/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs index 663306261f..2629a796c6 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs @@ -67,7 +67,7 @@ public void RemoveComponent(long entityId, uint componentId) { currentDiff.RemoveComponent(entityId, componentId); } - + public void AddComponent(long entityId, uint componentId, T component) where T : ISpatialComponentUpdate { From 0211542c5f9cbc29a109184be7fef47b71117fc8 Mon Sep 17 00:00:00 2001 From: zeroZshadow Date: Fri, 20 Mar 2020 11:48:59 +0000 Subject: [PATCH 8/8] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 524bcb4ecb..8c1e21b704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Fixed a bug where Reader/Writer/CommandSender/CommandReceiver fields would not have their state set to invalid when the underlying constraints were not met. [#1297](https://github.com/spatialos/gdk-for-unity/pull/1297) - This bug would manifest itself in situations like a `Reader` reference attempting to read data that does not exist in your worker's view anymore. - Fixed the Mobile Launcher being unable to find the Android SDK when using the embedded installation. [#1319](https://github.com/spatialos/gdk-for-unity/pull/1319) +- Fixed a bug where losing a `Reader` due to QBI would break the monobehaviour that required it. [#1326](https://github.com/spatialos/gdk-for-unity/pull/1326) ### Removed