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

Commit 20cdf69

Browse files
committed
revised blank project for SpatialOS 10.2.0
1 parent 482c6b6 commit 20cdf69

29 files changed

+143
-229
lines changed

README.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# BlankProject
1+
# Blank Project
22
---
33

4-
*Copyright Improbable 2016*
4+
*Copyright Improbable Worlds Ltd, 2017*
55

6-
- *GitHub Repository*: [github.com/spatialos/BlankProject](https://github.com/spatialos/BlankProject)
6+
- *GitHub repository*: [https://github.com/spatialos/BlankProject](https://github.com/spatialos/BlankProject)
77

88
---
99

@@ -14,14 +14,10 @@ This is a blank SpatialOS project that you can use to build your own SpatialOS a
1414
It contains:
1515

1616
* A SpatialOS project descriptor.
17-
* Unity worker
17+
* A Unity worker.
1818
* Bare-bones Launch Configurations for automatically and manually launching workers.
1919
* Bare-bones Client and Physics Scenes with a `Bootstrap.cs` file.
20-
* An example deployment configuration, `deploy.json`.
20+
* An example deployment configuration, `default_launch.json`.
2121
* `.gitignore` files for a SpatialOS project.
2222

23-
## Using the BlankProject
24-
25-
[SpatialOS documentation](https://spatialos.improbable.io/docs/).
26-
27-
To report bugs or to give feedback on this project, please contact SpatialOS Support.
23+
If you run into problems, or want to give us feedback, please visit the [SpatialOS forums](https://forums.improbable.io/).

default_launch.json

+17-20
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,17 @@
66
"snapshotWritePeriodSeconds": 0
77
},
88
"dimensions": {
9-
"xMeters": 8000,
10-
"zMeters": 8000
9+
"xMeters": 1500,
10+
"zMeters": 1500
1111
}
1212
},
1313
"workers": [
1414
{
1515
"worker_type": "UnityWorker",
1616
"load_balancing": {
17-
"dynamic_loadbalancer": {
18-
"worker_scaler_config": {
19-
"constant_config": {
20-
"num_workers": 4
21-
}
22-
},
23-
"worker_placer_config": {
24-
"random_params": {}
25-
},
26-
"loadbalancer_config": {
27-
"min_range_meters": 500.0,
28-
"max_range_meters": 5000.0,
29-
"speed_meters_per_second": 100.0,
30-
"expansion_time_millis": 60000
31-
}
32-
}
17+
"auto_hex_grid": {
18+
"num_workers": 1
19+
}
3320
},
3421
"permissions": [{
3522
"all": {}
@@ -38,9 +25,19 @@
3825
{
3926
"worker_type": "UnityClient",
4027
"permissions": [{
41-
"all": {}
28+
"entity_creation": {
29+
"allow": false
30+
},
31+
"entity_deletion": {
32+
"allow": false
33+
},
34+
"entity_query": {
35+
"allow": true,
36+
"components": [
37+
"*"
38+
]
4239
}
43-
]
40+
}]
4441
}
4542
]
4643
}

schema/improbable/general/WorldTransform.schema

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package improbable.global;
2+
3+
component WorldTransform {
4+
id = 1000;
5+
EntityPosition position = 1;
6+
}

schema/improbable/player/name.schema

-8
This file was deleted.

snapshots/default.snapshot

24 Bytes
Binary file not shown.

snapshots/initial_world.snapshot

-129 Bytes
Binary file not shown.

spatialos.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "your_project_name_here",
3-
"project_version": "0.0.4",
3+
"project_version": "1.0.0",
44
"sdk_version": "10.2.0",
55
"dependencies": [
6-
{"name": "WorkerSdkSchema", "version": "10.2.0"}
6+
{"name": "WorkerSdkSchema", "version": "10.2.0"}
77
]
88
}

workers/unity/Assets/Bootstrap.cs

-38
This file was deleted.
+26-27
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
using System.Collections.Generic;
22
using System.IO;
3-
using Assets.EntityTemplates;
43
using Improbable;
54
using Improbable.Worker;
65
using UnityEngine;
76
using JetBrains.Annotations;
87
using UnityEditor;
8+
using Assets.Gamelogic.Global;
99

10-
public class SnapshotMenu : MonoBehaviour
10+
namespace Assets.Editor
1111
{
12-
private static readonly string InitialWorldSnapshotPath = Application.dataPath +
13-
"/../../../snapshots/initial_world.snapshot";
12+
public class SnapshotMenu : MonoBehaviour
13+
{
14+
[MenuItem("Improbable/Snapshots/Generate Default Snapshot")]
15+
[UsedImplicitly]
16+
private static void GenerateDefaultSnapshot()
17+
{
18+
var snapshotEntities = new Dictionary<EntityId, SnapshotEntity>();
1419

15-
[MenuItem("Improbable/Snapshots/Generate Snapshot Programmatically")]
16-
[UsedImplicitly]
17-
private static void GenerateSnapshotProgrammatically()
18-
{
19-
var snapshotEntities = new Dictionary<EntityId, SnapshotEntity>();
20-
var currentEntityId = 1;
20+
// Add entity data to the snapshot
2121

22-
snapshotEntities.Add(new EntityId(currentEntityId++), ExampleEntityTemplate.GenerateExampleSnapshotEntityTemplate());
22+
SaveSnapshot(snapshotEntities);
23+
}
2324

24-
SaveSnapshot(snapshotEntities);
25-
}
25+
private static void SaveSnapshot(IDictionary<EntityId, SnapshotEntity> snapshotEntities)
26+
{
27+
File.Delete(SimulationSettings.DefaultSnapshotPath);
28+
var maybeError = Snapshot.Save(SimulationSettings.DefaultSnapshotPath, snapshotEntities);
2629

27-
private static void SaveSnapshot(IDictionary<EntityId, SnapshotEntity> snapshotEntities)
28-
{
29-
File.Delete(InitialWorldSnapshotPath);
30-
var maybeError = Snapshot.Save(InitialWorldSnapshotPath, snapshotEntities);
31-
32-
if (maybeError.HasValue)
33-
{
34-
Debug.LogErrorFormat("Failed to generate initial world snapshot: {0}", maybeError.Value);
35-
}
36-
else
37-
{
38-
Debug.LogFormat("Successfully generated initial world snapshot at {0}", InitialWorldSnapshotPath);
39-
}
40-
}
30+
if (maybeError.HasValue)
31+
{
32+
Debug.LogErrorFormat("Failed to generate initial world snapshot: {0}", maybeError.Value);
33+
}
34+
else
35+
{
36+
Debug.LogFormat("Successfully generated initial world snapshot at {0}", SimulationSettings.DefaultSnapshotPath);
37+
}
38+
}
39+
}
4140
}

workers/unity/Assets/EntityPrefabs.meta

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

workers/unity/Assets/EntityPrefabs/ExampleEntity.prefab.meta

-8
This file was deleted.

workers/unity/Assets/EntityTemplates/ExampleEntityTemplate.cs

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Assets.Gamelogic.EntityTemplates
2+
{
3+
public static class EntityTemplateFactory
4+
{
5+
// Add methods to define entity templates
6+
}
7+
}

workers/unity/Assets/Gamelogic/Global.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Improbable.Unity;
2+
using Improbable.Unity.Configuration;
3+
using Improbable.Unity.Core;
4+
using UnityEngine;
5+
6+
// Placed on a GameObject in the ClientScene to execute connection logic on client startup.
7+
namespace Assets.Gamelogic.Global
8+
{
9+
public class Bootstrap : MonoBehaviour
10+
{
11+
public WorkerConfigurationData Configuration = new WorkerConfigurationData();
12+
13+
private void Start()
14+
{
15+
SpatialOS.ApplyConfiguration(Configuration);
16+
17+
Time.fixedDeltaTime = 1.0f / SimulationSettings.FixedFramerate;
18+
19+
// Distinguishes between when the Unity is running as a client or a server.
20+
switch (SpatialOS.Configuration.WorkerPlatform)
21+
{
22+
case WorkerPlatform.UnityWorker:
23+
Application.targetFrameRate = SimulationSettings.TargetServerFramerate;
24+
SpatialOS.OnDisconnected += reason => Application.Quit();
25+
break;
26+
case WorkerPlatform.UnityClient:
27+
Application.targetFrameRate = SimulationSettings.TargetClientFramerate;
28+
SpatialOS.OnConnected += OnSpatialOsConnection;
29+
break;
30+
}
31+
32+
SpatialOS.Connect(gameObject);
33+
}
34+
35+
private static void OnSpatialOsConnection()
36+
{
37+
// Add code to handle SpatialOS connection
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using UnityEngine;
2+
3+
namespace Assets.Gamelogic.Global
4+
{
5+
public static class SimulationSettings
6+
{
7+
public static readonly int TargetClientFramerate = 60;
8+
public static readonly int TargetServerFramerate = 60;
9+
public static readonly int FixedFramerate = 20;
10+
11+
public static readonly string DefaultSnapshotPath = Application.dataPath + "/../../../snapshots/default.snapshot";
12+
}
13+
}

workers/unity/Assets/Gamelogic/TransformReceiver.cs.meta renamed to workers/unity/Assets/Gamelogic/Global/SimulationSettings.cs.meta

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)