Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"InputFilesLastModified":[{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\build\\dependencies\\schema\\WorkerSdkSchema\\improbable\\standard_library.schema","LastModified":1488470764}],"MiscData":["csharp_framework","D:\\Projects\\SpatialProjects\\PiratesTutorial\\build\\unity\\Generated\\Std",".spatialos/schema_codegen_proto_std","9.1.0"]}
{"InputFilesLastModified":[{"InputPath":"C:\\Dev\\control_example2\\build\\dependencies\\schema\\WorkerSdkSchema\\improbable\\standard_library.schema","LastModified":1491087801}],"MiscData":["csharp_framework","C:\\Dev\\control_example2\\build\\unity\\Generated\\Std",".spatialos/schema_codegen_proto_std","9.1.0"]}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"InputFilesLastModified":[{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\build\\dependencies\\schema\\WorkerSdkSchema\\improbable\\standard_library.schema","LastModified":1488470764},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\core\\Nothing.schema","LastModified":1488470761},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\crate\\Controllable.schema","LastModified":1488470761},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\crate\\Crate.schema","LastModified":1488470761},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\general\\WorldTransform.schema","LastModified":1488470761},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\player\\Handling.schema","LastModified":1488470761},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\player\\PlayerLifecycle.schema","LastModified":1488470305},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\player\\Spawner.schema","LastModified":1488470305},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\ship\\ShipControls.schema","LastModified":1488470305},{"InputPath":"D:\\Projects\\SpatialProjects\\PiratesTutorial\\schema\\improbable\\terrain\\Terrain.schema","LastModified":1488470305}],"MiscData":["csharp_framework","D:\\Projects\\SpatialProjects\\PiratesTutorial\\build\\unity\\Generated\\Usr",".spatialos/schema_codegen_proto_usr","9.1.0"]}
{"InputFilesLastModified":[{"InputPath":"C:\\Dev\\control_example2\\build\\dependencies\\schema\\WorkerSdkSchema\\improbable\\standard_library.schema","LastModified":1491087801},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\core\\Nothing.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\crate\\Controllable.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\crate\\Crate.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\general\\WorldTransform.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\player\\Handling.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\player\\PlayerLifecycle.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\player\\Spawner.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\ship\\ShipControls.schema","LastModified":1490074621},{"InputPath":"C:\\Dev\\control_example2\\schema\\improbable\\terrain\\Terrain.schema","LastModified":1490074621}],"MiscData":["csharp_framework","C:\\Dev\\control_example2\\build\\unity\\Generated\\Usr",".spatialos/schema_codegen_proto_usr","9.1.0"]}
56 changes: 56 additions & 0 deletions workers/unity/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
3 changes: 2 additions & 1 deletion workers/unity/Assets/Editor/SnapshotMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UnityEngine;
using JetBrains.Annotations;
using UnityEditor;
using Improbable.Math;

public class SnapshotMenu : MonoBehaviour
{
Expand All @@ -21,7 +22,7 @@ private static void GenerateSnapshotProgrammatically()

snapshotEntities.Add(new EntityId(currentEntityId++), TerrainEntityTemplate.GenerateTerrainSnapshotEntityTemplate());
snapshotEntities.Add(new EntityId(currentEntityId++), PlayerSpawnerEntityTemplate.GeneratePlayerSpawnerSnapshotEntityTemplate());
snapshotEntities.Add(new EntityId(currentEntityId++), CrateEntityTemplate.GenerateCrateEntityTemplate());
snapshotEntities.Add(new EntityId(currentEntityId++), CrateEntityTemplate.GenerateCrateEntityTemplate(new Coordinates(1, 6, 9)));

SaveSnapshot(snapshotEntities);
}
Expand Down
14 changes: 14 additions & 0 deletions workers/unity/Assets/EntityPrefabs/Crate.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ GameObject:
- component: {fileID: 54539613770995770}
- component: {fileID: 114032553465742246}
- component: {fileID: 114813398424348330}
- component: {fileID: 135199603471701406}
m_Layer: 0
m_Name: Model
m_TagString: Crate
Expand Down Expand Up @@ -152,6 +153,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4b094fc48b870a0479d86321e9877ce5, type: 3}
m_Name:
m_EditorClassIdentifier:
crateCreator: {fileID: 0}
trackTo: {fileID: 0}
--- !u!114 &114325701331400612
MonoBehaviour:
Expand Down Expand Up @@ -186,3 +188,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 744b97f5bfb680545a9b5d8b97e2b0aa, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!135 &135199603471701406
SphereCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1599764083337772}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
42 changes: 22 additions & 20 deletions workers/unity/Assets/EntityPrefabs/Terrain.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 478140}
- 218: {fileID: 21869460}
- 154: {fileID: 15469210}
- component: {fileID: 478140}
- component: {fileID: 21869460}
- component: {fileID: 15469210}
m_Layer: 0
m_Name: Ground
m_TagString: Untagged
m_TagString: Ground
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand All @@ -22,13 +22,13 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 488478}
- 33: {fileID: 3363968}
- 23: {fileID: 2389048}
- 114: {fileID: 11413158}
- 114: {fileID: 11455074}
- component: {fileID: 488478}
- component: {fileID: 3363968}
- component: {fileID: 2389048}
- component: {fileID: 11413158}
- component: {fileID: 11455074}
m_Layer: 4
m_Name: Water
m_TagString: Untagged
Expand All @@ -41,11 +41,11 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 486684}
- 114: {fileID: 11495542}
- 114: {fileID: 114000011513353296}
- component: {fileID: 486684}
- component: {fileID: 11495542}
- component: {fileID: 114000011513353296}
m_Layer: 0
m_Name: Terrain
m_TagString: Untagged
Expand All @@ -62,10 +62,10 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -250, y: -1, z: -250}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 486684}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &486684
Transform:
m_ObjectHideFlags: 1
Expand All @@ -75,12 +75,12 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 478140}
- {fileID: 488478}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &488478
Transform:
m_ObjectHideFlags: 1
Expand All @@ -90,10 +90,10 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 203, y: 1, z: 227}
m_LocalScale: {x: 450, y: 2, z: 450}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 486684}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &2389048
MeshRenderer:
m_ObjectHideFlags: 1
Expand All @@ -108,15 +108,17 @@ MeshRenderer:
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 7350b65a6431f604a8496c39db1ac9c5, type: 2}
m_SubsetIndices:
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedWireframeHidden: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
Expand Down
4 changes: 2 additions & 2 deletions workers/unity/Assets/EntityTemplates/CrateEntityTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

public class CrateEntityTemplate : MonoBehaviour
{
public static SnapshotEntity GenerateCrateEntityTemplate()
public static SnapshotEntity GenerateCrateEntityTemplate(Coordinates coord)
{
var crate = new SnapshotEntity { Prefab = "Crate" };
crate.Add(new Crate.Data(new CrateData()));
crate.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(1, 6, 9), 0)));
crate.Add(new WorldTransform.Data(new WorldTransformData(coord, 0)));
crate.Add(new Controllable.Data());

var permissions = Acl.Build()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Improbable;
using Improbable.Crate;
using Improbable.Math;
using Improbable.Unity;
using Improbable.Unity.Core;
using Improbable.Unity.Visualizer;
using Improbable.Worker;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[EngineType(EnginePlatform.FSim)]
public class CreateMoreCrates : MonoBehaviour {

[Require]
private Crate.Writer CrateWriter;

void Update() {

}

void OnTriggerEnter(Collider other)
{
if (CrateWriter == null)
{
Debug.Log("Writer Null");
return;
}
if (other != null && other.tag == "Ground")
{
Vector3 pos = transform.position;
var coord = new Coordinates(pos.x, pos.y, pos.z);
GetComponent<SphereCollider>().enabled = false;

var createEntityTemplate = CrateEntityTemplate.GenerateCrateEntityTemplate(coord);

// I could never get this to work because CrateWriter was always null
SpatialOS.Commands.CreateEntity(CrateWriter, "Crate", createEntityTemplate, result =>
//SpatialOS.WorkerCommands.CreateEntity("Crate", createEntityTemplate, result =>
{
if (result.StatusCode != StatusCode.Success)
{
Debug.LogError("Failed to create crate: " + result.ErrorMessage);
return;
}
});

EntityId id = gameObject.EntityId();
//SpatialOS.WorkerCommands.DeleteEntity(id, _ => { });
SpatialOS.Commands.DeleteEntity(CrateWriter, id, _ => { });
}
}
}

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

26 changes: 13 additions & 13 deletions workers/unity/Assets/Gamelogic/Pirates/Behaviours/Mover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Improbable.General;
using Improbable.Unity.Visualizer;
using Improbable.Unity;
using UnityEditor;

namespace Assets.Gamelogic.Pirates.Behaviours
{
Expand All @@ -11,24 +10,25 @@ public class Mover : MonoBehaviour
{
[Require]
private WorldTransform.Writer WorldTransformWriter;
public CreateMoreCrates crateCreator;

public Transform trackTo;
private Quaternion newRotation;

void OnEnable()
{
WorldTransformWriter.ComponentUpdated += WorldTransformWriter_ComponentUpdated;
}
//void OnEnable()
//{
// WorldTransformWriter.ComponentUpdated += WorldTransformWriter_ComponentUpdated;
//}

void OnDisable()
{
WorldTransformWriter.ComponentUpdated -= WorldTransformWriter_ComponentUpdated;
}
//void OnDisable()
//{
// WorldTransformWriter.ComponentUpdated -= WorldTransformWriter_ComponentUpdated;
//}

private void WorldTransformWriter_ComponentUpdated(WorldTransform.Update obj)
{
Debug.Log("WorldTransformWriter_ComponentUpdated!!");
}
//private void WorldTransformWriter_ComponentUpdated(WorldTransform.Update obj)
//{
// Debug.Log("WorldTransformWriter_ComponentUpdated!!");
//}

void Update()
{
Expand Down
4 changes: 4 additions & 0 deletions workers/unity/Assets/HandleCrates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public void GainControl(GameObject entityGameObject)
Mover mover = entityGameObject.GetComponent<Mover>();
mover.trackTo = transform;
HandlingWriter.Send(new Handling.Update().SetHeldEntity(entityId));
if (entityGameObject.GetComponent<CreateMoreCrates>() == null)
{
entityGameObject.AddComponent<CreateMoreCrates>();
}
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions workers/unity/Assets/Plugins.meta

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

6 changes: 3 additions & 3 deletions workers/unity/Assets/Resources/EntityPrefabs.meta

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

Loading