Add some computer functionality and fix a bug when setting static ids

This commit is contained in:
excitedneon 2017-05-11 19:58:33 +03:00
parent 189314ff60
commit d634e862ea
13 changed files with 435 additions and 143 deletions

View File

@ -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}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 660bef6a67fed4941b963e96ff20a5e0
timeCreated: 1494516788
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -56,7 +56,7 @@ namespace Cyber.Controls {
if (LookedAtObject != null) {
Interactable LookingAt = LookedAtObject.GetComponent<Interactable>();
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));
}

View File

@ -46,10 +46,10 @@ namespace Cyber.Entities.SyncBases {
/// for <see cref="BlinkLength"/> seconds, and calls Interact
/// on the <see cref="WillTrigger"/>.
/// </summary>
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.");
}

View File

@ -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);
/// <summary>
/// The screen this computer will print its output on.
/// </summary>
public TextTextureApplier Screen;
/// <summary>
/// The "left" key for this computer. Might cause actions depending
/// on the program.
/// </summary>
public Button KeyLeft;
/// <summary>
/// The "right" key for this computer. Might cause actions depending
/// on the program.
/// </summary>
public Button KeyRight;
/// <summary>
/// The function that is run when inputs are triggered. Can cause
/// state changes in the host computer.
/// </summary>
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);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f0956d24becd9469a855d97aee0b3150
timeCreated: 1494516387
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -23,7 +23,7 @@ namespace Cyber.Entities.SyncBases {
/// <summary>
/// Toggles the openness of the door.
/// </summary>
public override void Interact() {
public override void Interact(SyncBase Trigger) {
IsOpen = !IsOpen;
}

View File

@ -14,7 +14,7 @@ namespace Cyber.Entities.SyncBases {
/// <summary>
/// All interactables should implement their interactions by overriding this.
/// </summary>
public abstract void Interact();
public abstract void Interact(SyncBase Trigger);
/// <summary>
/// Get Interaction information about this interactible.

View File

@ -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 {
/// </summary>
/// <param name="idList">The list of id's to be set. If null, will create new ids.</param>
public void SetStaticObjectsIDs(int[] idList = null) {
SyncBase[] SyncBases = FindObjectsOfType<SyncBase>();
SyncBase[] SyncBases = GameObject.Find("/StaticWorld").GetComponentsInChildren<SyncBase>();
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);
});

View File

@ -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);

View File

@ -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);

View File

@ -44,7 +44,7 @@ namespace Cyber.Util {
/// <param name="fontSize">Font size.</param>
/// <param name="width">Width.</param>
/// <param name="height">Height.</param>
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;