Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 13c5f96

Browse files
author
Paul Balaji
authored
Basic port to QBI (#89)
1 parent 09db0f0 commit 13c5f96

13 files changed

+58
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Breaking Changes
6+
7+
- 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)
8+
59
## `0.3.3` - 2020-02-14
610

711
### Changed

cloud_launch.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88
"dimensions": {
99
"xMeters": 5000,
1010
"zMeters": 5000
11-
}
11+
},
12+
"legacy_flags": [
13+
{
14+
"name": "interest_queries_components_are_filtered_by_component_delivery",
15+
"value": "false"
16+
}
17+
]
1218
},
1319
"load_balancing": {
1420
"layer_configurations": [
1521
{
1622
"layer": "UnityGameLogic",
17-
"hex_grid": {
18-
"num_workers": 2
23+
"rectangle_grid": {
24+
"cols": 2,
25+
"rows": 1
1926
}
2027
}
2128
]

default_launch.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
"dimensions": {
99
"xMeters": 5000,
1010
"zMeters": 5000
11-
}
11+
},
12+
"legacy_flags": [
13+
{
14+
"name": "interest_queries_components_are_filtered_by_component_delivery",
15+
"value": "false"
16+
}
17+
]
1218
},
1319
"load_balancing": {
1420
"layer_configurations": [
1521
{
1622
"layer": "UnityGameLogic",
17-
"points_of_interest": {
18-
"num_workers": 1,
19-
"points": [
20-
{
21-
"x": 0,
22-
"z": 0
23-
}
24-
]
23+
"rectangle_grid": {
24+
"cols": 1,
25+
"rows": 1
2526
},
2627
"options": {
2728
"manual_worker_connection_only": true

snapshots/default.snapshot

24 Bytes
Binary file not shown.

spatialos.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "unity_gdk",
33
"project_version": "0.0.1",
4-
"sdk_version": "14.0.1",
4+
"sdk_version": "14.4.1",
55
"dependencies": [
6-
{"name": "standard_library", "version": "14.0.1"}
6+
{"name": "standard_library", "version": "14.4.1"}
77
]
88
}

workers/unity/Assets/BlankProject.asmdef

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"Improbable.Gdk.Generated",
66
"Improbable.Gdk.Mobile",
77
"Improbable.Gdk.PlayerLifecycle",
8+
"Improbable.Gdk.QueryBasedInterestHelper",
89
"Unity.Entities",
910
"Unity.Entities.Hybrid",
1011
"Unity.Mathematics"
1112
],
12-
"optionalUnityReferences": [],
1313
"includePlatforms": [],
1414
"excludePlatforms": [],
1515
"allowUnsafeCode": false,
@@ -18,4 +18,4 @@
1818
"autoReferenced": true,
1919
"defineConstraints": [],
2020
"versionDefines": []
21-
}
21+
}

workers/unity/Assets/BlankProject/Scripts/Config/EntityTemplates.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Improbable;
22
using Improbable.Gdk.Core;
33
using Improbable.Gdk.PlayerLifecycle;
4+
using Improbable.Gdk.QueryBasedInterest;
45

56
namespace BlankProject.Scripts.Config
67
{
@@ -17,6 +18,17 @@ public static EntityTemplate CreatePlayerEntityTemplate(string workerId, byte[]
1718

1819
PlayerLifecycleHelper.AddPlayerLifecycleComponents(template, workerId, serverAttribute);
1920

21+
const int serverRadius = 500;
22+
var clientRadius = workerId.Contains(MobileClientWorkerConnector.WorkerType) ? 100 : 500;
23+
24+
var serverQuery = InterestQuery.Query(Constraint.RelativeCylinder(serverRadius));
25+
var clientQuery = InterestQuery.Query(Constraint.RelativeCylinder(clientRadius));
26+
27+
var interest = InterestTemplate.Create()
28+
.AddQueries<Metadata.Component>(serverQuery)
29+
.AddQueries<Position.Component>(clientQuery);
30+
template.AddComponent(interest.ToSnapshot(), serverAttribute);
31+
2032
template.SetReadAccess(UnityClientConnector.WorkerType, MobileClientWorkerConnector.WorkerType, serverAttribute);
2133
template.SetComponentWriteAccess(EntityAcl.ComponentId, serverAttribute);
2234

workers/unity/Assets/Editor/BlankProject.Editor.asmdef

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
"Improbable.Gdk.BuildSystem",
66
"Improbable.Gdk.Core",
77
"Improbable.Gdk.Generated",
8+
"Improbable.Gdk.QueryBasedInterestHelper",
89
"Unity.Entities"
910
],
10-
"optionalUnityReferences": [],
1111
"includePlatforms": [
1212
"Editor"
1313
],
1414
"excludePlatforms": [],
15-
"allowUnsafeCode": false
15+
"allowUnsafeCode": false,
16+
"overrideReferences": false,
17+
"precompiledReferences": [],
18+
"autoReferenced": true,
19+
"defineConstraints": [],
20+
"versionDefines": []
1621
}

workers/unity/Assets/Editor/SnapshotGenerator/SnapshotGenerator.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
using Improbable;
33
using Improbable.Gdk.Core;
44
using Improbable.Gdk.PlayerLifecycle;
5+
using Improbable.Gdk.QueryBasedInterest;
56
using UnityEditor;
67
using UnityEngine;
8+
79
using Snapshot = Improbable.Gdk.Core.Snapshot;
810

911
namespace BlankProject.Editor
@@ -47,6 +49,11 @@ private static void AddPlayerSpawner(Snapshot snapshot)
4749
template.AddComponent(new Persistence.Snapshot(), serverAttribute);
4850
template.AddComponent(new PlayerCreator.Snapshot(), serverAttribute);
4951

52+
var query = InterestQuery.Query(Constraint.RelativeCylinder(500));
53+
var interest = InterestTemplate.Create()
54+
.AddQueries<Position.Component>(query);
55+
template.AddComponent(interest.ToSnapshot(), serverAttribute);
56+
5057
template.SetReadAccess(
5158
UnityClientConnector.WorkerType,
5259
UnityGameLogicConnector.WorkerType,

workers/unity/Packages/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"io.improbable.gdk.debug": "0.3.3",
1616
"io.improbable.gdk.deploymentlauncher": "0.3.3",
1717
"io.improbable.gdk.gameobjectcreation": "0.3.3",
18+
"io.improbable.gdk.querybasedinteresthelper": "0.3.3",
1819
"io.improbable.gdk.mobile": "0.3.3",
1920
"io.improbable.gdk.playerlifecycle": "0.3.3",
2021
"io.improbable.gdk.testutils": "0.3.3",

0 commit comments

Comments
 (0)