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

Commit

Permalink
Basic port to QBI (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Balaji authored Mar 6, 2020
1 parent 979cf09 commit 5a7262f
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## Breaking Changes

- 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)

## `0.3.3` - 2020-02-14

### Breaking Changes
Expand Down
8 changes: 7 additions & 1 deletion cloud_launch_large.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 1800,
"zMeters": 1800
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations": [
Expand Down
8 changes: 7 additions & 1 deletion cloud_launch_large_sim_players.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 1800,
"zMeters": 1800
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations" : [
Expand Down
8 changes: 7 additions & 1 deletion cloud_launch_small.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 300,
"zMeters": 300
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations": [
Expand Down
8 changes: 7 additions & 1 deletion cloud_launch_small_sim_players.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 300,
"zMeters": 300
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations": [
Expand Down
10 changes: 8 additions & 2 deletions default_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 300,
"zMeters": 300
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations": [
Expand Down Expand Up @@ -92,7 +98,7 @@
"name": "world_size",
"value": "4"
}
],
],
"permissions": [{
"all": {}
}]
Expand Down
Binary file modified snapshots/cloud.snapshot
Binary file not shown.
Binary file modified snapshots/default.snapshot
Binary file not shown.
17 changes: 17 additions & 0 deletions workers/unity/Assets/Fps/Scripts/Config/FpsEntityTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Improbable;
using Improbable.Gdk.Core;
using Improbable.Gdk.PlayerLifecycle;
using Improbable.Gdk.QueryBasedInterest;

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

var query = InterestQuery.Query(Constraint.RelativeCylinder(150));
var interest = InterestTemplate.Create()
.AddQueries<Position.Component>(query);
template.AddComponent(interest.ToSnapshot(), WorkerUtils.UnityGameLogic);

template.SetReadAccess(WorkerUtils.UnityGameLogic);
template.SetComponentWriteAccess(EntityAcl.ComponentId, WorkerUtils.UnityGameLogic);

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

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

const int serverRadius = 150;
var clientRadius = workerId.Contains(WorkerUtils.MobileClient) ? 60 : 150;

var serverQuery = InterestQuery.Query(Constraint.RelativeCylinder(serverRadius));
var clientQuery = InterestQuery.Query(Constraint.RelativeCylinder(clientRadius));

var interest = InterestTemplate.Create()
.AddQueries<Position.Component>(serverQuery)
.AddQueries<ClientMovement.Component>(clientQuery);
template.AddComponent(interest.ToSnapshot(), WorkerUtils.UnityGameLogic);

template.SetReadAccess(WorkerUtils.UnityClient, WorkerUtils.UnityGameLogic, WorkerUtils.MobileClient);
template.SetComponentWriteAccess(EntityAcl.ComponentId, WorkerUtils.UnityGameLogic);

Expand Down
7 changes: 1 addition & 6 deletions workers/unity/spatialos.MobileClient.worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
"MobileClient"
]
},
"entity_interest": {
"range_entity_interest": {
"radius": 60
}
},
"component_delivery": {
"default": "RELIABLE_ORDERED",
"checkoutAllInitially": true
"checkoutAllInitially": false
}
},
"external": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
"SimulatedPlayerCoordinator"
]
},
"entity_interest": {
"range_entity_interest": {
"radius": 1
}
},
"component_delivery": {
"default": "RELIABLE_ORDERED",
"checkoutAllInitially": true
"checkoutAllInitially": false
}
},
"external": {
Expand Down
7 changes: 1 addition & 6 deletions workers/unity/spatialos.UnityClient.worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
"UnityClient"
]
},
"entity_interest": {
"range_entity_interest": {
"radius": 150
}
},
"component_delivery": {
"default": "RELIABLE_ORDERED",
"checkoutAllInitially": true
"checkoutAllInitially": false
}
},
"external": {
Expand Down
7 changes: 1 addition & 6 deletions workers/unity/spatialos.UnityGameLogic.worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
"UnityGameLogic"
]
},
"entity_interest": {
"range_entity_interest": {
"radius": 150
}
},
"component_delivery": {
"default": "RELIABLE_ORDERED",
"checkoutAllInitially": true
"checkoutAllInitially": false
}
},
"external": {
Expand Down

0 comments on commit 5a7262f

Please sign in to comment.