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

Commit 5a7262f

Browse files
author
Paul Balaji
authored
Basic port to QBI (#253)
1 parent 979cf09 commit 5a7262f

13 files changed

+61
-30
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 FPS starter 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). [#253](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/253)
8+
59
## `0.3.3` - 2020-02-14
610

711
### Breaking Changes

cloud_launch_large.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"dimensions": {
99
"xMeters": 1800,
1010
"zMeters": 1800
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": [

cloud_launch_large_sim_players.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"dimensions": {
99
"xMeters": 1800,
1010
"zMeters": 1800
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" : [

cloud_launch_small.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"dimensions": {
99
"xMeters": 300,
1010
"zMeters": 300
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": [

cloud_launch_small_sim_players.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"dimensions": {
99
"xMeters": 300,
1010
"zMeters": 300
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": [

default_launch.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"dimensions": {
99
"xMeters": 300,
1010
"zMeters": 300
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": [
@@ -92,7 +98,7 @@
9298
"name": "world_size",
9399
"value": "4"
94100
}
95-
],
101+
],
96102
"permissions": [{
97103
"all": {}
98104
}]

snapshots/cloud.snapshot

24 Bytes
Binary file not shown.

snapshots/default.snapshot

24 Bytes
Binary file not shown.

workers/unity/Assets/Fps/Scripts/Config/FpsEntityTemplates.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Improbable;
66
using Improbable.Gdk.Core;
77
using Improbable.Gdk.PlayerLifecycle;
8+
using Improbable.Gdk.QueryBasedInterest;
89

910
namespace Fps.Config
1011
{
@@ -21,6 +22,11 @@ public static EntityTemplate Spawner(Coordinates spawnerCoordinates)
2122
template.AddComponent(new Persistence.Snapshot(), WorkerUtils.UnityGameLogic);
2223
template.AddComponent(new PlayerCreator.Snapshot(), WorkerUtils.UnityGameLogic);
2324

25+
var query = InterestQuery.Query(Constraint.RelativeCylinder(150));
26+
var interest = InterestTemplate.Create()
27+
.AddQueries<Position.Component>(query);
28+
template.AddComponent(interest.ToSnapshot(), WorkerUtils.UnityGameLogic);
29+
2430
template.SetReadAccess(WorkerUtils.UnityGameLogic);
2531
template.SetComponentWriteAccess(EntityAcl.ComponentId, WorkerUtils.UnityGameLogic);
2632

@@ -81,6 +87,17 @@ public static EntityTemplate Player(string workerId, byte[] args)
8187

8288
PlayerLifecycleHelper.AddPlayerLifecycleComponents(template, workerId, WorkerUtils.UnityGameLogic);
8389

90+
const int serverRadius = 150;
91+
var clientRadius = workerId.Contains(WorkerUtils.MobileClient) ? 60 : 150;
92+
93+
var serverQuery = InterestQuery.Query(Constraint.RelativeCylinder(serverRadius));
94+
var clientQuery = InterestQuery.Query(Constraint.RelativeCylinder(clientRadius));
95+
96+
var interest = InterestTemplate.Create()
97+
.AddQueries<Position.Component>(serverQuery)
98+
.AddQueries<ClientMovement.Component>(clientQuery);
99+
template.AddComponent(interest.ToSnapshot(), WorkerUtils.UnityGameLogic);
100+
84101
template.SetReadAccess(WorkerUtils.UnityClient, WorkerUtils.UnityGameLogic, WorkerUtils.MobileClient);
85102
template.SetComponentWriteAccess(EntityAcl.ComponentId, WorkerUtils.UnityGameLogic);
86103

workers/unity/spatialos.MobileClient.worker.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@
2121
"MobileClient"
2222
]
2323
},
24-
"entity_interest": {
25-
"range_entity_interest": {
26-
"radius": 60
27-
}
28-
},
2924
"component_delivery": {
3025
"default": "RELIABLE_ORDERED",
31-
"checkoutAllInitially": true
26+
"checkoutAllInitially": false
3227
}
3328
},
3429
"external": {

0 commit comments

Comments
 (0)