From d634e862ea2f78bbc391dd6da12e0ed86bf39725 Mon Sep 17 00:00:00 2001 From: excitedneon Date: Thu, 11 May 2017 19:58:33 +0300 Subject: [PATCH] Add some computer functionality and fix a bug when setting static ids --- Assets/Prefabs/Button.prefab | 142 ++++++++ Assets/Prefabs/Button.prefab.meta | 9 + Assets/Scenes/TestMap.unity | 328 +++++++++++------- Assets/Scripts/Controls/PlayerController.cs | 2 +- Assets/Scripts/Entities/SyncBases/Button.cs | 4 +- Assets/Scripts/Entities/SyncBases/Computer.cs | 59 ++++ .../Entities/SyncBases/Computer.cs.meta | 12 + Assets/Scripts/Entities/SyncBases/Door.cs | 2 +- .../Entities/SyncBases/Interactable.cs | 2 +- Assets/Scripts/Entities/SyncDB.cs | 11 +- .../Scripts/Networking/Clientside/Client.cs | 3 +- .../Scripts/Networking/Serverside/Server.cs | 2 +- Assets/Scripts/Util/TextTextureProperties.cs | 2 +- 13 files changed, 435 insertions(+), 143 deletions(-) create mode 100644 Assets/Prefabs/Button.prefab create mode 100644 Assets/Prefabs/Button.prefab.meta create mode 100644 Assets/Scripts/Entities/SyncBases/Computer.cs create mode 100644 Assets/Scripts/Entities/SyncBases/Computer.cs.meta diff --git a/Assets/Prefabs/Button.prefab b/Assets/Prefabs/Button.prefab new file mode 100644 index 0000000..eb7715f --- /dev/null +++ b/Assets/Prefabs/Button.prefab @@ -0,0 +1,142 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1801497498412898} + m_IsPrefabParent: 1 +--- !u!1 &1390911157316470 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4566397176341920} + - component: {fileID: 33811058192742118} + - component: {fileID: 23457073056180852} + m_Layer: 0 + m_Name: Button Mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1801497498412898 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4974430339442808} + - component: {fileID: 114327153796435004} + - component: {fileID: 65328059054887456} + m_Layer: 0 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4566397176341920 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1390911157316470} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.3, z: 0} + m_LocalScale: {x: 0.6, y: 0.6, z: 0.6} + m_Children: [] + m_Father: {fileID: 4974430339442808} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4974430339442808 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1801497498412898} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -3, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4566397176341920} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23457073056180852 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1390911157316470} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 82a7d1c3c9154445794eb04c29ab2bd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33811058192742118 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1390911157316470} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &65328059054887456 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1801497498412898} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.6, y: 0.6, z: 0.6} + m_Center: {x: 0, y: 0.3, z: 0} +--- !u!114 &114327153796435004 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1801497498412898} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 962f4855dcb8f4584839a7448e385201, type: 3} + m_Name: + m_EditorClassIdentifier: + ID: 0 + WillTrigger: {fileID: 0} + Mesh: {fileID: 23457073056180852} + BlinkLength: 1 + BlinkBrightness: 1.3 + BlinkColor: {r: 1, g: 0.80689657, b: 0, a: 1} diff --git a/Assets/Prefabs/Button.prefab.meta b/Assets/Prefabs/Button.prefab.meta new file mode 100644 index 0000000..8d80439 --- /dev/null +++ b/Assets/Prefabs/Button.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 660bef6a67fed4941b963e96ff20a5e0 +timeCreated: 1494516788 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/TestMap.unity b/Assets/Scenes/TestMap.unity index b30345b..ea6f225 100644 --- a/Assets/Scenes/TestMap.unity +++ b/Assets/Scenes/TestMap.unity @@ -117,7 +117,7 @@ GameObject: m_Component: - component: {fileID: 19192150} m_Layer: 0 - m_Name: Static World + m_Name: StaticWorld m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1039,8 +1039,9 @@ GameObject: - component: {fileID: 784099995} - component: {fileID: 784099994} - component: {fileID: 784099993} + - component: {fileID: 784099998} m_Layer: 0 - m_Name: Cube + m_Name: Screen m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1124,13 +1125,28 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 784099992} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 3, y: 1.5, z: 0} m_LocalScale: {x: 0.05, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 3 + m_Father: {fileID: 949094013} + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &784099998 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 784099992} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f0956d24becd9469a855d97aee0b3150, type: 3} + m_Name: + m_EditorClassIdentifier: + ID: 0 + Screen: {fileID: 784099993} + KeyLeft: {fileID: 1848764882} + KeyRight: {fileID: 1999224091} --- !u!1 &792995699 GameObject: m_ObjectHideFlags: 0 @@ -1412,6 +1428,9 @@ Transform: - {fileID: 1988211392} - {fileID: 360020178} - {fileID: 310461192} + - {fileID: 1999224090} + - {fileID: 1848764881} + - {fileID: 784099997} m_Father: {fileID: 19192150} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1641,75 +1660,6 @@ Transform: m_Father: {fileID: 949094013} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1229079789 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 1229079790} - - component: {fileID: 1229079793} - - component: {fileID: 1229079791} - m_Layer: 0 - m_Name: Button Mesh - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1229079790 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1229079789} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.3, z: 0} - m_LocalScale: {x: 0.6, y: 0.6, z: 0.6} - m_Children: [] - m_Father: {fileID: 1988211392} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &1229079791 -MeshRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1229079789} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: 82a7d1c3c9154445794eb04c29ab2bd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 1 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &1229079793 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1229079789} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1304969965 GameObject: m_ObjectHideFlags: 0 @@ -1958,6 +1908,53 @@ Transform: m_Father: {fileID: 949094013} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1451847461 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 949094013} + m_Modifications: + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.x + value: -3 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 114327153796435004, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + propertyPath: WillTrigger + value: + objectReference: {fileID: 310461193} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + m_IsPrefabParent: 0 --- !u!1 &1463006270 GameObject: m_ObjectHideFlags: 0 @@ -2332,6 +2329,68 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1815899003} +--- !u!1001 &1848764880 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 949094013} + m_Modifications: + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.x + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_RootOrder + value: 7 + objectReference: {fileID: 0} + - target: {fileID: 114327153796435004, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + propertyPath: WillTrigger + value: + objectReference: {fileID: 784099998} + - target: {fileID: 1801497498412898, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_Name + value: Button Left + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &1848764881 stripped +Transform: + m_PrefabParentObject: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + m_PrefabInternal: {fileID: 1848764880} +--- !u!114 &1848764882 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 114327153796435004, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + m_PrefabInternal: {fileID: 1848764880} + m_Script: {fileID: 11500000, guid: 962f4855dcb8f4584839a7448e385201, type: 3} --- !u!1 &1939832656 GameObject: m_ObjectHideFlags: 0 @@ -2376,66 +2435,73 @@ Transform: m_Father: {fileID: 344272455} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1988211391 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 1988211392} - - component: {fileID: 1988211393} - - component: {fileID: 1988211394} - m_Layer: 0 - m_Name: Button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1988211392 +--- !u!4 &1988211392 stripped Transform: + m_PrefabParentObject: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + m_PrefabInternal: {fileID: 1451847461} +--- !u!1001 &1999224089 +Prefab: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1988211391} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -3, y: 1, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1229079790} - m_Father: {fileID: 949094013} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1988211393 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1988211391} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 962f4855dcb8f4584839a7448e385201, type: 3} - m_Name: - m_EditorClassIdentifier: - ID: 0 - WillTrigger: {fileID: 310461193} - Mesh: {fileID: 1229079791} - BlinkLength: 1 - BlinkBrightness: 1.3 - BlinkColor: {r: 1, g: 0.80689657, b: 0, a: 1} ---- !u!65 &1988211394 -BoxCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1988211391} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 0.6, y: 0.6, z: 0.6} - m_Center: {x: 0, y: 0.3, z: 0} + m_Modification: + m_TransformParent: {fileID: 949094013} + m_Modifications: + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.x + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalPosition.z + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 114327153796435004, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + propertyPath: WillTrigger + value: + objectReference: {fileID: 784099998} + - target: {fileID: 1801497498412898, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + propertyPath: m_Name + value: Button Right + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 660bef6a67fed4941b963e96ff20a5e0, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &1999224090 stripped +Transform: + m_PrefabParentObject: {fileID: 4974430339442808, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + m_PrefabInternal: {fileID: 1999224089} +--- !u!114 &1999224091 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 114327153796435004, guid: 660bef6a67fed4941b963e96ff20a5e0, + type: 2} + m_PrefabInternal: {fileID: 1999224089} + m_Script: {fileID: 11500000, guid: 962f4855dcb8f4584839a7448e385201, type: 3} --- !u!1 &2000206069 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Controls/PlayerController.cs b/Assets/Scripts/Controls/PlayerController.cs index 300a8b5..5a3b318 100644 --- a/Assets/Scripts/Controls/PlayerController.cs +++ b/Assets/Scripts/Controls/PlayerController.cs @@ -56,7 +56,7 @@ namespace Cyber.Controls { if (LookedAtObject != null) { Interactable LookingAt = LookedAtObject.GetComponent(); if (LookingAt != null && (LookingAt.transform.position - Character.GetPosition()).magnitude < Character.InteractionDistance) { - LookingAt.Interact(); + LookingAt.Interact(Character); if (LookingAt.GetInteractableSyncdata().PublicInteractions) { Client.Send(PktType.InteractPkt, new InteractionPkt(LookingAt.ID)); } diff --git a/Assets/Scripts/Entities/SyncBases/Button.cs b/Assets/Scripts/Entities/SyncBases/Button.cs index b155775..7855d90 100644 --- a/Assets/Scripts/Entities/SyncBases/Button.cs +++ b/Assets/Scripts/Entities/SyncBases/Button.cs @@ -46,10 +46,10 @@ namespace Cyber.Entities.SyncBases { /// for seconds, and calls Interact /// on the . /// - public override void Interact() { + public override void Interact(SyncBase Trigger) { BlinkTime = Time.time; if (WillTrigger != null) { - WillTrigger.Interact(); + WillTrigger.Interact(this); } else { Term.Println("FIXME: The button '" + gameObject.name + "' was pressed, but it doesn't have a WillTrigger."); } diff --git a/Assets/Scripts/Entities/SyncBases/Computer.cs b/Assets/Scripts/Entities/SyncBases/Computer.cs new file mode 100644 index 0000000..333c261 --- /dev/null +++ b/Assets/Scripts/Entities/SyncBases/Computer.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using UnityEngine.Networking; +using Cyber.Console; +using Cyber.Util; + +namespace Cyber.Entities.SyncBases { + public class Computer : Interactable { + public const string KeyCodeLeft = "KeyLeft"; + public const string KeyCodeRight = "KeyRight"; + public delegate void RunProgram(Computer host, string key); + + /// + /// The screen this computer will print its output on. + /// + public TextTextureApplier Screen; + + /// + /// The "left" key for this computer. Might cause actions depending + /// on the program. + /// + public Button KeyLeft; + + /// + /// The "right" key for this computer. Might cause actions depending + /// on the program. + /// + public Button KeyRight; + + /// + /// The function that is run when inputs are triggered. Can cause + /// state changes in the host computer. + /// + public RunProgram Program; + + public override void Interact(SyncBase Trigger) { + if (Trigger == KeyLeft) { + Screen.SetTextProperties(new TextTextureProperties("\n Pressed left!")); + } else if (Trigger == KeyRight) { + Screen.SetTextProperties(new TextTextureProperties("\n Pressed right!")); + } else { + Screen.SetTextProperties(new TextTextureProperties("")); + } + } + + public override void Deserialize(NetworkReader reader) { + } + + public override void Serialize(NetworkWriter writer) { + } + + public override SyncHandletype GetSyncHandletype() { + return new SyncHandletype(true, 10); + } + + public override InteractableSyncdata GetInteractableSyncdata() { + return new InteractableSyncdata(true, true); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Entities/SyncBases/Computer.cs.meta b/Assets/Scripts/Entities/SyncBases/Computer.cs.meta new file mode 100644 index 0000000..753b5a5 --- /dev/null +++ b/Assets/Scripts/Entities/SyncBases/Computer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f0956d24becd9469a855d97aee0b3150 +timeCreated: 1494516387 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Entities/SyncBases/Door.cs b/Assets/Scripts/Entities/SyncBases/Door.cs index 1d4ffa8..e7ee5f3 100644 --- a/Assets/Scripts/Entities/SyncBases/Door.cs +++ b/Assets/Scripts/Entities/SyncBases/Door.cs @@ -23,7 +23,7 @@ namespace Cyber.Entities.SyncBases { /// /// Toggles the openness of the door. /// - public override void Interact() { + public override void Interact(SyncBase Trigger) { IsOpen = !IsOpen; } diff --git a/Assets/Scripts/Entities/SyncBases/Interactable.cs b/Assets/Scripts/Entities/SyncBases/Interactable.cs index 4269b9e..e0d8d28 100644 --- a/Assets/Scripts/Entities/SyncBases/Interactable.cs +++ b/Assets/Scripts/Entities/SyncBases/Interactable.cs @@ -14,7 +14,7 @@ namespace Cyber.Entities.SyncBases { /// /// All interactables should implement their interactions by overriding this. /// - public abstract void Interact(); + public abstract void Interact(SyncBase Trigger); /// /// Get Interaction information about this interactible. diff --git a/Assets/Scripts/Entities/SyncDB.cs b/Assets/Scripts/Entities/SyncDB.cs index 423ad4a..3d49d77 100644 --- a/Assets/Scripts/Entities/SyncDB.cs +++ b/Assets/Scripts/Entities/SyncDB.cs @@ -3,6 +3,7 @@ using System; using UnityEngine; using Cyber.Networking.Serverside; using Cyber.Entities.SyncBases; +using Cyber.Console; namespace Cyber.Entities { @@ -14,7 +15,9 @@ namespace Cyber.Entities { private static readonly Type[] SyncableClasses = new Type[] { typeof(Character), - typeof(Button) + typeof(Button), + typeof(Door), + typeof(Computer) }; private int IDCounter = 0; @@ -135,12 +138,12 @@ namespace Cyber.Entities { /// /// The list of id's to be set. If null, will create new ids. public void SetStaticObjectsIDs(int[] idList = null) { - SyncBase[] SyncBases = FindObjectsOfType(); + SyncBase[] SyncBases = GameObject.Find("/StaticWorld").GetComponentsInChildren(); Array.Sort(SyncBases, (a, b) => { Vector3 APos = a.gameObject.transform.position; - float AComparison = APos.x + APos.y + APos.z + Array.IndexOf(SyncableClasses, a); + float AComparison = APos.x * 677 + APos.y * 881 + APos.z * 313 + Array.IndexOf(SyncableClasses, a) * 463; Vector3 BPos = b.gameObject.transform.position; - float BComparison = BPos.x + BPos.y + BPos.z + Array.IndexOf(SyncableClasses, b); + float BComparison = BPos.x * 677 + BPos.y * 881 + BPos.z * 313 + Array.IndexOf(SyncableClasses, b) * 463; return AComparison.CompareTo(BComparison); }); diff --git a/Assets/Scripts/Networking/Clientside/Client.cs b/Assets/Scripts/Networking/Clientside/Client.cs index 3aa8b36..c6074f3 100644 --- a/Assets/Scripts/Networking/Clientside/Client.cs +++ b/Assets/Scripts/Networking/Clientside/Client.cs @@ -206,7 +206,7 @@ namespace Cyber.Networking.Clientside { SyncBase Target = Spawner.SyncDB.Get(Interaction.InteractSyncBaseID); if (Target != null && Target is Interactable) { - ((Interactable) Target).Interact(); + ((Interactable) Target).Interact(Spawner.SyncDB.Get(Interaction.OwnerSyncBaseID)); } else { Term.Println("Server has sent an erroneus SyncBase ID!"); } @@ -215,6 +215,7 @@ namespace Cyber.Networking.Clientside { SyncHandler.HandleSyncPkt(msg); break; case (PktType.StaticObjectIdsPkt): + Term.Println("The static object id packet!"); IntListPkt StaticIds = new IntListPkt(); StaticIds.Deserialize(msg.reader); Spawner.SyncDB.SetStaticObjectsIDs(StaticIds.IdList); diff --git a/Assets/Scripts/Networking/Serverside/Server.cs b/Assets/Scripts/Networking/Serverside/Server.cs index 17077a5..7a1bacc 100644 --- a/Assets/Scripts/Networking/Serverside/Server.cs +++ b/Assets/Scripts/Networking/Serverside/Server.cs @@ -186,7 +186,7 @@ namespace Cyber.Networking.Serverside { Vector3 Delta = Interacted.gameObject.transform.position - Sender.gameObject.transform.position; float ServerInteractionDistance = Sender.InteractionDistance + Sender.MovementSpeed * 0.5f; if (Delta.magnitude <= ServerInteractionDistance) { - Interacted.Interact(); + Interacted.Interact(Sender); NetworkServer.SendToAll(PktType.InteractPkt, Interaction); if (Interacted.GetInteractableSyncdata().RequiresSyncing) { Syncer.DirtSyncBase(Interacted.ID); diff --git a/Assets/Scripts/Util/TextTextureProperties.cs b/Assets/Scripts/Util/TextTextureProperties.cs index fa89e70..c115525 100644 --- a/Assets/Scripts/Util/TextTextureProperties.cs +++ b/Assets/Scripts/Util/TextTextureProperties.cs @@ -44,7 +44,7 @@ namespace Cyber.Util { /// Font size. /// Width. /// Height. - public TextTextureProperties(string text, Color background = new Color(), int fontSize = 32, int width = 128, int height = 128) { + public TextTextureProperties(string text, Color background = new Color(), int fontSize = 32, int width = 256, int height = 256) { Text = text; Background = background; FontSize = fontSize;