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

Commit 2b11e4a

Browse files
authored
Upgrade Entities packages to preview.33 (#963)
* Refactor world creation to allow for multiple worlds Replace PlayerLoop code to allow for custom root SystemGroups * Remove all deprecated API usages * Upgrade to entities preview.33 * Fix Reactive Components No longer generate empty queries for reactive component events and commands * Disconnected Workers get removed from PlayerLoop * Add physics module as entities requires it now * Add DisableAutoCreation attributes to groups * Limit client and worker framerate for playground * Tweak launch and worker configuration to work with our small playground Load-balancing now splits cubes across 2 workers in the cloud * Changelog
1 parent 6ff6038 commit 2b11e4a

File tree

190 files changed

+1766
-1789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+1766
-1789
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
- If you use schema that imports from GDK packages, you will need to change how you import GDK schema.
1111
- Schema file Y in package `improbable.gdk.X` is imported using `import "improbable/gdk/X/Y.schema"`.
1212
- For example, `import "from_gdk_packages/com.improbable.gdk.core/common.schema";` now becomes `import "improbable/gdk/core/common.schema";`.
13+
- Upgraded the Unity Entities package to `preview.33` from `preview.21`.
14+
- See the Unity Entities package [changelog](https://docs.unity3d.com/Packages/[email protected]/changelog/CHANGELOG.html) for more information.
15+
- This has removed several APIs such as `[Inject]` and `ComponentDataArray`.
16+
- If you use generic `IComponentData` types, you must explicitly register them. Please view Unity's example on `RegisterGenericComponentType` in the changelog linked above.
17+
- System groups API has changed, systems without a group are automatically added to the `SimulationSystemGroup` which runs on `Update`.
18+
- The Unity Editor will print helpful warnings if any systems are not grouped properly.
1319

1420
### Changed
1521

cloud_launch.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
22
"template": "small",
33
"world": {
4-
"chunkEdgeLengthMeters": 50,
4+
"chunkEdgeLengthMeters": 5,
55
"snapshots": {
66
"snapshotWritePeriodSeconds": 0
77
},
88
"dimensions": {
9-
"xMeters": 5000,
10-
"zMeters": 5000
9+
"xMeters": 500,
10+
"zMeters": 500
1111
}
1212
},
1313
"load_balancing": {
1414
"layer_configurations": [
1515
{
1616
"layer": "UnityGameLogic",
17-
"hex_grid": {
18-
"num_workers": 2
17+
"rectangle_grid": {
18+
"cols": 2,
19+
"rows": 1
1920
}
2021
}
2122
]

default_launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"template": "small",
33
"world": {
4-
"chunkEdgeLengthMeters": 50,
4+
"chunkEdgeLengthMeters": 5,
55
"snapshots": {
66
"snapshotWritePeriodSeconds": 0
77
},
88
"dimensions": {
9-
"xMeters": 5000,
10-
"zMeters": 5000
9+
"xMeters": 500,
10+
"zMeters": 500
1111
},
1212
"legacy_flags": [
1313
{

snapshots/default.snapshot

-4 Bytes
Binary file not shown.

test-project/Assets/EditmodeTests/Subscriptions/ReaderWriter/InjectionCriteriaTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ public void Setup()
3030
{
3131
world = new World("TestWorld");
3232
connectionHandler = new MockConnectionHandler();
33-
world.CreateManager<WorkerSystem>(connectionHandler, null,
33+
world.CreateSystem<WorkerSystem>(connectionHandler, null,
3434
new LoggingDispatcher(), "TestWorkerType", Vector3.zero);
35-
receiveSystem = world.CreateManager<SpatialOSReceiveSystem>();
36-
world.GetOrCreateManager<WorkerFlagCallbackSystem>();
37-
world.GetOrCreateManager<ComponentUpdateSystem>();
38-
world.GetOrCreateManager<ComponentConstraintsCallbackSystem>();
39-
world.CreateManager<SubscriptionSystem>();
40-
world.CreateManager<CommandCallbackSystem>();
41-
world.CreateManager<ComponentCallbackSystem>();
42-
requireLifecycleSystem = world.CreateManager<RequireLifecycleSystem>();
35+
receiveSystem = world.CreateSystem<SpatialOSReceiveSystem>();
36+
world.GetOrCreateSystem<WorkerFlagCallbackSystem>();
37+
world.GetOrCreateSystem<ComponentUpdateSystem>();
38+
world.GetOrCreateSystem<ComponentConstraintsCallbackSystem>();
39+
world.CreateSystem<SubscriptionSystem>();
40+
world.CreateSystem<CommandCallbackSystem>();
41+
world.CreateSystem<ComponentCallbackSystem>();
42+
requireLifecycleSystem = world.CreateSystem<RequireLifecycleSystem>();
4343

4444
linker = new EntityGameObjectLinker(world);
4545

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyComponentReaderWriter.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public class ExhaustiveMapKeyReaderSubscriptionManager : SubscriptionManager<Exh
3030
public ExhaustiveMapKeyReaderSubscriptionManager(World world)
3131
{
3232
this.world = world;
33-
entityManager = world.GetOrCreateManager<EntityManager>();
33+
entityManager = world.EntityManager;
3434

3535
// todo Check that these are there
36-
workerSystem = world.GetExistingManager<WorkerSystem>();
36+
workerSystem = world.GetExistingSystem<WorkerSystem>();
3737

38-
var constraintCallbackSystem = world.GetExistingManager<ComponentConstraintsCallbackSystem>();
38+
var constraintCallbackSystem = world.GetExistingSystem<ComponentConstraintsCallbackSystem>();
3939

4040
constraintCallbackSystem.RegisterComponentAddedCallback(ExhaustiveMapKey.ComponentId, entityId =>
4141
{
@@ -160,10 +160,10 @@ public ExhaustiveMapKeyWriterSubscriptionManager(World world)
160160
this.world = world;
161161

162162
// todo Check that these are there
163-
workerSystem = world.GetExistingManager<WorkerSystem>();
164-
componentUpdateSystem = world.GetExistingManager<ComponentUpdateSystem>();
163+
workerSystem = world.GetExistingSystem<WorkerSystem>();
164+
componentUpdateSystem = world.GetExistingSystem<ComponentUpdateSystem>();
165165

166-
var constraintCallbackSystem = world.GetExistingManager<ComponentConstraintsCallbackSystem>();
166+
var constraintCallbackSystem = world.GetExistingSystem<ComponentConstraintsCallbackSystem>();
167167

168168
constraintCallbackSystem.RegisterAuthorityCallback(ExhaustiveMapKey.ComponentId, authorityChange =>
169169
{
@@ -918,9 +918,9 @@ internal ExhaustiveMapKeyReader(World world, Entity entity, EntityId entityId)
918918

919919
IsValid = true;
920920

921-
ComponentUpdateSystem = world.GetExistingManager<ComponentUpdateSystem>();
922-
CallbackSystem = world.GetExistingManager<ComponentCallbackSystem>();
923-
EntityManager = world.GetExistingManager<EntityManager>();
921+
ComponentUpdateSystem = world.GetExistingSystem<ComponentUpdateSystem>();
922+
CallbackSystem = world.GetExistingSystem<ComponentCallbackSystem>();
923+
EntityManager = world.EntityManager;
924924
}
925925

926926
public void RemoveAllCallbacks()

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyEcsViewManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public class EcsViewManager : IEcsViewManager
1919

2020
private readonly ComponentType[] initialComponents = new ComponentType[]
2121
{
22-
ComponentType.Create<Component>(),
23-
ComponentType.Create<ComponentAuthority>(),
22+
ComponentType.ReadWrite<Component>(),
23+
ComponentType.ReadWrite<ComponentAuthority>(),
2424
};
2525

2626
public uint GetComponentId()
@@ -65,9 +65,9 @@ public void ApplyDiff(ViewDiff diff)
6565
public void Init(World world)
6666
{
6767
this.world = world;
68-
entityManager = world.GetOrCreateManager<EntityManager>();
68+
entityManager = world.EntityManager;
6969

70-
workerSystem = world.GetExistingManager<WorkerSystem>();
70+
workerSystem = world.GetExistingSystem<WorkerSystem>();
7171

7272
if (workerSystem == null)
7373
{

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyReactiveComponents.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
using Improbable.Gdk.ReactiveComponents;
1010
using Improbable.Worker.CInterop;
1111

12+
[assembly: RegisterGenericComponentType(typeof(ComponentAdded<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
13+
[assembly: RegisterGenericComponentType(typeof(ComponentRemoved<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
14+
[assembly: RegisterGenericComponentType(typeof(AuthorityChanges<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
15+
[assembly: RegisterGenericComponentType(typeof(Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
16+
[assembly: RegisterGenericComponentType(typeof(NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
17+
[assembly: RegisterGenericComponentType(typeof(AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>))]
18+
1219
namespace Improbable.Gdk.Tests
1320
{
1421
public partial class ExhaustiveMapKey
@@ -71,7 +78,7 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
7178
entityManager.RemoveComponent<ComponentRemoved<Component>>(entity);
7279
}
7380

74-
entityManager.AddComponent(entity, ComponentType.Create<ComponentAdded<Component>>());
81+
entityManager.AddComponent(entity, ComponentType.ReadWrite<ComponentAdded<Component>>());
7582
}
7683
}
7784

@@ -98,7 +105,7 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
98105
entityManager.RemoveComponent<ComponentAdded<Component>>(entity);
99106
}
100107

101-
entityManager.AddComponent(entity, ComponentType.Create<ComponentRemoved<Component>>());
108+
entityManager.AddComponent(entity, ComponentType.ReadWrite<ComponentRemoved<Component>>());
102109
}
103110
}
104111

@@ -154,11 +161,11 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
154161
{
155162
var authorityChanges = updateSystem.GetAuthorityChangesReceived(ComponentId);
156163

157-
foreach (var entityId in world.GetExistingManager<EntitySystem>().GetEntitiesAdded())
164+
foreach (var entityId in world.GetExistingSystem<EntitySystem>().GetEntitiesAdded())
158165
{
159166
workerSystem.TryGetEntity(entityId, out var entity);
160167
entityManager.AddComponent(entity,
161-
ComponentType.Create<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
168+
ComponentType.ReadWrite<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
162169
}
163170

164171
for (int i = 0; i < authorityChanges.Count; ++i)
@@ -189,7 +196,7 @@ private void ApplyAuthorityChange(Unity.Entities.Entity entity, Authority author
189196
}
190197

191198
entityManager.RemoveComponent<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
192-
entityManager.AddComponent(entity, ComponentType.Create<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
199+
entityManager.AddComponent(entity, ComponentType.ReadWrite<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
193200

194201
break;
195202
case Authority.AuthorityLossImminent:
@@ -199,7 +206,7 @@ private void ApplyAuthorityChange(Unity.Entities.Entity entity, Authority author
199206
return;
200207
}
201208

202-
entityManager.AddComponent(entity, ComponentType.Create<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
209+
entityManager.AddComponent(entity, ComponentType.ReadWrite<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
203210
break;
204211
case Authority.NotAuthoritative:
205212
if (!entityManager.HasComponent<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
@@ -214,7 +221,7 @@ private void ApplyAuthorityChange(Unity.Entities.Entity entity, Authority author
214221
}
215222

216223
entityManager.RemoveComponent<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
217-
entityManager.AddComponent(entity, ComponentType.Create<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
224+
entityManager.AddComponent(entity, ComponentType.ReadWrite<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
218225
break;
219226
}
220227
}

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyReactiveHandlers.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,9 @@ internal class ReactiveComponentReplicator : IReactiveComponentReplicationHandle
2222
{
2323
public uint ComponentId => 197719;
2424

25-
public EntityArchetypeQuery EventQuery => new EntityArchetypeQuery
26-
{
27-
All = new[]
28-
{
29-
ComponentType.ReadOnly<SpatialEntityId>()
30-
},
31-
Any = Array.Empty<ComponentType>(),
32-
None = Array.Empty<ComponentType>(),
33-
};
25+
public EntityQueryDesc EventQuery => null;
3426

35-
public EntityArchetypeQuery[] CommandQueries => new EntityArchetypeQuery[]
36-
{
37-
};
27+
public EntityQueryDesc[] CommandQueries => null;
3828

3929
public void SendEvents(NativeArray<ArchetypeChunk> chunkArray, ComponentSystemBase system, ComponentUpdateSystem componentUpdateSystem)
4030
{
@@ -47,17 +37,15 @@ public void SendCommands(NativeArray<ArchetypeChunk> chunkArray, ComponentSystem
4737

4838
internal class ComponentCleanup : ComponentCleanupHandler
4939
{
50-
public override EntityArchetypeQuery CleanupArchetypeQuery => new EntityArchetypeQuery
40+
public override EntityQueryDesc CleanupArchetypeQuery => new EntityQueryDesc
5141
{
52-
All = Array.Empty<ComponentType>(),
5342
Any = new ComponentType[]
5443
{
55-
ComponentType.Create<ComponentAdded<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
56-
ComponentType.Create<ComponentRemoved<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
57-
ComponentType.Create<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(),
58-
ComponentType.Create<AuthorityChanges<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
44+
ComponentType.ReadWrite<ComponentAdded<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
45+
ComponentType.ReadWrite<ComponentRemoved<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
46+
ComponentType.ReadWrite<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(),
47+
ComponentType.ReadWrite<AuthorityChanges<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
5948
},
60-
None = Array.Empty<ComponentType>(),
6149
};
6250

6351
public override void CleanComponents(NativeArray<ArchetypeChunk> chunkArray, ComponentSystemBase system,
@@ -125,15 +113,13 @@ public override void CleanComponents(NativeArray<ArchetypeChunk> chunkArray, Com
125113

126114
internal class AcknowledgeAuthorityLossHandler : AbstractAcknowledgeAuthorityLossHandler
127115
{
128-
public override EntityArchetypeQuery Query => new EntityArchetypeQuery
116+
public override EntityQueryDesc Query => new EntityQueryDesc
129117
{
130118
All = new ComponentType[]
131119
{
132120
ComponentType.ReadOnly<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(),
133121
ComponentType.ReadOnly<SpatialEntityId>()
134122
},
135-
Any = Array.Empty<ComponentType>(),
136-
None = Array.Empty<ComponentType>()
137123
};
138124

139125
public override void AcknowledgeAuthorityLoss(NativeArray<ArchetypeChunk> chunkArray, ComponentSystemBase system,

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyUpdateSender.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ internal class ComponentReplicator : IComponentReplicationHandler
2020
{
2121
public uint ComponentId => 197719;
2222

23-
public EntityArchetypeQuery ComponentUpdateQuery => new EntityArchetypeQuery
23+
public EntityQueryDesc ComponentUpdateQuery => new EntityQueryDesc
2424
{
2525
All = new[]
2626
{
27-
ComponentType.Create<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(),
28-
ComponentType.Create<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ComponentAuthority>(),
27+
ComponentType.ReadWrite<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(),
28+
ComponentType.ReadWrite<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ComponentAuthority>(),
2929
ComponentType.ReadOnly<SpatialEntityId>()
3030
},
31-
Any = Array.Empty<ComponentType>(),
32-
None = Array.Empty<ComponentType>(),
3331
};
3432

3533
public void SendUpdates(

0 commit comments

Comments
 (0)