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

Basic port to QBI #89

Merged
merged 8 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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).
paulbalaji marked this conversation as resolved.
Show resolved Hide resolved

## `0.3.3` - 2020-02-14

### Changed
Expand Down
8 changes: 7 additions & 1 deletion cloud_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 5000,
"zMeters": 5000
}
},
"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 default_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"dimensions": {
"xMeters": 5000,
"zMeters": 5000
}
},
"legacy_flags": [
{
"name": "interest_queries_components_are_filtered_by_component_delivery",
"value": "false"
}
]
},
"load_balancing": {
"layer_configurations": [
Expand Down
4 changes: 2 additions & 2 deletions spatialos.json
Original file line number Diff line number Diff line change
@@ -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"}
]
}
4 changes: 2 additions & 2 deletions workers/unity/Assets/BlankProject.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"Improbable.Gdk.PlayerLifecycle",
"Unity.Entities",
"Unity.Entities.Hybrid",
"Unity.Mathematics"
"Unity.Mathematics",
"Improbable.Gdk.QueryBasedInterestHelper"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Improbable;
using Improbable.Gdk.Core;
using Improbable.Gdk.PlayerLifecycle;
using Improbable.Gdk.QueryBasedInterest;

namespace BlankProject.Scripts.Config
{
Expand All @@ -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<Metadata.Component>(serverQuery)
.AddQueries<Position.Component>(clientQuery);
template.AddComponent(interest.ToSnapshot(), serverAttribute);

template.SetReadAccess(UnityClientConnector.WorkerType, MobileClientWorkerConnector.WorkerType, serverAttribute);
template.SetComponentWriteAccess(EntityAcl.ComponentId, serverAttribute);

Expand Down
13 changes: 9 additions & 4 deletions workers/unity/Assets/Editor/BlankProject.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
"Improbable.Gdk.BuildSystem",
"Improbable.Gdk.Core",
"Improbable.Gdk.Generated",
"Unity.Entities"
"Unity.Entities",
"Improbable.Gdk.QueryBasedInterestHelper"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
paulbalaji marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Position.Component>(query);
template.AddComponent(interest.ToSnapshot(), serverAttribute);

template.SetReadAccess(
UnityClientConnector.WorkerType,
UnityGameLogicConnector.WorkerType,
Expand Down
1 change: 1 addition & 0 deletions workers/unity/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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": 100
}
},
"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": 500
}
},
"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": 500
}
},
"component_delivery": {
"default": "RELIABLE_ORDERED",
"checkoutAllInitially": true
"checkoutAllInitially": false
}
},
"external": {
Expand Down