From 8719543f96d03fa322bfa1eeff9d120167941030 Mon Sep 17 00:00:00 2001 From: milan Date: Mon, 7 Nov 2022 14:21:00 +0100 Subject: [PATCH] requirements foundation --- .../Generic Door Entrance.asset | 3 +- .../Generic Door Exit.asset | 2 + .../Module Descriptions/Generic Module.asset | 2 + .../Module Descriptions/Generic Puzzle.asset | 3 + .../Engine/Module Descriptions/Spawn.asset | 4 +- .../Prefabs/Generic Door Entrance.prefab | 5 + .../Engine/Prefabs/Generic Door Exit.prefab | 5 + .../Engine/Prefabs/Generic Module.prefab | 102 ++++++++++-- .../Engine/Prefabs/Generic Puzzle.prefab | 10 ++ .../Engine/Prefabs/Spawn.prefab | 153 +++--------------- .../Engine/Requirements.meta | 8 + .../Place Along Space Edges.asset | 14 ++ .../Place Along Space Edges.asset.meta | 8 + .../Engine/Requirements/Place Anywhere.asset | 14 ++ .../Requirements/Place Anywhere.asset.meta | 8 + .../Engine/Scripts/Dimensions.cs | 21 ++- .../Engine/Scripts/Engine.cs | 26 ++- .../Engine/Scripts/Modules/DoorModule.cs | 1 - .../Scripts/Modules/DoorModuleDescription.cs | 1 - .../Engine/Scripts/Modules/Module.cs | 9 +- .../Scripts/Modules/ModuleDescription.cs | 8 +- .../Engine/Scripts/Modules/PuzzleModule.cs | 1 - .../Engine/Scripts/Requirements.meta | 3 + .../Requirements/PlaceAlongSpaceEdges.cs | 28 ++++ .../Requirements/PlaceAlongSpaceEdges.cs.meta | 3 + .../Scripts/Requirements/PlaceAnywhere.cs | 15 ++ .../Requirements/PlaceAnywhere.cs.meta | 3 + .../Requirements/PlacementRequirement.cs | 11 ++ .../Requirements/PlacementRequirement.cs.meta | 3 + .../Scripts/Requirements/Requirement.cs | 9 ++ .../Scripts/Requirements/Requirement.cs.meta | 3 + .../Engine/Scripts/Utilities/Logger.cs | 2 +- .../Engine/Scripts/Utilities/Utilities.cs | 2 + Assets/Scenes/TestScene.unity | 2 +- 34 files changed, 332 insertions(+), 160 deletions(-) create mode 100644 Assets/Escape Room Engine/Engine/Requirements.meta create mode 100644 Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset create mode 100644 Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset.meta create mode 100644 Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset create mode 100644 Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs.meta diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset index 2f727bc..aa684fe 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset @@ -12,8 +12,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} m_Name: Generic Door Entrance m_EditorClassIdentifier: + types: 00000000 modulePrefab: {fileID: 5399176795272327488, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} - doorType: 0 + requirements: [] connectedDoorDescription: {fileID: 11400000, guid: 29e2ae36585f4e65966bc9ea2f95ac4a, type: 2} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset index b6ca173..3b76300 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset @@ -12,8 +12,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} m_Name: Generic Door Exit m_EditorClassIdentifier: + types: 01000000 modulePrefab: {fileID: 5399176795272327488, guid: d877ee36ba6ace440aebce2c20cf70d6, type: 3} + requirements: [] doorType: 1 connectedDoorDescription: {fileID: 11400000, guid: a70cb93176094309a847f1928d6b950d, type: 2} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset index ae10c70..f343439 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset @@ -12,5 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: abf4a405f6c64073995bded39977563e, type: 3} m_Name: Generic Module m_EditorClassIdentifier: + types: modulePrefab: {fileID: 3864228228344123331, guid: ad2655de8289afa40aa520f9fc474681, type: 3} + requirements: [] diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset index e194a6d..f9293dd 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset @@ -12,5 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f928b97941e3469a9015316bb5ac1309, type: 3} m_Name: Generic Puzzle m_EditorClassIdentifier: + types: 02000000 modulePrefab: {fileID: 1780958886295268827, guid: e419cb35bd744b24ea973860d8b1405d, type: 3} + requirements: + - {fileID: 11400000, guid: d34a7e9c8d3eaf946ade02be9eff0041, type: 2} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset index 66a957b..02ed078 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset @@ -12,7 +12,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} m_Name: Spawn m_EditorClassIdentifier: - modulePrefab: {fileID: 278361332033420131, guid: db5350cd22f3a0f4f818a5f985342136, + types: 00000000 + modulePrefab: {fileID: 641449049689494886, guid: db5350cd22f3a0f4f818a5f985342136, type: 3} + requirements: [] doorType: 0 connectedDoorDescription: {fileID: 11400000} diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Entrance.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Entrance.prefab index 8b50377..0800149 100644 --- a/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Entrance.prefab +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Entrance.prefab @@ -72,5 +72,10 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8741597917111152084, guid: 30bf75759c019b843afd4c6aeb694159, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 94d63268ac1ac034d8c0af72dd04a346, type: 2} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 30bf75759c019b843afd4c6aeb694159, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Exit.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Exit.prefab index bd7d589..63fe1b3 100644 --- a/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Exit.prefab +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Door Exit.prefab @@ -72,5 +72,10 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8741597917111152084, guid: 30bf75759c019b843afd4c6aeb694159, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 3e334d6799a0d0040a41fe4794da90f5, type: 2} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 30bf75759c019b843afd4c6aeb694159, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Generic Module.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Generic Module.prefab index 0c714c1..6b5b0eb 100644 --- a/Assets/Escape Room Engine/Engine/Prefabs/Generic Module.prefab +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Module.prefab @@ -1,5 +1,88 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &714560894994709254 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6287965203426599350} + - component: {fileID: 5368003019011713868} + - component: {fileID: 4637598171471972507} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6287965203426599350 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 714560894994709254} + m_LocalRotation: {x: -0.15643595, y: 0.37715694, z: -0.06479774, w: 0.91053927} + m_LocalPosition: {x: 0, y: 0.262, z: 0.075} + m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7279153380729290489} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: -13.651, y: 46.691, z: -14.056} +--- !u!33 &5368003019011713868 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 714560894994709254} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &4637598171471972507 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 714560894994709254} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + 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 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &3864228228344123331 GameObject: m_ObjectHideFlags: 0 @@ -43,7 +126,6 @@ GameObject: - component: {fileID: 7279153380729290489} - component: {fileID: 609314626751263072} - component: {fileID: 8884008595548699417} - - component: {fileID: 3037682669808127519} m_Layer: 0 m_Name: Cube m_TagString: Untagged @@ -59,10 +141,11 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4439105426094897912} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.5, y: 0.5, z: 0.5} + m_LocalPosition: {x: 0, y: 0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 6287965203426599350} m_Father: {fileID: 7860513085978939562} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -116,16 +199,3 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!65 &3037682669808127519 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4439105426094897912} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab index 9b6d0d5..9dfcb50 100644 --- a/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab @@ -12,6 +12,16 @@ PrefabInstance: propertyPath: m_Name value: Generic Puzzle objectReference: {fileID: 0} + - target: {fileID: 4637598171471972507, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 46455800cc2ce524c92336599f5ec772, type: 2} + - target: {fileID: 7279153380729290489, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, type: 3} propertyPath: m_RootOrder diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Spawn.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Spawn.prefab index 912815b..50edd58 100644 --- a/Assets/Escape Room Engine/Engine/Prefabs/Spawn.prefab +++ b/Assets/Escape Room Engine/Engine/Prefabs/Spawn.prefab @@ -1,179 +1,76 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &6011647874759208035 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5928148369176390461} - - component: {fileID: 5083806700704616900} - - component: {fileID: 3214657300310728549} - - component: {fileID: 8608837451192070870} - m_Layer: 0 - m_Name: Sphere - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &5928148369176390461 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6011647874759208035} - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 6587262333262160906} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &5083806700704616900 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6011647874759208035} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!23 &3214657300310728549 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6011647874759208035} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - 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 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!135 &8608837451192070870 -SphereCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6011647874759208035} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Radius: 0.5 - m_Center: {x: 0, y: 0, z: 0} ---- !u!1001 &1112641151226188271 +--- !u!1001 &4758994409158878246 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 330650459340005303, guid: 30bf75759c019b843afd4c6aeb694159, - type: 3} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 913127997918145164, guid: 30bf75759c019b843afd4c6aeb694159, - type: 3} - propertyPath: m_Name - value: Spawn - objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalPosition.x - value: 0.5 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalPosition.z - value: 0.5 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, + - target: {fileID: 1322900129209232937, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 1894180114262114426, guid: da9b7a57e7c37d149827fe17188bdeea, + type: 3} + propertyPath: m_LocalPosition.y + value: -0.90000004 + objectReference: {fileID: 0} + - target: {fileID: 5399176795272327488, guid: da9b7a57e7c37d149827fe17188bdeea, + type: 3} + propertyPath: m_Name + value: Spawn + objectReference: {fileID: 0} m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 30bf75759c019b843afd4c6aeb694159, type: 3} ---- !u!4 &6587262333262160906 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 6060240960858060261, guid: 30bf75759c019b843afd4c6aeb694159, - type: 3} - m_PrefabInstance: {fileID: 1112641151226188271} - m_PrefabAsset: {fileID: 0} + m_SourcePrefab: {fileID: 100100000, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Requirements.meta b/Assets/Escape Room Engine/Engine/Requirements.meta new file mode 100644 index 0000000..e46bbc8 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Requirements.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1491a0a32aa61104b9a742535e2dd3f9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset b/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset new file mode 100644 index 0000000..87d62ef --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8ec2cdf0145347e18e7c68221333be2c, type: 3} + m_Name: Place Along Space Edges + m_EditorClassIdentifier: diff --git a/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset.meta b/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset.meta new file mode 100644 index 0000000..b9c6c09 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Requirements/Place Along Space Edges.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed4830127e9381245a6af07e42c52422 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset b/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset new file mode 100644 index 0000000..a15af17 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aa4ff365b4e844e782cd12d8aeebd3d4, type: 3} + m_Name: Place Anywhere + m_EditorClassIdentifier: diff --git a/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset.meta b/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset.meta new file mode 100644 index 0000000..3686989 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Requirements/Place Anywhere.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d34a7e9c8d3eaf946ade02be9eff0041 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Scripts/Dimensions.cs b/Assets/Escape Room Engine/Engine/Scripts/Dimensions.cs index d405985..d51909f 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Dimensions.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Dimensions.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System.Collections.Generic; +using UnityEngine; namespace Escape_Room_Engine.Engine.Scripts { @@ -39,6 +40,24 @@ namespace Escape_Room_Engine.Engine.Scripts public int Area => width * length; + public HashSet EveryPosition + { + get + { + var positions = new HashSet(); + + for (var zIter = 0; zIter < length; zIter++) + { + for (var xIter = 0; xIter < width; xIter++) + { + positions.Add(new Vector2Int(xIter, zIter)); + } + } + + return positions; + } + } + public override string ToString() => $"({width}, {length}) at ({x}, {z})"; } } \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Engine.cs b/Assets/Escape Room Engine/Engine/Scripts/Engine.cs index ab1cacf..4aa4f99 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Engine.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Engine.cs @@ -82,17 +82,31 @@ namespace Escape_Room_Engine.Engine.Scripts // add puzzles for (var i = 0; i < Utilities.Utilities.RandomInclusive(minPuzzleCount, maxPuzzleCount); i++) { - var puzzle = new PuzzleModule(space, puzzleTypes.RandomElement()); - puzzle.Place(new Vector2Int( - Random.Range(0, rrDimensions.width), - Random.Range(0, rrDimensions.length) - )); - space.AddModule(puzzle); + GeneratePuzzle(space); } room.AddSpace(space, exit); } + private void GeneratePuzzle(Space space) + { + var puzzle = new PuzzleModule(space, puzzleTypes.RandomElement()); + + // place puzzle + var placementCandidates = space.rrDimensions.EveryPosition; + puzzle._description.PlacementRequirements.ForEach(requirement => + placementCandidates.IntersectWith(requirement.PlacementCandidates(puzzle, space))); + if (placementCandidates.Count > 0) + { + puzzle.Place(placementCandidates.RandomElement()); + space.AddModule(puzzle); + } + else + { + Logger.Log("Could not find suitable placement for puzzle", LogType.PuzzleGeneration); + } + } + /// /// Generate space dimensions that fit the required size constraints and cover the position of the entrance. /// diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModule.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModule.cs index 11ae019..a93ae6c 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModule.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModule.cs @@ -16,7 +16,6 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules internal DoorModule(Space space, DoorModuleDescription description) : base(space, description) { - _description.types.Add((ModuleType)description.doorType); srDimensions.Size = Vector2Int.one; // door always has size 1x1 } diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs index e93f887..0fc26f6 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs @@ -5,7 +5,6 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules [CreateAssetMenu(menuName = "Modules/Door")] public class DoorModuleDescription : ModuleDescription { - public DoorType doorType; /// /// The description for the door that should be connected with this one. /// If this is a teleporter entrance, the connected door should be a teleporter exit. diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/Module.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/Module.cs index 1d53d67..65dc988 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/Module.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/Module.cs @@ -8,6 +8,11 @@ using Object = UnityEngine.Object; namespace Escape_Room_Engine.Engine.Scripts.Modules { + public enum Orientation + { + North = 0, East = 90, South = 180, West = 270 + } + public class Module { /// @@ -25,6 +30,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules /// The space relative (SR) dimensions of this module. /// protected Dimensions srDimensions; + protected Orientation orientation; private readonly Space _space; @@ -65,7 +71,8 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules { _moduleObject = new GameObject(ToString()); _moduleObject.transform.SetParent(parent, false); - _moduleObject.transform.localPosition = new Vector3(srDimensions.x, 0, srDimensions.z); + _moduleObject.transform.localPosition = new Vector3(srDimensions.x + .5f, 0, srDimensions.z + .5f); + _moduleObject.transform.Rotate(Vector3.up, (float)orientation); Object.Instantiate(_description.modulePrefab, _moduleObject.transform, false); } diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs index 0762504..9f3f46d 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Escape_Room_Engine.Engine.Scripts.Requirements; using UnityEngine; namespace Escape_Room_Engine.Engine.Scripts.Modules @@ -6,7 +7,12 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules [CreateAssetMenu(menuName = "Modules/Generic Module")] public class ModuleDescription : ScriptableObject { - public readonly HashSet types = new(); + public List types = new(); public GameObject modulePrefab; + public List requirements = new(); + + public List PlacementRequirements => requirements + .FindAll(requirement => requirement is PlacementRequirement) + .ConvertAll(requirement => (PlacementRequirement)requirement); } } \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs index 5c4b1d2..0698573 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs @@ -6,7 +6,6 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules { internal PuzzleModule(Space space, PuzzleModuleDescription description) : base(space, description) { - _description.types.Add(ModuleType.Puzzle); srDimensions.Size = Vector2Int.one; // TODO: larger modules } } diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements.meta b/Assets/Escape Room Engine/Engine/Scripts/Requirements.meta new file mode 100644 index 0000000..c7da18f --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 629d8948cbb04005b050a6aa1e66c0f4 +timeCreated: 1667874124 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs new file mode 100644 index 0000000..3f7a960 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Escape_Room_Engine.Engine.Scripts.Modules; +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Requirements +{ + [CreateAssetMenu(menuName = "Requirements/Place Along Space Edges")] + public class PlaceAlongSpaceEdges : PlacementRequirement + { + public override HashSet PlacementCandidates(Module module, Space space) + { + var edgePositions = new HashSet(); + + for (var x = 0; x < space.rrDimensions.width; x++) + { + edgePositions.Add(new Vector2Int(x, 0)); + edgePositions.Add(new Vector2Int(x, space.rrDimensions.length)); + } + for (var z = 0; z < space.rrDimensions.length; z++) + { + edgePositions.Add(new Vector2Int(0, z)); + edgePositions.Add(new Vector2Int(space.rrDimensions.width, z)); + } + + return edgePositions; + } + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs.meta new file mode 100644 index 0000000..576a0ca --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAlongSpaceEdges.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8ec2cdf0145347e18e7c68221333be2c +timeCreated: 1667876484 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs new file mode 100644 index 0000000..6a87b0c --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using Escape_Room_Engine.Engine.Scripts.Modules; +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Requirements +{ + [CreateAssetMenu(menuName = "Requirements/Place Anywhere")] + public class PlaceAnywhere : PlacementRequirement + { + public override HashSet PlacementCandidates(Module module, Space space) + { + return space.rrDimensions.EveryPosition; + } + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs.meta new file mode 100644 index 0000000..dc58440 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlaceAnywhere.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: aa4ff365b4e844e782cd12d8aeebd3d4 +timeCreated: 1667876850 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs new file mode 100644 index 0000000..d74c51a --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Escape_Room_Engine.Engine.Scripts.Modules; +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Requirements +{ + public abstract class PlacementRequirement : Requirement + { + public abstract HashSet PlacementCandidates(Module module, Space space); + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs.meta new file mode 100644 index 0000000..21de97b --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/PlacementRequirement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 65f297b8d32b4f09b89c21b88b43b646 +timeCreated: 1667876036 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs b/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs new file mode 100644 index 0000000..ed9af31 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Requirements +{ + public abstract class Requirement : ScriptableObject + { + + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs.meta new file mode 100644 index 0000000..f3629e2 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Requirements/Requirement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9123b592f74444c8b6225f725b6407b3 +timeCreated: 1667874140 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Utilities/Logger.cs b/Assets/Escape Room Engine/Engine/Scripts/Utilities/Logger.cs index f4eeda9..08633bd 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Utilities/Logger.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Utilities/Logger.cs @@ -5,7 +5,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Utilities { public enum LogType { - Important, ModulePlacement, PassageConnection, RoomGeneration + Important, ModulePlacement, PassageConnection, RoomGeneration, PuzzleGeneration } public class Logger : MonoBehaviour diff --git a/Assets/Escape Room Engine/Engine/Scripts/Utilities/Utilities.cs b/Assets/Escape Room Engine/Engine/Scripts/Utilities/Utilities.cs index c937845..3adfd9d 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Utilities/Utilities.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Utilities/Utilities.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using UnityEngine; namespace Escape_Room_Engine.Engine.Scripts.Utilities @@ -24,6 +25,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Utilities public static int RandomInclusive(int from, int to) => Random.Range(from, to + 1); public static T RandomElement(this List list) => list[Random.Range(0, list.Count)]; + public static T RandomElement(this HashSet set) => set.ElementAt(Random.Range(0, set.Count)); #endregion } diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity index 0451cc3..73ad702 100644 --- a/Assets/Scenes/TestScene.unity +++ b/Assets/Scenes/TestScene.unity @@ -1271,7 +1271,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: loggingEnabled: 1 - typeFilter: 00000000010000000200000003000000 + typeFilter: 0000000001000000020000000300000004000000 --- !u!1 &1718957584 GameObject: m_ObjectHideFlags: 0