diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e4c69fe..c46cb4378 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Breaking Changes + +- The blank project now uses [query-based interest](https://docs.improbable.io/reference/14.4/shared/authority-and-interest/interest/query-based-interest-qbi) instead of [chunk-based interest](https://docs.improbable.io/reference/14.4/shared/authority-and-interest/interest/chunk-based-interest-cbi). [#89](https://github.com/spatialos/gdk-for-unity-blank-project/pull/89) + ## `0.3.3` - 2020-02-14 ### Changed diff --git a/cloud_launch.json b/cloud_launch.json index 7428bdd03..8a4edc2d3 100644 --- a/cloud_launch.json +++ b/cloud_launch.json @@ -8,14 +8,21 @@ "dimensions": { "xMeters": 5000, "zMeters": 5000 - } + }, + "legacy_flags": [ + { + "name": "interest_queries_components_are_filtered_by_component_delivery", + "value": "false" + } + ] }, "load_balancing": { "layer_configurations": [ { "layer": "UnityGameLogic", - "hex_grid": { - "num_workers": 2 + "rectangle_grid": { + "cols": 2, + "rows": 1 } } ] diff --git a/default_launch.json b/default_launch.json index f2a6c2e27..cbe6c98b3 100644 --- a/default_launch.json +++ b/default_launch.json @@ -8,20 +8,21 @@ "dimensions": { "xMeters": 5000, "zMeters": 5000 - } + }, + "legacy_flags": [ + { + "name": "interest_queries_components_are_filtered_by_component_delivery", + "value": "false" + } + ] }, "load_balancing": { "layer_configurations": [ { "layer": "UnityGameLogic", - "points_of_interest": { - "num_workers": 1, - "points": [ - { - "x": 0, - "z": 0 - } - ] + "rectangle_grid": { + "cols": 1, + "rows": 1 }, "options": { "manual_worker_connection_only": true diff --git a/snapshots/default.snapshot b/snapshots/default.snapshot index 9e71db40a..ac0972fb2 100644 Binary files a/snapshots/default.snapshot and b/snapshots/default.snapshot differ diff --git a/spatialos.json b/spatialos.json index 6c03eac86..9331a7dce 100644 --- a/spatialos.json +++ b/spatialos.json @@ -1,8 +1,8 @@ { "name": "unity_gdk", "project_version": "0.0.1", - "sdk_version": "14.0.1", + "sdk_version": "14.4.1", "dependencies": [ - {"name": "standard_library", "version": "14.0.1"} + {"name": "standard_library", "version": "14.4.1"} ] } diff --git a/workers/unity/Assets/BlankProject.asmdef b/workers/unity/Assets/BlankProject.asmdef index 8f355fdee..88ac5776b 100644 --- a/workers/unity/Assets/BlankProject.asmdef +++ b/workers/unity/Assets/BlankProject.asmdef @@ -5,11 +5,11 @@ "Improbable.Gdk.Generated", "Improbable.Gdk.Mobile", "Improbable.Gdk.PlayerLifecycle", + "Improbable.Gdk.QueryBasedInterestHelper", "Unity.Entities", "Unity.Entities.Hybrid", "Unity.Mathematics" ], - "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, @@ -18,4 +18,4 @@ "autoReferenced": true, "defineConstraints": [], "versionDefines": [] -} \ No newline at end of file +} diff --git a/workers/unity/Assets/BlankProject/Scripts/Config/EntityTemplates.cs b/workers/unity/Assets/BlankProject/Scripts/Config/EntityTemplates.cs index 13e91881b..b3da01688 100644 --- a/workers/unity/Assets/BlankProject/Scripts/Config/EntityTemplates.cs +++ b/workers/unity/Assets/BlankProject/Scripts/Config/EntityTemplates.cs @@ -1,6 +1,7 @@ using Improbable; using Improbable.Gdk.Core; using Improbable.Gdk.PlayerLifecycle; +using Improbable.Gdk.QueryBasedInterest; namespace BlankProject.Scripts.Config { @@ -17,6 +18,17 @@ public static EntityTemplate CreatePlayerEntityTemplate(string workerId, byte[] PlayerLifecycleHelper.AddPlayerLifecycleComponents(template, workerId, serverAttribute); + const int serverRadius = 500; + var clientRadius = workerId.Contains(MobileClientWorkerConnector.WorkerType) ? 100 : 500; + + var serverQuery = InterestQuery.Query(Constraint.RelativeCylinder(serverRadius)); + var clientQuery = InterestQuery.Query(Constraint.RelativeCylinder(clientRadius)); + + var interest = InterestTemplate.Create() + .AddQueries(serverQuery) + .AddQueries(clientQuery); + template.AddComponent(interest.ToSnapshot(), serverAttribute); + template.SetReadAccess(UnityClientConnector.WorkerType, MobileClientWorkerConnector.WorkerType, serverAttribute); template.SetComponentWriteAccess(EntityAcl.ComponentId, serverAttribute); diff --git a/workers/unity/Assets/Editor/BlankProject.Editor.asmdef b/workers/unity/Assets/Editor/BlankProject.Editor.asmdef index 3bff81b80..9854f9392 100644 --- a/workers/unity/Assets/Editor/BlankProject.Editor.asmdef +++ b/workers/unity/Assets/Editor/BlankProject.Editor.asmdef @@ -5,12 +5,17 @@ "Improbable.Gdk.BuildSystem", "Improbable.Gdk.Core", "Improbable.Gdk.Generated", + "Improbable.Gdk.QueryBasedInterestHelper", "Unity.Entities" ], - "optionalUnityReferences": [], "includePlatforms": [ "Editor" ], "excludePlatforms": [], - "allowUnsafeCode": false + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [] } diff --git a/workers/unity/Assets/Editor/SnapshotGenerator/SnapshotGenerator.cs b/workers/unity/Assets/Editor/SnapshotGenerator/SnapshotGenerator.cs index 95cab6537..7dd2156dc 100644 --- a/workers/unity/Assets/Editor/SnapshotGenerator/SnapshotGenerator.cs +++ b/workers/unity/Assets/Editor/SnapshotGenerator/SnapshotGenerator.cs @@ -2,8 +2,10 @@ using Improbable; using Improbable.Gdk.Core; using Improbable.Gdk.PlayerLifecycle; +using Improbable.Gdk.QueryBasedInterest; using UnityEditor; using UnityEngine; + using Snapshot = Improbable.Gdk.Core.Snapshot; namespace BlankProject.Editor @@ -47,6 +49,11 @@ private static void AddPlayerSpawner(Snapshot snapshot) template.AddComponent(new Persistence.Snapshot(), serverAttribute); template.AddComponent(new PlayerCreator.Snapshot(), serverAttribute); + var query = InterestQuery.Query(Constraint.RelativeCylinder(500)); + var interest = InterestTemplate.Create() + .AddQueries(query); + template.AddComponent(interest.ToSnapshot(), serverAttribute); + template.SetReadAccess( UnityClientConnector.WorkerType, UnityGameLogicConnector.WorkerType, diff --git a/workers/unity/Packages/manifest.json b/workers/unity/Packages/manifest.json index 01992a179..695dd4a21 100644 --- a/workers/unity/Packages/manifest.json +++ b/workers/unity/Packages/manifest.json @@ -15,6 +15,7 @@ "io.improbable.gdk.debug": "0.3.3", "io.improbable.gdk.deploymentlauncher": "0.3.3", "io.improbable.gdk.gameobjectcreation": "0.3.3", + "io.improbable.gdk.querybasedinteresthelper": "0.3.3", "io.improbable.gdk.mobile": "0.3.3", "io.improbable.gdk.playerlifecycle": "0.3.3", "io.improbable.gdk.testutils": "0.3.3", diff --git a/workers/unity/spatialos.MobileClient.worker.json b/workers/unity/spatialos.MobileClient.worker.json index 62b90ad93..4722dd2c2 100644 --- a/workers/unity/spatialos.MobileClient.worker.json +++ b/workers/unity/spatialos.MobileClient.worker.json @@ -21,14 +21,9 @@ "MobileClient" ] }, - "entity_interest": { - "range_entity_interest": { - "radius": 100 - } - }, "component_delivery": { "default": "RELIABLE_ORDERED", - "checkoutAllInitially": true + "checkoutAllInitially": false } }, "external": { diff --git a/workers/unity/spatialos.UnityClient.worker.json b/workers/unity/spatialos.UnityClient.worker.json index 5120e5bd6..9d3427e59 100644 --- a/workers/unity/spatialos.UnityClient.worker.json +++ b/workers/unity/spatialos.UnityClient.worker.json @@ -21,14 +21,9 @@ "UnityClient" ] }, - "entity_interest": { - "range_entity_interest": { - "radius": 500 - } - }, "component_delivery": { "default": "RELIABLE_ORDERED", - "checkoutAllInitially": true + "checkoutAllInitially": false } }, "external": { diff --git a/workers/unity/spatialos.UnityGameLogic.worker.json b/workers/unity/spatialos.UnityGameLogic.worker.json index 362abbc8e..b1e045c5d 100644 --- a/workers/unity/spatialos.UnityGameLogic.worker.json +++ b/workers/unity/spatialos.UnityGameLogic.worker.json @@ -21,14 +21,9 @@ "UnityGameLogic" ] }, - "entity_interest": { - "range_entity_interest": { - "radius": 500 - } - }, "component_delivery": { "default": "RELIABLE_ORDERED", - "checkoutAllInitially": true + "checkoutAllInitially": false } }, "external": {