From 81e42d8739eaa94a564f4d36c7a018196a429d1d Mon Sep 17 00:00:00 2001 From: Luka Date: Thu, 18 Apr 2024 14:15:43 +0200 Subject: [PATCH 1/8] feat: add doors during level generation --- .../Environment/Interactables/Door.prefab | 73 +- aplib.net-demo/Assets/Scenes/GridSystem.unity | 884 +++++++++++++++++- .../Assets/Scripts/Doors/DoorCollision.cs | 26 +- .../Assets/Scripts/WFC/GridPlacer.cs | 81 +- .../Assets/Scripts/WFC/GridPlacer.cs.meta | 12 +- aplib.net-demo/Packages/manifest.json | 3 +- aplib.net-demo/Packages/packages-lock.json | 28 +- .../BurstAotSettings_StandaloneLinux64.json | 17 + .../ProjectSettings/ProjectSettings.asset | 3 + 9 files changed, 1037 insertions(+), 90 deletions(-) create mode 100644 aplib.net-demo/ProjectSettings/BurstAotSettings_StandaloneLinux64.json diff --git a/aplib.net-demo/Assets/Prefabs/Environment/Interactables/Door.prefab b/aplib.net-demo/Assets/Prefabs/Environment/Interactables/Door.prefab index 616515af..157831fb 100644 --- a/aplib.net-demo/Assets/Prefabs/Environment/Interactables/Door.prefab +++ b/aplib.net-demo/Assets/Prefabs/Environment/Interactables/Door.prefab @@ -12,7 +12,6 @@ GameObject: - component: {fileID: 1472966249733116028} - component: {fileID: 3338573040676617101} - component: {fileID: 7956993908252065484} - - component: {fileID: 4805177238158399063} m_Layer: 0 m_Name: Door m_TagString: Untagged @@ -34,6 +33,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 720727558142947255} + - {fileID: 848415037625510833} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!33 &1472966249733116028 @@ -107,20 +107,6 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} ---- !u!114 &4805177238158399063 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3526522355453958696} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ab4ebc97e438ddf4f82df525a42daa25, type: 3} - m_Name: - m_EditorClassIdentifier: - doorId: 1 - _parent: {fileID: 3526522355453958696} --- !u!1 &4350768672960882908 GameObject: m_ObjectHideFlags: 0 @@ -135,7 +121,7 @@ GameObject: - component: {fileID: 8973477280568418425} - component: {fileID: 9013568583056147879} m_Layer: 0 - m_Name: DoorCollider + m_Name: DoorTrigger m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -240,4 +226,57 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: doorId: 0 - _parent: {fileID: 0} + parent: {fileID: 0} +--- !u!1 &6703117969167787572 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 848415037625510833} + - component: {fileID: 3675384861766110758} + m_Layer: 0 + m_Name: DoorCollider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &848415037625510833 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6703117969167787572} + serializedVersion: 2 + 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: 753418903027165643} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &3675384861766110758 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6703117969167787572} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} diff --git a/aplib.net-demo/Assets/Scenes/GridSystem.unity b/aplib.net-demo/Assets/Scenes/GridSystem.unity index e80facd8..f03ada17 100644 --- a/aplib.net-demo/Assets/Scenes/GridSystem.unity +++ b/aplib.net-demo/Assets/Scenes/GridSystem.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} + m_IndirectSpecularColor: {r: 0.18028328, g: 0.22571328, b: 0.3069218, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -123,6 +123,115 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &5735385 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5735386} + - component: {fileID: 5735389} + - component: {fileID: 5735388} + - component: {fileID: 5735387} + m_Layer: 7 + m_Name: PlayerVisual + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5735386 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5735385} + serializedVersion: 2 + 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: + - {fileID: 567241799} + - {fileID: 1686523604} + m_Father: {fileID: 1243935640} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!136 &5735387 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5735385} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &5735388 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5735385} + 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: 4709ea8a5a06f7e42bce5d484875497c, 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!33 &5735389 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5735385} + m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &24601448 GameObject: m_ObjectHideFlags: 0 @@ -241,7 +350,338 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 0 ---- !u!1 &1378037378 +--- !u!1 &238006242 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 238006245} + - component: {fileID: 238006244} + - component: {fileID: 238006243} + m_Layer: 0 + m_Name: Virtual Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &238006243 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 238006242} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d1f5e507127c23247adaeb4cf512a262, type: 3} + m_Name: + m_EditorClassIdentifier: + _horizontalSpeed: 10 + _verticalSpeed: 12 + _clampAngle: 80 +--- !u!114 &238006244 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 238006242} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45e653bab7fb20e499bda25e1b646fea, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ExcludedPropertiesInInspector: + - m_Script + m_LockStageInInspector: + m_StreamingVersion: 20170927 + m_Priority: 10 + m_StandbyUpdate: 2 + m_LookAt: {fileID: 0} + m_Follow: {fileID: 1243935640} + m_Lens: + FieldOfView: 80 + OrthographicSize: 10 + NearClipPlane: 0.1 + FarClipPlane: 5000 + Dutch: 0 + ModeOverride: 0 + LensShift: {x: 0, y: 0} + GateFit: 2 + FocusDistance: 10 + m_SensorSize: {x: 1, y: 1} + m_Transitions: + m_BlendHint: 0 + m_InheritPosition: 0 + m_OnCameraLive: + m_PersistentCalls: + m_Calls: [] + m_LegacyBlendHint: 0 + m_ComponentOwner: {fileID: 913431177} +--- !u!4 &238006245 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 238006242} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 2, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 913431177} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &305750412 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 305750414} + - component: {fileID: 305750413} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &305750413 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305750412} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a86e216828156b1448d8de6705d13e7f, type: 3} + m_Name: + m_EditorClassIdentifier: + _mouseLock: {fileID: 1629133975} + _playerTransform: {fileID: 1243935640} +--- !u!4 &305750414 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305750412} + serializedVersion: 2 + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &567241798 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 567241799} + m_Layer: 7 + m_Name: CamFollow + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &567241799 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 567241798} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5735386} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &913431176 +GameObject: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 913431177} + - component: {fileID: 913431180} + - component: {fileID: 913431179} + - component: {fileID: 913431178} + m_Layer: 0 + m_Name: cm + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &913431177 +Transform: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 913431176} + serializedVersion: 2 + 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: 238006245} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &913431178 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 913431176} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3c9beda531928fc40968802117a5d256, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RecenterTarget: 0 + m_VerticalAxis: + Value: 0 + m_SpeedMode: 0 + m_MaxSpeed: 300 + m_AccelTime: 0 + m_DecelTime: 0.1 + m_InputAxisName: + m_InputAxisValue: 0 + m_InvertInput: 1 + m_MinValue: -70 + m_MaxValue: 70 + m_Wrap: 0 + m_Recentering: + m_enabled: 0 + m_WaitTime: 1 + m_RecenteringTime: 2 + m_LegacyHeadingDefinition: -1 + m_LegacyVelocityFilterStrength: -1 + m_VerticalRecentering: + m_enabled: 0 + m_WaitTime: 1 + m_RecenteringTime: 2 + m_LegacyHeadingDefinition: -1 + m_LegacyVelocityFilterStrength: -1 + m_HorizontalAxis: + Value: 0 + m_SpeedMode: 0 + m_MaxSpeed: 300 + m_AccelTime: 0 + m_DecelTime: 0.1 + m_InputAxisName: + m_InputAxisValue: 0 + m_InvertInput: 0 + m_MinValue: -180 + m_MaxValue: 180 + m_Wrap: 1 + m_Recentering: + m_enabled: 0 + m_WaitTime: 1 + m_RecenteringTime: 2 + m_LegacyHeadingDefinition: -1 + m_LegacyVelocityFilterStrength: -1 + m_HorizontalRecentering: + m_enabled: 0 + m_WaitTime: 1 + m_RecenteringTime: 2 + m_LegacyHeadingDefinition: -1 + m_LegacyVelocityFilterStrength: -1 + m_ApplyBeforeBody: 0 +--- !u!114 &913431179 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 913431176} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36d1163fa822e8b418a0a603ec078d5c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Damping: 0 +--- !u!114 &913431180 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 913431176} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &1146326357 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1146326359} + - component: {fileID: 1146326358} + m_Layer: 0 + m_Name: CameraManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1146326358 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146326357} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e53597eb9099ea944b4b47688ff12f55, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayerVisTransform: {fileID: 5735386} +--- !u!4 &1146326359 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146326357} + serializedVersion: 2 + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1243935633 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -249,9 +689,237 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1378037381} - - component: {fileID: 1378037380} - - component: {fileID: 1378037379} + - component: {fileID: 1243935640} + - component: {fileID: 1243935639} + - component: {fileID: 1243935638} + - component: {fileID: 1243935637} + - component: {fileID: 1243935636} + - component: {fileID: 1243935635} + - component: {fileID: 1243935634} + m_Layer: 7 + m_Name: Player + m_TagString: Player + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1243935634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1ea6676c278c51f44aecf76adb1d4961, type: 3} + m_Name: + m_EditorClassIdentifier: + _maxSpeedGround: 7 + _maxSpeedAir: 7 + _acceleration: 140 + _normalGravityScale: 1.7 + _fallingGravityScale: 2.5 + _jumpHeight: 7 + _airMovementScale: 0.5 + _groundMask: + serializedVersion: 2 + m_Bits: 64 + _groundDrag: 0.8 + _airDrag: 0.2 + _slopeAngle: 40 + _slopeCheckRayExtraLength: 0.3 + _wallCheckMaxDistance: 0.5 + _playerVisTransform: {fileID: 5735386} +--- !u!54 &1243935635 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + serializedVersion: 4 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_CenterOfMass: {x: 0, y: 0, z: 0} + m_InertiaTensor: {x: 1, y: 1, z: 1} + m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ImplicitCom: 1 + m_ImplicitTensor: 1 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 1 + m_Constraints: 112 + m_CollisionDetection: 1 +--- !u!114 &1243935636 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Actions: {fileID: -944628639613478452, guid: 181079df28ea48f47b289ef2760436f4, + type: 3} + m_NotificationBehavior: 0 + m_UIInputModule: {fileID: 0} + m_DeviceLostEvent: + m_PersistentCalls: + m_Calls: [] + m_DeviceRegainedEvent: + m_PersistentCalls: + m_Calls: [] + m_ControlsChangedEvent: + m_PersistentCalls: + m_Calls: [] + m_ActionEvents: [] + m_NeverAutoSwitchControlSchemes: 0 + m_DefaultControlScheme: + m_DefaultActionMap: Player + m_SplitScreenIndex: -1 + m_Camera: {fileID: 0} +--- !u!136 &1243935637 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + m_Material: {fileID: 13400000, guid: e5ad33bb5f3f35a4a81e6043c6935a2d, type: 2} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.56 + m_Height: 1.9 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!136 &1243935638 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + m_Material: {fileID: 13400000, guid: f0bc186bb893f79478f18ef7a8fc00e1, type: 2} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1243935639 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1243935640 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1243935633} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 2, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5735386} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1455078761 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1455078763} + - component: {fileID: 1455078762} + m_Layer: 0 + m_Name: Grid + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1455078762 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1455078761} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bf81f8d2562f471f8fe5ad818d5670e6, type: 3} + m_Name: + m_EditorClassIdentifier: + _roomObjects: {fileID: 11400000, guid: 9962865d7cc12a74abe02efdb8b7d072, type: 2} + _doorPrefab: {fileID: 3526522355453958696, guid: 22b08b26ebf57994bb9b9f1004aa58ca, + type: 3} +--- !u!4 &1455078763 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1455078761} + serializedVersion: 2 + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1629133974 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1629133980} + - component: {fileID: 1629133979} + - component: {fileID: 1629133978} + - component: {fileID: 1629133977} + - component: {fileID: 1629133976} + - component: {fileID: 1629133975} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -259,21 +927,111 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!81 &1378037379 +--- !u!114 &1629133975 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629133974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 050f3baec8542fa4ea6c967dc6e56d43, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1629133976 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629133974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 72ece51f2901e7445ab60da3685d6b5f, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ShowDebugText: 0 + m_ShowCameraFrustum: 1 + m_IgnoreTimeScale: 1 + m_WorldUpOverride: {fileID: 0} + m_UpdateMethod: 2 + m_BlendUpdateMethod: 1 + m_DefaultBlend: + m_Style: 1 + m_Time: 2 + m_CustomCurve: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CustomBlends: {fileID: 0} + m_CameraCutEvent: + m_PersistentCalls: + m_Calls: [] + m_CameraActivatedEvent: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1629133977 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1629133974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 + m_TaaSettings: + quality: 3 + frameInfluence: 0.1 + jitterScale: 1 + mipBias: 0 + varianceClampScale: 0.9 + contrastAdaptiveSharpening: 0 +--- !u!81 &1629133978 AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1378037378} + m_GameObject: {fileID: 1629133974} m_Enabled: 1 ---- !u!20 &1378037380 +--- !u!20 &1629133979 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1378037378} + m_GameObject: {fileID: 1629133974} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 @@ -298,15 +1056,15 @@ Camera: y: 0 width: 1 height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 + near clip plane: 0.1 + far clip plane: 5000 + field of view: 80 orthographic: 0 - orthographic size: 5 + orthographic size: 10 m_Depth: -1 m_CullingMask: serializedVersion: 2 - m_Bits: 4294967295 + m_Bits: 119 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -318,22 +1076,22 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!4 &1378037381 +--- !u!4 &1629133980 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1378037378} + m_GameObject: {fileID: 1629133974} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalPosition: {x: 0, y: 2, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1455078761 +--- !u!1 &1686523603 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -341,47 +1099,89 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1455078763} - - component: {fileID: 1455078762} - m_Layer: 0 - m_Name: Grid + - component: {fileID: 1686523604} + - component: {fileID: 1686523606} + - component: {fileID: 1686523605} + m_Layer: 7 + m_Name: Visor m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1455078762 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1455078761} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: bf81f8d2562f471f8fe5ad818d5670e6, type: 3} - m_Name: - m_EditorClassIdentifier: - RoomObjects: {fileID: 11400000, guid: 9962865d7cc12a74abe02efdb8b7d072, type: 2} ---- !u!4 &1455078763 +--- !u!4 &1686523604 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1455078761} + m_GameObject: {fileID: 1686523603} serializedVersion: 2 - 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_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, z: 0.5} + m_LocalScale: {x: 0.7, y: 0.2, z: 0.2} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 5735386} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1686523605 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1686523603} + 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!33 &1686523606 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1686523603} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 1378037381} - {fileID: 24601450} - {fileID: 1455078763} + - {fileID: 1243935640} + - {fileID: 1629133980} + - {fileID: 305750414} + - {fileID: 1146326359} + - {fileID: 238006245} diff --git a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs index 1f1a3b2b..d9a04ab1 100644 --- a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs +++ b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs @@ -2,15 +2,24 @@ /// /// This class handles collisions with the player and makes sure that the parent object (the door) disappears/opens when -/// the player is in range and the prerequisites are met (the right key, or in this case the right player ID). -/// Set the ID in the editor for the collider +/// the player is in range and the prerequisites are met (the right key). /// public class DoorCollision : MonoBehaviour { + /// + /// The number of doors that have been spawned in the level so far. This is used to give each door a unique ID. + /// + private static int s_numberOfDoors; + /// The unique ID of the door, to check whether the player has the right key/ID to open the door - public int doorId; - /// the door object this script is attached to - [SerializeField] private GameObject parent; + [SerializeField] private int _doorId; + + /// Gives the door a unique ID on load. + private void Awake() + { + _doorId = s_numberOfDoors; + s_numberOfDoors++; + } /// /// Checks if the player has the right ID, and destroys the door if true @@ -18,10 +27,7 @@ public class DoorCollision : MonoBehaviour /// the object that collides with the collider private void OnTriggerEnter(Collider collidingObject) { - //Delete door - if (collidingObject.gameObject.CompareTag("Player") && collidingObject.gameObject.GetComponent().itemId == doorId) - { - Destroy(parent); - } + // Delete door if it is triggered by the player + if (collidingObject.gameObject.CompareTag("Player")) Destroy(transform.parent.gameObject); } } diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 95967710..3a808384 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -9,11 +9,6 @@ namespace Assets.Scripts.WFC /// public class GridPlacer : MonoBehaviour { - /// - /// Represents the grid. - /// - private Grid _grid; - /// /// The size of the tiles in the x-direction. /// @@ -32,7 +27,17 @@ public class GridPlacer : MonoBehaviour /// /// Represents the room objects. /// - public RoomObjects RoomObjects; + [SerializeField] private RoomObjects _roomObjects; + + /// + /// Represents the door object. + /// + [SerializeField] private GameObject _doorPrefab; + + /// + /// Represents the grid. + /// + private Grid _grid; /// /// Awake is called when the script instance is being loaded. @@ -57,7 +62,7 @@ public void Awake() /// /// A temporary function to fill the grid with rooms. /// - public void TempFillFunction() + private void TempFillFunction() { _grid.PlaceRoom(2, 1, new Room(new List { false, true, true, false })); @@ -83,22 +88,62 @@ public void TempFillFunction() /// The x-coordinates of the room. /// The y-coordinates of the room. /// The tile that needs to be placed. - public void PlaceTile(int x, int y, Tile tile) + /// Thrown when the is of an unkown type. + private void PlaceTile(int x, int y, Tile tile) { + if (tile is Room room) PlaceDoors(x, y, room); + GameObject prefab = tile switch { - Corner _ => RoomObjects.Corner, - Crossing _ => RoomObjects.Crossing, - DeadEnd _ => RoomObjects.DeadEnd, - Empty _ => RoomObjects.Empty, - Room _ => RoomObjects.Room, - Straight _ => RoomObjects.Straight, - TSection _ => RoomObjects.TSection, - _ => null + Corner _ => _roomObjects.Corner, + Crossing _ => _roomObjects.Crossing, + DeadEnd _ => _roomObjects.DeadEnd, + Empty _ => _roomObjects.Empty, + Room _ => _roomObjects.Room, + Straight _ => _roomObjects.Straight, + TSection _ => _roomObjects.TSection, + _ => throw new UnityException("Unknown tile type when placing tile") }; - if (prefab != null) - _ = Instantiate(prefab, new Vector3(x * _tileSizeX, 0, y * _tileSizeY), Quaternion.Euler(0, tile.Rotation * _tileRotation, 0), transform); + _ = Instantiate + ( + prefab, + new Vector3(x * _tileSizeX, 0, y * _tileSizeY), + Quaternion.Euler(0, tile.Rotation * _tileRotation, 0), + transform + ); + } + + /// + /// Place the doors for the given room in the world. Which doors need to be spawned is determined from the + /// allowed directions of the room. + /// + /// The x-position of the room, in the grid. + /// The y-position of the room, in the grid. + /// The room for which the doors need to be spawned. + // ReSharper disable once SuggestBaseTypeForParameter + private void PlaceDoors(int x, int y, Room room) + { + for (int direction = 0; direction <= 3; direction++) + { + // Continue to next direction if no door needs to be placed + if (room.CanConnectInDirection(direction)) continue; + + Vector3 roomPosition = new(x * _tileSizeX, 0, y * _tileSizeY); + Quaternion roomRotation = Quaternion.Euler(0, room.Rotation * _tileRotation, 0); + (Vector3 relativeDoorPosition, Quaternion relativeDoorRotation) = direction switch + { + 0 => (new Vector3(-_tileSizeX / 2f, 0, 0), Quaternion.Euler(0, -_tileRotation, 0)), + 1 => (new Vector3(0, 0, _tileSizeY / 2f), Quaternion.identity), + 2 => (new Vector3(_tileSizeX / 2f, 0, 0), Quaternion.Euler(0, _tileRotation, 0)), + 3 => (new Vector3(0, 0, -_tileSizeY / 2f), Quaternion.Euler(0, 2f * _tileRotation, 0)), + _ => throw new UnityException("Invalid direction when placing door") + }; + Vector3 doorPosition = roomPosition + relativeDoorPosition; + Quaternion doorRotation = roomRotation * relativeDoorRotation; + + _ = Instantiate(_doorPrefab, doorPosition, doorRotation, transform); + } } } } diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs.meta b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs.meta index a0b69c6b..a02ac7e6 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs.meta +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs.meta @@ -1,3 +1,13 @@ fileFormatVersion: 2 guid: bf81f8d2562f471f8fe5ad818d5670e6 -timeCreated: 1712221432 \ No newline at end of file +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - RoomObjects: {instanceID: 0} + - doorObjects: {instanceID: 0} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/aplib.net-demo/Packages/manifest.json b/aplib.net-demo/Packages/manifest.json index e305570c..13e1b44f 100644 --- a/aplib.net-demo/Packages/manifest.json +++ b/aplib.net-demo/Packages/manifest.json @@ -2,7 +2,7 @@ "dependencies": { "com.unity.cinemachine": "2.9.7", "com.unity.collab-proxy": "2.2.0", - "com.unity.ide.rider": "3.0.27", + "com.unity.ide.rider": "3.0.28", "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", "com.unity.inputsystem": "1.7.0", @@ -13,6 +13,7 @@ "com.unity.testtools.codecoverage": "1.2.5", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.7.6", + "com.unity.toolchain.linux-x86_64": "2.0.6", "com.unity.ugui": "1.0.0", "com.unity.visualscripting": "1.9.1", "com.unity.modules.ai": "1.0.0", diff --git a/aplib.net-demo/Packages/packages-lock.json b/aplib.net-demo/Packages/packages-lock.json index c99b1152..4566abc2 100644 --- a/aplib.net-demo/Packages/packages-lock.json +++ b/aplib.net-demo/Packages/packages-lock.json @@ -34,7 +34,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.27", + "version": "3.0.28", "depth": 0, "source": "registry", "dependencies": { @@ -148,6 +148,22 @@ "com.unity.searcher": "4.9.2" } }, + "com.unity.sysroot": { + "version": "2.0.7", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.sysroot.linux-x86_64": { + "version": "2.0.6", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7" + }, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { "version": "1.1.33", "depth": 0, @@ -190,6 +206,16 @@ }, "url": "https://packages.unity.com" }, + "com.unity.toolchain.linux-x86_64": { + "version": "2.0.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7", + "com.unity.sysroot.linux-x86_64": "2.0.6" + }, + "url": "https://packages.unity.com" + }, "com.unity.ugui": { "version": "1.0.0", "depth": 0, diff --git a/aplib.net-demo/ProjectSettings/BurstAotSettings_StandaloneLinux64.json b/aplib.net-demo/ProjectSettings/BurstAotSettings_StandaloneLinux64.json new file mode 100644 index 00000000..ca7cf1a1 --- /dev/null +++ b/aplib.net-demo/ProjectSettings/BurstAotSettings_StandaloneLinux64.json @@ -0,0 +1,17 @@ +{ + "MonoBehaviour": { + "Version": 4, + "EnableBurstCompilation": true, + "EnableOptimisations": true, + "EnableSafetyChecks": false, + "EnableDebugInAllBuilds": false, + "DebugDataKind": 1, + "EnableArmv9SecurityFeatures": false, + "CpuMinTargetX32": 0, + "CpuMaxTargetX32": 0, + "CpuMinTargetX64": 0, + "CpuMaxTargetX64": 0, + "CpuTargetsX64": 72, + "OptimizeFor": 0 + } +} diff --git a/aplib.net-demo/ProjectSettings/ProjectSettings.asset b/aplib.net-demo/ProjectSettings/ProjectSettings.asset index 515047b8..833c8db0 100644 --- a/aplib.net-demo/ProjectSettings/ProjectSettings.asset +++ b/aplib.net-demo/ProjectSettings/ProjectSettings.asset @@ -523,6 +523,9 @@ PlayerSettings: - m_BuildTarget: AndroidPlayer m_APIs: 150000000b000000 m_Automatic: 0 + - m_BuildTarget: LinuxStandaloneSupport + m_APIs: 1500000011000000 + m_Automatic: 0 m_BuildTargetVRSettings: [] m_DefaultShaderChunkSizeInMB: 16 m_DefaultShaderChunkCount: 0 From 0c34a99e3a06b24adee5eb45573da112c2df89cb Mon Sep 17 00:00:00 2001 From: Luka Date: Sat, 20 Apr 2024 15:55:48 +0200 Subject: [PATCH 2/8] fix: naming and formatting --- .gitignore | 5 +++- aplib.net-demo/.editorconfig | 5 ++++ .../Assets/Scripts/Doors/DoorCollision.cs | 12 +++++----- .../Assets/Scripts/WFC/GridPlacer.cs | 24 +++++++++---------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 5d3aa6ad..603356da 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,7 @@ aplib.net-demo/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* # Temporary auto-generated Android Assets aplib.net-demo/[Aa]ssets/[Ss]treamingAssets/aa.meta -aplib.net-demo/[Aa]ssets/[Ss]treamingAssets/aa/* \ No newline at end of file +aplib.net-demo/[Aa]ssets/[Ss]treamingAssets/aa/* + +# Rider files +.idea/ \ No newline at end of file diff --git a/aplib.net-demo/.editorconfig b/aplib.net-demo/.editorconfig index 67652209..9c3f1409 100644 --- a/aplib.net-demo/.editorconfig +++ b/aplib.net-demo/.editorconfig @@ -230,6 +230,11 @@ dotnet_naming_style.begins_with_i.required_suffix = dotnet_naming_style.begins_with_i.word_separator = dotnet_naming_style.begins_with_i.capitalization = pascal_case +#### Rules for Resharper #### + +resharper_place_attribute_on_same_line = never +resharper_indent_nested_for_stmt = true + [*.{cs,vb}] # Use underscores for private fields dotnet_naming_symbols.private_fields.applicable_kinds = field diff --git a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs index d9a04ab1..241dfed0 100644 --- a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs +++ b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs @@ -9,25 +9,25 @@ public class DoorCollision : MonoBehaviour /// /// The number of doors that have been spawned in the level so far. This is used to give each door a unique ID. /// - private static int s_numberOfDoors; + private static int _numberOfDoors; - /// The unique ID of the door, to check whether the player has the right key/ID to open the door + /// The unique ID of the door, to check whether the player has the right key/ID to open the door. [SerializeField] private int _doorId; /// Gives the door a unique ID on load. private void Awake() { - _doorId = s_numberOfDoors; - s_numberOfDoors++; + _doorId = _numberOfDoors; + _numberOfDoors++; } /// /// Checks if the player has the right ID, and destroys the door if true /// - /// the object that collides with the collider + /// The object that collides with the collider. private void OnTriggerEnter(Collider collidingObject) { - // Delete door if it is triggered by the player + // Delete door if it is triggered by the player. if (collidingObject.gameObject.CompareTag("Player")) Destroy(transform.parent.gameObject); } } diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 3a808384..d1dfdb07 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -27,12 +27,14 @@ public class GridPlacer : MonoBehaviour /// /// Represents the room objects. /// - [SerializeField] private RoomObjects _roomObjects; + [SerializeField] + private RoomObjects _roomObjects; /// /// Represents the door object. /// - [SerializeField] private GameObject _doorPrefab; + [SerializeField] + private GameObject _doorPrefab; /// /// Represents the grid. @@ -51,12 +53,8 @@ public void Awake() TempFillFunction(); for (int y = 0; y < _grid.Height; y++) - { for (int x = 0; x < _grid.Width; x++) - { PlaceTile(x, y, _grid[x, y].Tile); - } - } } /// @@ -95,13 +93,13 @@ private void PlaceTile(int x, int y, Tile tile) GameObject prefab = tile switch { - Corner _ => _roomObjects.Corner, - Crossing _ => _roomObjects.Crossing, - DeadEnd _ => _roomObjects.DeadEnd, - Empty _ => _roomObjects.Empty, - Room _ => _roomObjects.Room, - Straight _ => _roomObjects.Straight, - TSection _ => _roomObjects.TSection, + Corner => _roomObjects.Corner, + Crossing => _roomObjects.Crossing, + DeadEnd => _roomObjects.DeadEnd, + Empty => _roomObjects.Empty, + Room => _roomObjects.Room, + Straight => _roomObjects.Straight, + TSection => _roomObjects.TSection, _ => throw new UnityException("Unknown tile type when placing tile") }; From daf2c700aa13dfd6719454e4850823402dc9c843 Mon Sep 17 00:00:00 2001 From: Luka Date: Sat, 20 Apr 2024 16:05:00 +0200 Subject: [PATCH 3/8] fix: do not serialize the door ID in `DoorCollision` --- aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs index 241dfed0..87d66659 100644 --- a/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs +++ b/aplib.net-demo/Assets/Scripts/Doors/DoorCollision.cs @@ -12,7 +12,7 @@ public class DoorCollision : MonoBehaviour private static int _numberOfDoors; /// The unique ID of the door, to check whether the player has the right key/ID to open the door. - [SerializeField] private int _doorId; + private int _doorId; /// Gives the door a unique ID on load. private void Awake() From fca7461a911848da67990fbc5eea263b95bad58d Mon Sep 17 00:00:00 2001 From: Luka Date: Sat, 20 Apr 2024 21:39:42 +0200 Subject: [PATCH 4/8] fix: place door in the center of the door opening --- aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index d1dfdb07..157f4604 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -128,13 +128,15 @@ private void PlaceDoors(int x, int y, Room room) if (room.CanConnectInDirection(direction)) continue; Vector3 roomPosition = new(x * _tileSizeX, 0, y * _tileSizeY); + float doorDepthExtend = _doorPrefab.GetComponent().bounds.extents.z; + float doorDistanceFromRoomCenter = (_tileSizeX / 2f) - doorDepthExtend; Quaternion roomRotation = Quaternion.Euler(0, room.Rotation * _tileRotation, 0); (Vector3 relativeDoorPosition, Quaternion relativeDoorRotation) = direction switch { - 0 => (new Vector3(-_tileSizeX / 2f, 0, 0), Quaternion.Euler(0, -_tileRotation, 0)), - 1 => (new Vector3(0, 0, _tileSizeY / 2f), Quaternion.identity), - 2 => (new Vector3(_tileSizeX / 2f, 0, 0), Quaternion.Euler(0, _tileRotation, 0)), - 3 => (new Vector3(0, 0, -_tileSizeY / 2f), Quaternion.Euler(0, 2f * _tileRotation, 0)), + 0 => (new Vector3(-doorDistanceFromRoomCenter, 0, 0), Quaternion.Euler(0, -_tileRotation, 0)), + 1 => (new Vector3(0, 0, doorDistanceFromRoomCenter), Quaternion.identity), + 2 => (new Vector3(doorDistanceFromRoomCenter, 0, 0), Quaternion.Euler(0, _tileRotation, 0)), + 3 => (new Vector3(0, 0, -doorDistanceFromRoomCenter), Quaternion.Euler(0, 2f * _tileRotation, 0)), _ => throw new UnityException("Invalid direction when placing door") }; Vector3 doorPosition = roomPosition + relativeDoorPosition; From f93c45a59d841ee115d5ed8a7f702d30acc7155b Mon Sep 17 00:00:00 2001 From: Luka Date: Wed, 24 Apr 2024 13:53:01 +0200 Subject: [PATCH 5/8] style: improve the readability of `PlaceDoors` --- aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 688d7356..9058c901 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -122,11 +122,13 @@ private void PlaceDoors(int x, int y, Room room) { foreach (Direction direction in room.ConnectingDirections) { + // # Calculate where the door should be placed + Vector3 roomPosition = new(x * _tileSizeX, 0, y * _tileSizeY); + // Get (half of) the width of the door model float doorDepthExtend = _doorPrefab.GetComponent().bounds.extents.z; + // Calculate the distance from the room center to where the door should be placed float doorDistanceFromRoomCenter = (_tileSizeX / 2f) - doorDepthExtend; - Quaternion roomRotation = Quaternion.Euler(0, room.Facing.RotationDegrees(), 0); - Quaternion relativeDoorRotation = Quaternion.Euler(0, direction.RotateLeft().RotationDegrees(), 0); Vector3 relativeDoorPosition = direction switch { North => new Vector3(-doorDistanceFromRoomCenter, 0, 0), @@ -136,8 +138,17 @@ private void PlaceDoors(int x, int y, Room room) _ => throw new UnityException("Invalid direction when placing door") }; Vector3 doorPosition = roomPosition + relativeDoorPosition; + + // # Calculate the rotation the door should have + + Quaternion roomRotation = Quaternion.Euler(0, room.Facing.RotationDegrees(), 0); + // The `RotateLeft` here is because the rotation of the grid and the rotation of the door model do not + // line up + Quaternion relativeDoorRotation = Quaternion.Euler(0, direction.RotateLeft().RotationDegrees(), 0); Quaternion doorRotation = roomRotation * relativeDoorRotation; + // # Spawn the door + _ = Instantiate(_doorPrefab, doorPosition, doorRotation, transform); } } From 2aac621338f10917ec176a0af35606b7bbd826cc Mon Sep 17 00:00:00 2001 From: Luka Date: Wed, 24 Apr 2024 15:25:13 +0200 Subject: [PATCH 6/8] perf: move code out of a loop --- aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 9058c901..dc2e1468 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -120,15 +120,18 @@ private void PlaceTile(int x, int y, Tile tile) // ReSharper disable once SuggestBaseTypeForParameter private void PlaceDoors(int x, int y, Room room) { + Vector3 roomPosition = new(x * _tileSizeX, 0, y * _tileSizeY); + // Get (half of) the depth of the door model + float doorDepthExtend = _doorPrefab.GetComponent().bounds.extents.z; + // Calculate the distance from the room center to where a door should be placed + float doorDistanceFromRoomCenter = (_tileSizeX / 2f) - doorDepthExtend; + + Quaternion roomRotation = Quaternion.Euler(0, room.Facing.RotationDegrees(), 0); + foreach (Direction direction in room.ConnectingDirections) { // # Calculate where the door should be placed - Vector3 roomPosition = new(x * _tileSizeX, 0, y * _tileSizeY); - // Get (half of) the width of the door model - float doorDepthExtend = _doorPrefab.GetComponent().bounds.extents.z; - // Calculate the distance from the room center to where the door should be placed - float doorDistanceFromRoomCenter = (_tileSizeX / 2f) - doorDepthExtend; Vector3 relativeDoorPosition = direction switch { North => new Vector3(-doorDistanceFromRoomCenter, 0, 0), @@ -141,7 +144,6 @@ private void PlaceDoors(int x, int y, Room room) // # Calculate the rotation the door should have - Quaternion roomRotation = Quaternion.Euler(0, room.Facing.RotationDegrees(), 0); // The `RotateLeft` here is because the rotation of the grid and the rotation of the door model do not // line up Quaternion relativeDoorRotation = Quaternion.Euler(0, direction.RotateLeft().RotationDegrees(), 0); From f7b3b5863b36a2031f3c68bfe23a01aae1ad8cb5 Mon Sep 17 00:00:00 2001 From: Luka Date: Fri, 26 Apr 2024 17:03:55 +0200 Subject: [PATCH 7/8] chore: clarify the north direction in `PlaceDoors` --- aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 16818e85..37d12aa7 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -193,6 +193,7 @@ private void PlaceDoors(int x, int z, Room room) { // # Calculate where the door should be placed + // North is in the negative x direction Vector3 relativeDoorPosition = direction switch { North => new Vector3(-doorDistanceFromRoomCenter, 0, 0), From 7edbd38b655686c0e008d36f43f30df01efcf0c0 Mon Sep 17 00:00:00 2001 From: Luka Date: Fri, 26 Apr 2024 17:37:16 +0200 Subject: [PATCH 8/8] perf: only call `_doorPrefab.GetComponent` once --- aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs index 37d12aa7..de89d3b7 100644 --- a/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs +++ b/aplib.net-demo/Assets/Scripts/WFC/GridPlacer.cs @@ -76,10 +76,20 @@ public class GridPlacer : MonoBehaviour /// private Random _random = new(); + /// + /// The `Renderer` component for the door prefab. + /// + /// Getting a reference to the component is expensive, so we only want to do it once. + private Renderer _doorRenderer; + /// /// This contains the whole 'pipeline' of level generation, including initialising the grid and placing teleporters. /// - public void Awake() => MakeScene(); + public void Awake() + { + _doorRenderer = _doorPrefab.GetComponent(); + MakeScene(); + } /// /// Makes the scene. @@ -183,7 +193,7 @@ private void PlaceDoors(int x, int z, Room room) { Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); // Get (half of) the depth of the door model - float doorDepthExtend = _doorPrefab.GetComponent().bounds.extents.z; + float doorDepthExtend = _doorRenderer.bounds.extents.z; // Calculate the distance from the room center to where a door should be placed float doorDistanceFromRoomCenter = (_tileSizeX / 2f) - doorDepthExtend;