Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
Worker SDK 14.0.0 upgrade (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Brynes authored Aug 16, 2019
1 parent 2545d14 commit 618c28c
Show file tree
Hide file tree
Showing 83 changed files with 309 additions and 635 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
### Breaking Changes

- Renamed the public field `AnonymousAuthenticationPort` to `LocatorPort` on the `AlphaLocatorFlow` class and the `RuntimeConfigDefaults` static class. [#1105](https://github.com/spatialos/gdk-for-unity/pull/1105)
- Upgraded to Worker SDK `14.0.1`. This brings a number of breaking changes. [#1112](https://github.com/spatialos/gdk-for-unity/pull/1112)
- `Vector3f` and `Vector3d` are no longer available in the schema standard library.
- The `Improbable.Coordinates.ToSpatialVector3d()` method has been removed.
- `LocatorFlow` and `AlphaLocatorFlow` have been merged.
- The implementation of the old `LocatorFlow` has been removed.
- The `ConnectionService.AlphaLocator` enum value has been removed.
- The `ProjectName`, `SteamDeploymentTag`, and `SteamTicket` constants have been removed from the `RuntimeConfigNames` static class.

### Added

- Added the ability to connect to an arbitrary host/port combo for the `AlphaLocatorFlow`. [#1105](https://github.com/spatialos/gdk-for-unity/pull/1105)
- Added a `SpatialdManager` class for managing local deployments with `SpatialD` into `io.improbable.gdk.testutils`. [#1104](https://github.com/spatialos/gdk-for-unity/pull/1104)
- Added the ability to specify a snapshot to be used when launching a deployment in the Editor. [#1098](https://github.com/spatialos/gdk-for-unity/pull/1098)
- Added the ability to select the modular UDP network type as part of the Worker SDK 14.0.1 upgrade. [#1112](https://github.com/spatialos/gdk-for-unity/pull/1112)

### Changed

Expand All @@ -32,6 +40,7 @@
- Added `spot` downloading to `init.sh` & `init.ps` into the `io.improbable.worker.sdk` package. [#1104](https://github.com/spatialos/gdk-for-unity/pull/1104)
- Added tests for the `AlphaLocatorFlow` class. [#1108](https://github.com/spatialos/gdk-for-unity/pull/1108)
- `Option<T>` is now explicitly immutable as a `readonly struct`. [#1110](https://github.com/spatialos/gdk-for-unity/pull/1110)
- Removed unused arguments from worker configuration files. [#1112](https://github.com/spatialos/gdk-for-unity/pull/1112)

## `0.2.6` - 2019-08-05

Expand Down
75 changes: 75 additions & 0 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
# Upgrade Guide

## From `0.2.6` to `0.2.7`

### Worker SDK `14.0.1` upgrade

The Worker SDK upgrade introduces breaking changes to the connection flow, and removes the `Vector3f` and `Vector3d` types from the standard schema library.

#### Removal of `Vector3f` and `Vector3d`

These two schema types are no longer available in the standard schema library. You can replace their definitions by first defining a schema file in your project:

```
package my_game;
type Vector3f {
float x = 1;
float y = 2;
float z = 3;
}
type Vector3d {
double x = 1;
double y = 2;
double z = 3;
}
```

You should then replace the import of `improbable/vector.schema` and usage of `improbable.Vector3f`/`improbable.Vector3d` with the schema file you defined.

> Note that methods such as `Vector3f.ToUnityVector();` are no longer available and you'll need to reimplement them yourself as extension/static methods. You can find the old implementations here: [`Vector3f`](https://github.com/spatialos/gdk-for-unity/blob/0.2.6/workers/unity/Packages/io.improbable.gdk.tools/.CodeGenerator/GdkCodeGenerator/Partials/Improbable.Vector3f) and [`Vector3d`](https://github.com/spatialos/gdk-for-unity/blob/0.2.6/workers/unity/Packages/io.improbable.gdk.tools/.CodeGenerator/GdkCodeGenerator/Partials/Improbable.Vector3d).
>
> You will be unable to reimplement the operators since C# lacks the ability to define operations via extension methods.
>
> Note that the `Coordinates` type can be used as a replacement for `Vector3d` as they are structurally the same.
#### Connection flow changes

The `AlphaLocatorFlow` and the `LocatorFlow` have been merged. This means that your worker connectors may require some changes. Wherever you were previously using the `AlphaLocatorFlow` or the `ConnectionService.AlphaLocator` enum value, you should now be using the `LocatorFlow` and the `ConnectionService.Locator` enum value.

For example:

```csharp
var initializer = new CommandLineConnectionFlowInitializer();
switch (initializer.GetConnectionService())
{
case ConnectionService.Receptionist:
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient), initializer));
break;
case ConnectionService.Locator:
builder.SetConnectionFlow(new LocatorFlow(initializer));
break;
case ConnectionService.AlphaLocator:
builder.SetConnectionFlow(new AlphaLocatorFlow(initializer));
break;
default:
throw new ArgumentOutOfRangeException();
}
```

Would change into:

```csharp
var initializer = new CommandLineConnectionFlowInitializer();
switch (initializer.GetConnectionService())
{
case ConnectionService.Receptionist:
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient), initializer));
break;
case ConnectionService.Locator:
builder.SetConnectionFlow(new LocatorFlow(initializer));
break;
default:
throw new ArgumentOutOfRangeException();
}
```

## From `0.2.5` to `0.2.6`

### General changes
Expand Down
25 changes: 14 additions & 11 deletions init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ cd $PSScriptRoot
$PkgRoot = $PSScriptRoot + "/workers/unity/Packages"
$SdkPath = $PkgRoot + "/io.improbable.worker.sdk"
$SdkMobilePath = $PkgRoot + "/io.improbable.worker.sdk.mobile"
$TestSdkPath="test-project/Packages/io.improbable.worker.sdk.testschema"

$SdkVersion = Get-Content ($SdkPath + "/package.json") | jq -r '.version'
$SdkVersion = "14.0.1-b1352-614f42b-WORKER-SNAPSHOT"
# $SdkVersion = Get-Content ($SdkPath + "/package.json") | jq -r '.version'
$SpotVersion = Get-Content ($SdkPath + "/.spot.version")

function UpdatePackage($type, $identifier, $path, $removes)
Expand All @@ -24,13 +26,14 @@ function UpdateSpot($identifier, $path)
spatial package get spot $identifier $SpotVersion "$path" --force --json_output
}

UpdatePackage worker_sdk core-dynamic-x86_64-linux "$SdkPath/Plugins/Improbable/Core/Linux/x86_64"
UpdatePackage worker_sdk core-bundle-x86_64-macos "$SdkPath/Plugins/Improbable/Core/OSX"
UpdatePackage worker_sdk core-dynamic-x86_64-win32 "$SdkPath/Plugins/Improbable/Core/Windows/x86_64" "CoreSdkDll.lib"
UpdatePackage worker_sdk c-dynamic-x86_64-gcc510-linux "$SdkPath/Plugins/Improbable/Core/Linux/x86_64"
UpdatePackage worker_sdk c-bundle-x86_64-clang-macos "$SdkPath/Plugins/Improbable/Core/OSX"
UpdatePackage worker_sdk c-dynamic-x86_64-vc140_mt-win32 "$SdkPath/Plugins/Improbable/Core/Windows/x86_64" "improbable_worker.lib"

UpdatePackage worker_sdk csharp-c-interop "$SdkPath/Plugins/Improbable/Sdk/Common" "Improbable.Worker.CInterop.pdb"
UpdatePackage worker_sdk csharp_cinterop "$SdkPath/Plugins/Improbable/Sdk/Common" "Improbable.Worker.CInterop.pdb"

UpdatePackage schema standard_library "$SdkPath/.schema"
UpdatePackage schema test_schema_library "$TestSdkPath/.schema" "test_schema/recursion.schema"

UpdatePackage tools schema_compiler-x86_64-win32 "$SdkPath/.schema_compiler"
UpdatePackage tools schema_compiler-x86_64-macos "$SdkPath/.schema_compiler"
Expand All @@ -39,11 +42,11 @@ UpdateSpot spot-win64 "$SdkPath/.spot/spot.exe"
UpdateSpot spot-macos "$SdkPath/.spot/spot"

#Update Mobile SDK
UpdatePackage worker_sdk core-static-fullylinked-arm-ios "$SdkMobilePath/Plugins/Improbable/Core/iOS/arm" "CoreSdkStatic.lib;libCoreSdkStatic.a.pic"
UpdatePackage worker_sdk core-static-fullylinked-x86_64-ios "$SdkMobilePath/Plugins/Improbable/Core/iOS/x86_64" "CoreSdkStatic.lib;libCoreSdkStatic.a.pic"
UpdatePackage worker_sdk c-static-fullylinked-arm-clang-ios "$SdkMobilePath/Plugins/Improbable/Core/iOS/arm" "improbable_worker_static.lib;libimprobable_worker_static.a.pic"
UpdatePackage worker_sdk c-static-fullylinked-x86_64-clang-ios "$SdkMobilePath/Plugins/Improbable/Core/iOS/x86_64" "improbable_worker_static.lib;libimprobable_worker_static.a.pic"

UpdatePackage worker_sdk core-dynamic-arm64v8a-android "$SdkMobilePath/Plugins/Improbable/Core/Android/arm64"
UpdatePackage worker_sdk core-dynamic-armv7a-android "$SdkMobilePath/Plugins/Improbable/Core/Android/armv7"
UpdatePackage worker_sdk core-dynamic-x86-android "$SdkMobilePath/Plugins/Improbable/Core/Android/x86"
UpdatePackage worker_sdk c-dynamic-arm64v8a-clang_ndk16b-android "$SdkMobilePath/Plugins/Improbable/Core/Android/arm64"
UpdatePackage worker_sdk c-dynamic-armv7a-clang_ndk16b-android "$SdkMobilePath/Plugins/Improbable/Core/Android/armv7"
UpdatePackage worker_sdk c-dynamic-x86-clang_ndk16b-android "$SdkMobilePath/Plugins/Improbable/Core/Android/x86"

UpdatePackage worker_sdk csharp-c-interop-static "$SdkMobilePath/Plugins/Improbable/Sdk/iOS" "Improbable.Worker.CInteropStatic.pdb"
UpdatePackage worker_sdk csharp_cinterop_static "$SdkMobilePath/Plugins/Improbable/Sdk/iOS" "Improbable.Worker.CInteropStatic.pdb"
23 changes: 12 additions & 11 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ SDK_PATH="${PKG_ROOT}/io.improbable.worker.sdk"
SDK_MOBILE_PATH="${PKG_ROOT}/io.improbable.worker.sdk.mobile"
TEST_SDK_PATH="test-project/Packages/io.improbable.worker.sdk.testschema"

SDK_VERSION="$(cat "${SDK_PATH}"/package.json | jq -r '.version')"
SDK_VERSION="14.0.1-b1352-614f42b-WORKER-SNAPSHOT"
# SDK_VERSION="$(cat "${SDK_PATH}"/package.json | jq -r '.version')"
SPOT_VERSION="$(cat "${SDK_PATH}"/.spot.version)"

update_package() {
Expand All @@ -32,11 +33,11 @@ update_spot() {
}

# Update Core SDK
update_package worker_sdk core-dynamic-x86_64-linux "${SDK_PATH}/Plugins/Improbable/Core/Linux/x86_64"
update_package worker_sdk core-bundle-x86_64-macos "${SDK_PATH}/Plugins/Improbable/Core/OSX"
update_package worker_sdk core-dynamic-x86_64-win32 "${SDK_PATH}/Plugins/Improbable/Core/Windows/x86_64" "CoreSdkDll.lib"
update_package worker_sdk c-dynamic-x86_64-gcc510-linux "${SDK_PATH}/Plugins/Improbable/Core/Linux/x86_64"
update_package worker_sdk c-bundle-x86_64-clang-macos "${SDK_PATH}/Plugins/Improbable/Core/OSX"
update_package worker_sdk c-dynamic-x86_64-vc140_mt-win32 "${SDK_PATH}/Plugins/Improbable/Core/Windows/x86_64" "improbable_worker.lib"

update_package worker_sdk csharp-c-interop "${SDK_PATH}/Plugins/Improbable/Sdk/Common" "Improbable.Worker.CInterop.pdb"
update_package worker_sdk csharp_cinterop "${SDK_PATH}/Plugins/Improbable/Sdk/Common" "Improbable.Worker.CInterop.pdb"

update_package schema standard_library "${SDK_PATH}/.schema"
update_package schema test_schema_library "${TEST_SDK_PATH}/.schema" "test_schema/recursion.schema"
Expand All @@ -48,11 +49,11 @@ update_spot spot-win64 "${SDK_PATH}/.spot/spot.exe"
update_spot spot-macos "${SDK_PATH}/.spot/spot"

#Update Mobile SDK
update_package worker_sdk core-static-fullylinked-arm-ios "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/iOS/arm" "CoreSdkStatic.lib;libCoreSdkStatic.a.pic"
update_package worker_sdk core-static-fullylinked-x86_64-ios "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/iOS/x86_64" "CoreSdkStatic.lib;libCoreSdkStatic.a.pic"
update_package worker_sdk c-static-fullylinked-arm-clang-ios "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/iOS/arm" "improbable_worker_static.lib;libimprobable_worker_static.a.pic"
update_package worker_sdk c-static-fullylinked-x86_64-clang-ios "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/iOS/x86_64" "improbable_worker_static.lib;libimprobable_worker_static.a.pic"

update_package worker_sdk core-dynamic-arm64v8a-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/arm64"
update_package worker_sdk core-dynamic-armv7a-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/armv7"
update_package worker_sdk core-dynamic-x86-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/x86"
update_package worker_sdk c-dynamic-arm64v8a-clang_ndk16b-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/arm64"
update_package worker_sdk c-dynamic-armv7a-clang_ndk16b-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/armv7"
update_package worker_sdk c-dynamic-x86-clang_ndk16b-android "${SDK_MOBILE_PATH}/Plugins/Improbable/Core/Android/x86"

update_package worker_sdk csharp-c-interop-static "${SDK_MOBILE_PATH}/Plugins/Improbable/Sdk/iOS" "Improbable.Worker.CInteropStatic.pdb"
update_package worker_sdk csharp_cinterop_static "${SDK_MOBILE_PATH}/Plugins/Improbable/Sdk/iOS" "Improbable.Worker.CInteropStatic.pdb"
4 changes: 2 additions & 2 deletions schema/playground/cube.schema
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package playground;
import "improbable/vector3.schema";
import "playground/shared.schema";

component CubeTargetVelocity {
id = 12008;
improbable.Vector3f target_velocity = 1;
playground.Vector3f target_velocity = 1;
}
11 changes: 6 additions & 5 deletions schema/playground/launcher.schema
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package playground;
import "improbable/vector3.schema";

import "playground/shared.schema";

// Launcher represents an entity that can launch Launchables.
// The act of launching costs the launcher energy.
Expand All @@ -8,8 +9,8 @@ import "improbable/vector3.schema";
// Command sent by clients to request launching a Launchable.
type LaunchCommandRequest {
EntityId entity_to_launch = 1;
improbable.Vector3f impact_point = 2;
improbable.Vector3f launch_direction = 3;
playground.Vector3f impact_point = 2;
playground.Vector3f launch_direction = 3;
float launch_energy = 4;
EntityId player = 5;
}
Expand All @@ -18,8 +19,8 @@ type LaunchCommandResponse {}

// Command sent by gamelogic to get a Launchable to launch itself.
type LaunchMeCommandRequest {
improbable.Vector3f impact_point = 1;
improbable.Vector3f launch_direction = 2;
playground.Vector3f impact_point = 1;
playground.Vector3f launch_direction = 2;
float launch_energy = 3;
EntityId player = 4;
}
Expand Down
7 changes: 7 additions & 0 deletions schema/playground/shared.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package playground;

type Vector3f {
float x = 1;
float y = 2;
float z = 3;
}
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": "13.8.2",
"sdk_version": "14.0.1",
"dependencies": [
{"name": "standard_library", "version": "13.8.2"}
{"name": "standard_library", "version": "14.0.1"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Can_create_from_entity_template()
[Test]
public void Can_create_from_schema_object()
{
var data = new ComponentData(new SchemaComponentData(0)); // Easiest way to get a valid `SchemaObject`.
var data = new ComponentData(0, SchemaComponentData.Create()); // Easiest way to get a valid `SchemaObject`.
try
{
var schemaObject = data.SchemaData.Value.GetFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void MarkDataClean()

public Snapshot ToComponentSnapshot(global::Unity.Entities.World world)
{
var componentDataSchema = new ComponentData(new SchemaComponentData(198800));
var componentDataSchema = new ComponentData(198800, SchemaComponentData.Create());
Serialization.SerializeComponent(this, componentDataSchema.SchemaData.Value.GetFields(), world);
var snapshot = Serialization.DeserializeSnapshot(componentDataSchema.SchemaData.Value.GetFields());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void Serialize(MessagesToSend messages, SerializedMessagesToSend serializ
for (int i = 0; i < updates.Count; ++i)
{
ref readonly var update = ref updates[i];
var schemaUpdate = new SchemaComponentUpdate(ComponentId);
var componentUpdate = new ComponentUpdate(schemaUpdate);
var schemaUpdate = SchemaComponentUpdate.Create();
var componentUpdate = new ComponentUpdate(ComponentId, schemaUpdate);
Serialization.SerializeUpdate(update.Update, schemaUpdate);
serializedMessages.AddComponentUpdate(componentUpdate, update.EntityId.Id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void MarkDataClean()

public Snapshot ToComponentSnapshot(global::Unity.Entities.World world)
{
var componentDataSchema = new ComponentData(new SchemaComponentData(198801));
var componentDataSchema = new ComponentData(198801, SchemaComponentData.Create());
Serialization.SerializeComponent(this, componentDataSchema.SchemaData.Value.GetFields(), world);
var snapshot = Serialization.DeserializeSnapshot(componentDataSchema.SchemaData.Value.GetFields());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public void Serialize(MessagesToSend messages, SerializedMessagesToSend serializ
var context = new CommandContext<global::Improbable.TestSchema.SomeType>(request.SendingEntity, request.Request.Payload, request.Request.Context, request.RequestId);
commandMetaData.AddRequest<global::Improbable.TestSchema.SomeType>(ComponentId, 1, in context);

var schemaCommandRequest = new global::Improbable.Worker.CInterop.SchemaCommandRequest(ComponentId, 1);
var schemaCommandRequest = global::Improbable.Worker.CInterop.SchemaCommandRequest.Create();
global::Improbable.TestSchema.SomeType.Serialization.Serialize(request.Request.Payload, schemaCommandRequest.GetObject());
var serializedRequest = new global::Improbable.Worker.CInterop.CommandRequest(schemaCommandRequest);
var serializedRequest = new global::Improbable.Worker.CInterop.CommandRequest(ComponentId, 1, schemaCommandRequest);

serializedMessages.AddRequest(serializedRequest, 1,
request.Request.TargetEntityId.Id, request.Request.TimeoutMillis, request.RequestId);
Expand All @@ -104,10 +104,10 @@ public void Serialize(MessagesToSend messages, SerializedMessagesToSend serializ
continue;
}

var schemaCommandResponse = new global::Improbable.Worker.CInterop.SchemaCommandResponse(ComponentId, 1);
var schemaCommandResponse = global::Improbable.Worker.CInterop.SchemaCommandResponse.Create();
global::Improbable.TestSchema.SomeType.Serialization.Serialize(response.Payload.Value, schemaCommandResponse.GetObject());

var serializedResponse = new global::Improbable.Worker.CInterop.CommandResponse(schemaCommandResponse);
var serializedResponse = new global::Improbable.Worker.CInterop.CommandResponse(ComponentId, 1, schemaCommandResponse);

serializedMessages.AddResponse(serializedResponse, (uint) response.RequestId);
}
Expand Down
Loading

0 comments on commit 618c28c

Please sign in to comment.