Skip to content
This repository has been archived by the owner on Dec 5, 2018. It is now read-only.

Commit

Permalink
initial release of the Starter Project for SpatialOS
Browse files Browse the repository at this point in the history
  • Loading branch information
johnprobable committed Apr 26, 2017
1 parent f252710 commit 6183408
Show file tree
Hide file tree
Showing 79 changed files with 1,523 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spatial.log
spatialos_worker_packages.json
build/
logs/
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# StarterProject
This is a SpatialOS starter project with useful core features that you can extend to build your own SpatialOS application
# Starter Project
---

*Copyright Improbable Worlds Ltd, 2017*

- *GitHub repository*: [https://github.com/spatialos/StarterProject](https://github.com/spatialos/StarterProject)

---

## Introduction

This is a SpatialOS starter project with useful core features that you can extend to build your own SpatialOS application.

It contains:

* A Player spawned on client connection as per the [Unity Client Lifecycle Guide](https://spatialos.improbable.io/docs/reference/latest/tutorials/client-lifecycle).
* A Cube spawned through a snapshot via an entity template method and an Unity prefab.
* The rest of the features included in the [BlankProject](https://github.com/spatialos/BlankProject).

If you run into problems, or want to give us feedback, please visit the [SpatialOS forums](https://forums.improbable.io/).

## Running the project

To run the project locally, first build it by running `spatial worker build`, then start the server with `spatial local start`. You can connect a client by opening the Unity project and pressing the play button, or by running `spatial local worker launch UnityClient default`. See the [documentation](https://spatialos.improbable.io/docs/reference/latest/developing/local/run) for more details.

To deploy the project to the cloud, first build it by running `spatial worker build -t=deployment`, then upload the assembly with `spatial cloud upload <assembly name>`, and finally deploy it with `spatial cloud launch <assembly name> <launch configuration file> <deployment name> --snapshot=<snapshot file>`. You can obtain and share links to connect to the deployment from the [console](http://console.improbable.io/projects). See the [documentation](https://spatialos.improbable.io/docs/reference/latest/developing/deploy-an-application) for more details.
43 changes: 43 additions & 0 deletions default_launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"template": "small",
"world": {
"chunkEdgeLengthMeters": 50,
"snapshots": {
"snapshotWritePeriodSeconds": 0
},
"dimensions": {
"xMeters": 1500,
"zMeters": 1500
}
},
"workers": [
{
"worker_type": "UnityWorker",
"load_balancing": {
"auto_hex_grid": {
"num_workers": 1
}
},
"permissions": [{
"all": {}
}]
},
{
"worker_type": "UnityClient",
"permissions": [{
"entity_creation": {
"allow": false
},
"entity_deletion": {
"allow": false
},
"entity_query": {
"allow": true,
"components": [
"*"
]
}
}]
}
]
}
5 changes: 5 additions & 0 deletions schema/improbable/global/ClientAuthorityCheck.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package improbable.global;

component ClientAuthorityCheck {
id = 1002;
}
9 changes: 9 additions & 0 deletions schema/improbable/global/PlayerCreation.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package improbable.global;

type CreatePlayerRequest {}
type CreatePlayerResponse {}

component PlayerCreation {
id = 1001;
command CreatePlayerResponse create_player(CreatePlayerRequest);
}
8 changes: 8 additions & 0 deletions schema/improbable/global/Quaternion.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package improbable.global;

type Quaternion {
float x = 1;
float y = 2;
float z = 3;
float w = 4;
}
9 changes: 9 additions & 0 deletions schema/improbable/global/WorldTransform.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package improbable.global;

import "improbable/global/Quaternion.schema";

component WorldTransform {
id = 1000;
EntityPosition position = 1;
improbable.global.Quaternion rotation = 2;
}
14 changes: 14 additions & 0 deletions schema/improbable/player/ClientConnection.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package improbable.player;

type ClientDisconnectRequest{}
type ClientDisconnectResponse{}

type HeartbeatRequest{}
type HeartbeatResponse{}

component ClientConnection {
id = 1003;
uint32 timeout_beats_remaining = 1;
command HeartbeatResponse heartbeat(HeartbeatRequest);
command ClientDisconnectResponse disconnect_client(ClientDisconnectRequest);
}
Binary file added snapshots/default.snapshot
Binary file not shown.
Binary file added snapshots/initial_world.snapshot
Binary file not shown.
8 changes: 8 additions & 0 deletions spatialos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "your_project_name_here",
"project_version": "1.0.0",
"sdk_version": "10.2.0",
"dependencies": [
{"name": "WorkerSdkSchema", "version": "10.2.0"}
]
}
7 changes: 7 additions & 0 deletions workers/gsim/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spatialos_nexus.sbt
spatialos_pack.sbt
.spatialos
generated
project
target
build.json
61 changes: 61 additions & 0 deletions workers/gsim/spatialos.gsim.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"tasks": [
{
"name": "Codegen",
"steps": [
{
"name": "Scala",
"arguments": [
"process_schema",
"generate",
"--input=../../schema/",
"--repository=../../build/dependencies/schema/",
"--output=generated",
"--language=scala"
]
}
]
},
{
"name": "Build",
"steps": [
{
"name": "Codegen",
"arguments": [
"invoke-task",
"Codegen"
]
},
{
"name": "scala",
"arguments": [
"invoke",
"sbt",
"workerPackage"
]
}
]
},
{
"name": "Clean",
"steps": [
{
"name": "Scala",
"arguments": [
"invoke",
"sbt",
"clean"
]
},
{
"name": "Generated code",
"arguments": [
"process_schema",
"clean",
"generated"
]
}
]
}
]
}
6 changes: 6 additions & 0 deletions workers/gsim/spatialos.gsim.worker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build": {
"tasks_filename": "spatialos.gsim.build.json",
"generated_build_scripts_type": "gsim"
}
}
4 changes: 4 additions & 0 deletions workers/gsim/src/main/scala/DummyMain.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// The sbt-pack plugin will print a warning if there is no main class in the
// project. The sole purpose of this file is to mask this warning.

object DummyMain extends App
50 changes: 50 additions & 0 deletions workers/unity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#Improbable Unity Ignores
build.json
.invoke.log
zip_toolbelt.log
Improbable.meta
Assets/Improbable
Assets/Plugins/Improbable
Assets/Plugins/x86/Improbable
Assets/Plugins/x86.meta
Assets/Plugins/x86_64/Improbable
Assets/Plugins/x86_64.meta
Assets/Gamelogic/Generated/
Assets/Gamelogic/Generated.meta
Assembly-CSharp-Editor.csproj
Assembly-CSharp-firstpass.csproj
Assembly-CSharp.csproj
.spatialos

# Standard Unity Ignores
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Autogenerated VS/MD solution and project files
ExportedObj/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd

# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

.idea/
Binary file added workers/unity/Assets/ClientScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions workers/unity/Assets/ClientScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions workers/unity/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions workers/unity/Assets/Editor/SnapshotMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.IO;
using Assets.Gamelogic.EntityTemplates;
using Improbable;
using Improbable.Worker;
using UnityEngine;
using JetBrains.Annotations;
using UnityEditor;
using Assets.Gamelogic.Global;

namespace Assets.Editor
{
public class SnapshotMenu : MonoBehaviour
{
[MenuItem("Improbable/Snapshots/Generate Default Snapshot")]
[UsedImplicitly]
private static void GenerateDefaultSnapshot()
{
var snapshotEntities = new Dictionary<EntityId, SnapshotEntity>();
var currentEntityId = 1;

snapshotEntities.Add(new EntityId(currentEntityId++), EntityTemplateFactory.CreatePlayerCreatorTemplate());
snapshotEntities.Add(new EntityId(currentEntityId++), EntityTemplateFactory.CreateCubeTemplate());

SaveSnapshot(snapshotEntities);
}

private static void SaveSnapshot(IDictionary<EntityId, SnapshotEntity> snapshotEntities)
{
File.Delete(SimulationSettings.DefaultSnapshotPath);
var maybeError = Snapshot.Save(SimulationSettings.DefaultSnapshotPath, snapshotEntities);

if (maybeError.HasValue)
{
Debug.LogErrorFormat("Failed to generate initial world snapshot: {0}", maybeError.Value);
}
else
{
Debug.LogFormat("Successfully generated initial world snapshot at {0}", SimulationSettings.DefaultSnapshotPath);
}
}
}
}
12 changes: 12 additions & 0 deletions workers/unity/Assets/Editor/SnapshotMenu.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions workers/unity/Assets/EntityPrefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added workers/unity/Assets/EntityPrefabs/Cube.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions workers/unity/Assets/EntityPrefabs/Cube.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added workers/unity/Assets/EntityPrefabs/Player.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions workers/unity/Assets/EntityPrefabs/Player.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
8 changes: 8 additions & 0 deletions workers/unity/Assets/EntityPrefabs/PlayerCreator.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions workers/unity/Assets/Gamelogic.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6183408

Please sign in to comment.