Improve maze start/end placement with dead-end detection
Refactored PlaceStartAndEnd to intelligently place start and end points at dead ends using random selection and distance-based fallbacks. Added EnforceSingleConnection to ensure start/end points have exactly one connection, compatible with U-turn prefabs. Improved MazeReworkSpawner with object hierarchy grouping (Floors, Categories) and made RefreshSingleCell public. Updated maze config and cleaned up scene hierarchy.
This commit is contained in:
5
.idea/.idea.BABA_YAGA/.idea/workspace.xml
generated
5
.idea/.idea.BABA_YAGA/.idea/workspace.xml
generated
@@ -12,13 +12,10 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="d308d1cb-09fc-4331-ba20-00f7b43d1576" name="Changes" comment="">
|
<list default="true" id="d308d1cb-09fc-4331-ba20-00f7b43d1576" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Materials/Red 4.mat" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Materials/Red 4.mat" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Prefabs/Environment/Hall/End.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Prefabs/Environment/Hall/End.prefab" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Prefabs/Environment/Room/Stair.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Prefabs/Environment/Room/Stair.prefab" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Presets/MazeRework.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Presets/MazeRework.asset" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Presets/MazeRework.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Presets/MazeRework.asset" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkGenerator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkGenerator.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkGenerator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkGenerator.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkManager.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkSpawner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Baba_yaga/GameSetup/MazeRework/MazeReworkSpawner.cs" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
@@ -1,5 +1,104 @@
|
|||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1001 &1697779104191720984
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 1895562424247967253}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 3377181292992421420, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Magic circle 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 3220440682565326704, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 7916597384863477479}
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
--- !u!4 &4039140197731819905 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 3423388300971593625, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1697779104191720984}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &4269118487993547112 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 3220440682565326704, guid: 48c5715f9603c3842a353516a8baefbb, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1697779104191720984}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &7916597384863477479
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4269118487993547112}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalAdditionalLightData
|
||||||
|
m_UsePipelineSettings: 1
|
||||||
|
m_AdditionalLightsShadowResolutionTier: 2
|
||||||
|
m_CustomShadowLayers: 0
|
||||||
|
m_LightCookieSize: {x: 1, y: 1}
|
||||||
|
m_LightCookieOffset: {x: 0, y: 0}
|
||||||
|
m_SoftShadowQuality: 0
|
||||||
|
m_RenderingLayersMask:
|
||||||
|
serializedVersion: 0
|
||||||
|
m_Bits: 1
|
||||||
|
m_ShadowRenderingLayersMask:
|
||||||
|
serializedVersion: 0
|
||||||
|
m_Bits: 1
|
||||||
|
m_Version: 4
|
||||||
|
m_LightLayerMask: 1
|
||||||
|
m_ShadowLayerMask: 1
|
||||||
|
m_RenderingLayers: 1
|
||||||
|
m_ShadowRenderingLayers: 1
|
||||||
--- !u!1001 &2818225372865226580
|
--- !u!1001 &2818225372865226580
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -10,7 +109,7 @@ PrefabInstance:
|
|||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 817386962124533542, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
- target: {fileID: 817386962124533542, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: U-Turn
|
value: End
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4418658990435547457, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
- target: {fileID: 4418658990435547457, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
@@ -54,6 +153,14 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 4418658990435547457, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 4039140197731819905}
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
||||||
|
--- !u!4 &1895562424247967253 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 4418658990435547457, guid: f147133c37d69764abf51ce8374aed85, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2818225372865226580}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ MonoBehaviour:
|
|||||||
m_Name: MazeRework
|
m_Name: MazeRework
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Baba_yaga.GameSetup.MazeRework.MazeReworkConfig
|
m_EditorClassIdentifier: Assembly-CSharp::Baba_yaga.GameSetup.MazeRework.MazeReworkConfig
|
||||||
algorithm: 0
|
algorithm: 0
|
||||||
width: 21
|
width: 13
|
||||||
depth: 21
|
depth: 13
|
||||||
useRandomSeed: 1
|
useRandomSeed: 1
|
||||||
seed: 1337
|
seed: 1989
|
||||||
startLocation: {x: 1, y: 1}
|
startLocation: {x: 1, y: 1}
|
||||||
generateRooms: 0
|
generateRooms: 1
|
||||||
roomCount: 378
|
roomCount: 2
|
||||||
minRoomSize: {x: 3, y: 3}
|
minRoomSize: {x: 3, y: 3}
|
||||||
maxRoomSize: {x: 5, y: 5}
|
maxRoomSize: {x: 5, y: 5}
|
||||||
extraRoomDoorChance: 1
|
extraRoomDoorChance: 1
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 786488}
|
m_GameObject: {fileID: 786488}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 3.5546, y: 7, z: 4.39807}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -312,10 +312,9 @@ Transform:
|
|||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 828777830}
|
- {fileID: 1896629832}
|
||||||
|
- {fileID: 1119991880}
|
||||||
- {fileID: 1768466479}
|
- {fileID: 1768466479}
|
||||||
- {fileID: 1170687049}
|
|
||||||
- {fileID: 1100452909}
|
|
||||||
m_Father: {fileID: 656189834}
|
m_Father: {fileID: 656189834}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &390274364 stripped
|
--- !u!1 &390274364 stripped
|
||||||
@@ -642,54 +641,6 @@ Transform:
|
|||||||
- {fileID: 747234400}
|
- {fileID: 747234400}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &828777828
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 828777830}
|
|
||||||
- component: {fileID: 828777829}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: MazeController
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 0
|
|
||||||
--- !u!114 &828777829
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 828777828}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: f30df611110713742ab984f5bead5d88, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.GameSetup.Maze.MazeRenderer
|
|
||||||
visualProfile: {fileID: 11400000, guid: 15b745b0bb979b84ea937c679ee0f1ed, type: 2}
|
|
||||||
floorHeight: 3.5
|
|
||||||
currentAnimationType: 1
|
|
||||||
--- !u!4 &828777830
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 828777828}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 7, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children:
|
|
||||||
- {fileID: 1052820475}
|
|
||||||
m_Father: {fileID: 346257372}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!224 &942362353 stripped
|
--- !u!224 &942362353 stripped
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_CorrespondingSourceObject: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3}
|
m_CorrespondingSourceObject: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3}
|
||||||
@@ -700,102 +651,6 @@ RectTransform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3}
|
m_CorrespondingSourceObject: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3}
|
||||||
m_PrefabInstance: {fileID: 1420512788}
|
m_PrefabInstance: {fileID: 1420512788}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1 &1052820474
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1052820475}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Container
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &1052820475
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1052820474}
|
|
||||||
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: 828777830}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &1100452908
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1100452909}
|
|
||||||
- component: {fileID: 1100452910}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: MazeManager
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 0
|
|
||||||
--- !u!4 &1100452909
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1100452908}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 7, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 346257372}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &1100452910
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1100452908}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 3607adabe0c29c34591af73b414eb17a, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.GameSetup.Maze.MazeManager
|
|
||||||
mazes:
|
|
||||||
- scale: 1
|
|
||||||
- scale: 1
|
|
||||||
floorHeight: 1.5
|
|
||||||
connectionsPerFloor: 2
|
|
||||||
selectedAlgorithm: 0
|
|
||||||
width: 30
|
|
||||||
depth: 30
|
|
||||||
animateGeneration: 1
|
|
||||||
generationSpeed: 50
|
|
||||||
cellAnimationType: 1
|
|
||||||
mazeRenderer: {fileID: 828777829}
|
|
||||||
generateRooms: 1
|
|
||||||
numberOfRooms: 2
|
|
||||||
minRoomSize: {x: 2, y: 2}
|
|
||||||
maxRoomSize: {x: 4, y: 4}
|
|
||||||
mazeContainer: {fileID: 1052820475}
|
|
||||||
straightManHoleLadder: {fileID: 919132149155446097, guid: bea94d2de5b89ea4cba759f4a73149d4, type: 3}
|
|
||||||
straightManHoleUp: {fileID: 919132149155446097, guid: df993452c905ccd4a8db16303509c4aa, type: 3}
|
|
||||||
deadendManHoleLadder: {fileID: 919132149155446097, guid: c7b8e72ff8d936143a810e1baa494428, type: 3}
|
|
||||||
deadendManHoleUp: {fileID: 919132149155446097, guid: 1e0fe08755c202644ab57e3ecb75ea61, type: 3}
|
|
||||||
--- !u!1 &1119991879
|
--- !u!1 &1119991879
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -806,7 +661,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1119991880}
|
- component: {fileID: 1119991880}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameObject
|
m_Name: MazeContainer
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@@ -820,126 +675,13 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1119991879}
|
m_GameObject: {fileID: 1119991879}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0.1, z: 0}
|
m_LocalPosition: {x: 0, y: 0.1, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &1170687048
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1170687049}
|
|
||||||
- component: {fileID: 1170687052}
|
|
||||||
- component: {fileID: 1170687051}
|
|
||||||
- component: {fileID: 1170687050}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Update plan
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &1170687049
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1170687048}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 393.9129, y: 5, z: 251.7189}
|
|
||||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 346257372}
|
m_Father: {fileID: 346257372}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!64 &1170687050
|
|
||||||
MeshCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1170687048}
|
|
||||||
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: 5
|
|
||||||
m_Convex: 0
|
|
||||||
m_CookingOptions: 30
|
|
||||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
--- !u!23 &1170687051
|
|
||||||
MeshRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1170687048}
|
|
||||||
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_RayTracingAccelStructBuildFlagsOverride: 0
|
|
||||||
m_RayTracingAccelStructBuildFlags: 1
|
|
||||||
m_SmallMeshCulling: 1
|
|
||||||
m_ForceMeshLod: -1
|
|
||||||
m_MeshLodSelectionBias: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 2100000, guid: e2e2684e969402049b87d7f81417c603, 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_GlobalIlluminationMeshLod: 0
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_MaskInteraction: 0
|
|
||||||
m_AdditionalVertexStreams: {fileID: 0}
|
|
||||||
--- !u!33 &1170687052
|
|
||||||
MeshFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1170687048}
|
|
||||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
--- !u!1001 &1216657555
|
--- !u!1001 &1216657555
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1344,11 +1086,11 @@ Transform:
|
|||||||
m_GameObject: {fileID: 1896629830}
|
m_GameObject: {fileID: 1896629830}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -33.08711, y: 2.5, z: -1.2811}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 346257372}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1896629833
|
--- !u!114 &1896629833
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
@@ -1560,5 +1302,3 @@ SceneRoots:
|
|||||||
- {fileID: 656189834}
|
- {fileID: 656189834}
|
||||||
- {fileID: 1945212510}
|
- {fileID: 1945212510}
|
||||||
- {fileID: 1216657555}
|
- {fileID: 1216657555}
|
||||||
- {fileID: 1896629832}
|
|
||||||
- {fileID: 1119991880}
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
CarveLoops(grid, rng, width, depth);
|
CarveLoops(grid, rng, width, depth);
|
||||||
|
|
||||||
// 8. Place Start & End points
|
// 8. Place Start & End points
|
||||||
PlaceStartAndEnd(grid, rooms, width, depth, forcedStart, forcedDirection, null);
|
PlaceStartAndEnd(grid, rooms, width, depth, rng, forcedStart, forcedDirection, null);
|
||||||
|
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
|
|
||||||
// 8. Place Start & End points (no highlighting needed for this step in animation)
|
// 8. Place Start & End points (no highlighting needed for this step in animation)
|
||||||
currentPhase = MazeAnimationPhase.StartEnd;
|
currentPhase = MazeAnimationPhase.StartEnd;
|
||||||
PlaceStartAndEnd(grid, rooms, width, depth, forcedStart, forcedDirection, recordNoHighlight);
|
PlaceStartAndEnd(grid, rooms, width, depth, rng, forcedStart, forcedDirection, recordNoHighlight);
|
||||||
|
|
||||||
return (grid, history);
|
return (grid, history);
|
||||||
}
|
}
|
||||||
@@ -469,81 +469,149 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlaceStartAndEnd(MazeReworkCellType[,] grid, List<Room> rooms, int width, int depth, Vector2Int? forcedStart, Vector2Int? forcedDirection,
|
private void PlaceStartAndEnd(MazeReworkCellType[,] grid, List<Room> rooms, int width, int depth, System.Random rng, Vector2Int? forcedStart, Vector2Int? forcedDirection,
|
||||||
Action<int, int, MazeReworkCellType> onCellChanged = null)
|
Action<int, int, MazeReworkCellType> onCellChanged = null)
|
||||||
{
|
{
|
||||||
Vector2Int startPt;
|
Vector2Int startPt = new Vector2Int(-1, -1);
|
||||||
|
|
||||||
if (forcedStart.HasValue)
|
if (forcedStart.HasValue)
|
||||||
{
|
{
|
||||||
startPt = forcedStart.Value;
|
startPt = forcedStart.Value;
|
||||||
}
|
}
|
||||||
else if (rooms != null && rooms.Count > 0)
|
|
||||||
{
|
|
||||||
startPt = rooms[0].GetCenter();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sx = _config.startLocation.x, sz = _config.startLocation.y;
|
startPt = FindDeadEnd(grid, width, depth, rng, new Vector2Int(-1, -1));
|
||||||
EnsureValidOddCoordinates(width, depth, ref sx, ref sz);
|
if (startPt.x == -1)
|
||||||
startPt = new Vector2Int(sx, sz);
|
{
|
||||||
|
// Fallback to config start if no corridors exist
|
||||||
|
int sx = _config.startLocation.x, sz = _config.startLocation.y;
|
||||||
|
EnsureValidOddCoordinates(width, depth, ref sx, ref sz);
|
||||||
|
startPt = new Vector2Int(sx, sz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grid[startPt.x, startPt.y] = MazeReworkCellType.Start;
|
grid[startPt.x, startPt.y] = MazeReworkCellType.Start;
|
||||||
onCellChanged?.Invoke(startPt.x, startPt.y, MazeReworkCellType.Start);
|
onCellChanged?.Invoke(startPt.x, startPt.y, MazeReworkCellType.Start);
|
||||||
|
|
||||||
Vector2Int endPt = startPt;
|
Vector2Int endPt = FindDeadEnd(grid, width, depth, rng, startPt);
|
||||||
if (rooms != null && rooms.Count > 0)
|
|
||||||
{
|
|
||||||
var endRoom = rooms[rooms.Count - 1];
|
|
||||||
endPt = endRoom.GetCenter();
|
|
||||||
if (endPt == startPt && rooms.Count > 1) { endPt = rooms[1].GetCenter(); }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int ex = width - 2, ez = depth - 2;
|
|
||||||
EnsureValidOddCoordinates(width, depth, ref ex, ref ez);
|
|
||||||
if (grid[ex, ez] == MazeReworkCellType.Wall)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
for (int r = 1; r < Mathf.Max(width, depth) && !found; r++)
|
|
||||||
for (int ddx = -r; ddx <= r && !found; ddx++)
|
|
||||||
for (int ddz = -r; ddz <= r && !found; ddz++)
|
|
||||||
{
|
|
||||||
int tx = ex + ddx, tz = ez + ddz;
|
|
||||||
if (tx >= 0 && tx < width && tz >= 0 && tz < depth && IsPathCell(grid[tx, tz]))
|
|
||||||
{ ex = tx; ez = tz; found = true; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endPt = new Vector2Int(ex, ez);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endPt == startPt)
|
if (endPt.x == -1)
|
||||||
{
|
{
|
||||||
// Fallback: find any path cell that isn't the start point, starting from the opposite corner
|
// Fallback: just pick the furthest corridor cell from startPt
|
||||||
int ex = 1, ez = 1;
|
endPt = FindFurthestCorridor(grid, width, depth, startPt);
|
||||||
bool found = false;
|
|
||||||
for (int r = 0; r < Mathf.Max(width, depth) && !found; r++)
|
if (endPt.x == -1)
|
||||||
{
|
{
|
||||||
for (int ddx = -r; ddx <= r && !found; ddx++)
|
// Extreme fallback
|
||||||
{
|
int ex = width - 2, ez = depth - 2;
|
||||||
for (int ddz = -r; ddz <= r && !found; ddz++)
|
EnsureValidOddCoordinates(width, depth, ref ex, ref ez);
|
||||||
{
|
endPt = new Vector2Int(ex, ez);
|
||||||
int tx = ex + ddx, tz = ez + ddz;
|
|
||||||
if (tx >= 0 && tx < width && tz >= 0 && tz < depth && IsPathCell(grid[tx, tz]))
|
|
||||||
{
|
|
||||||
if (tx != startPt.x || tz != startPt.y)
|
|
||||||
{
|
|
||||||
ex = tx; ez = tz; found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
endPt = new Vector2Int(ex, ez);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grid[endPt.x, endPt.y] = MazeReworkCellType.End;
|
grid[endPt.x, endPt.y] = MazeReworkCellType.End;
|
||||||
onCellChanged?.Invoke(endPt.x, endPt.y, MazeReworkCellType.End);
|
onCellChanged?.Invoke(endPt.x, endPt.y, MazeReworkCellType.End);
|
||||||
|
|
||||||
|
// To guarantee they fit the U-turn prefab, enforce a single connection on them
|
||||||
|
// (this only affects Corridors now, so it will never ruin a Room!)
|
||||||
|
EnforceSingleConnection(grid, startPt.x, startPt.y, forcedDirection);
|
||||||
|
EnforceSingleConnection(grid, endPt.x, endPt.y, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2Int FindDeadEnd(MazeReworkCellType[,] grid, int width, int depth, System.Random rng, Vector2Int exclude)
|
||||||
|
{
|
||||||
|
List<Vector2Int> deadEnds = new List<Vector2Int>();
|
||||||
|
List<Vector2Int> corridors = new List<Vector2Int>();
|
||||||
|
|
||||||
|
for (int z = 1; z < depth - 1; z++)
|
||||||
|
{
|
||||||
|
for (int x = 1; x < width - 1; x++)
|
||||||
|
{
|
||||||
|
if (grid[x, z] == MazeReworkCellType.Corridor)
|
||||||
|
{
|
||||||
|
if (x == exclude.x && z == exclude.y) continue;
|
||||||
|
corridors.Add(new Vector2Int(x, z));
|
||||||
|
|
||||||
|
int connections = 0;
|
||||||
|
if (IsPathCell(grid[x, z + 1])) connections++;
|
||||||
|
if (IsPathCell(grid[x + 1, z])) connections++;
|
||||||
|
if (IsPathCell(grid[x, z - 1])) connections++;
|
||||||
|
if (IsPathCell(grid[x - 1, z])) connections++;
|
||||||
|
|
||||||
|
if (connections == 1)
|
||||||
|
{
|
||||||
|
deadEnds.Add(new Vector2Int(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deadEnds.Count > 0) return deadEnds[rng.Next(deadEnds.Count)];
|
||||||
|
if (corridors.Count > 0) return corridors[rng.Next(corridors.Count)];
|
||||||
|
return new Vector2Int(-1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2Int FindFurthestCorridor(MazeReworkCellType[,] grid, int width, int depth, Vector2Int from)
|
||||||
|
{
|
||||||
|
Vector2Int best = new Vector2Int(-1, -1);
|
||||||
|
float maxDist = -1f;
|
||||||
|
|
||||||
|
for (int z = 1; z < depth - 1; z++)
|
||||||
|
{
|
||||||
|
for (int x = 1; x < width - 1; x++)
|
||||||
|
{
|
||||||
|
if (grid[x, z] == MazeReworkCellType.Corridor)
|
||||||
|
{
|
||||||
|
if (x == from.x && z == from.y) continue;
|
||||||
|
float dist = Vector2Int.Distance(new Vector2Int(x, z), from);
|
||||||
|
if (dist > maxDist)
|
||||||
|
{
|
||||||
|
maxDist = dist;
|
||||||
|
best = new Vector2Int(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnforceSingleConnection(MazeReworkCellType[,] grid, int cx, int cz, Vector2Int? forcedDirection)
|
||||||
|
{
|
||||||
|
int width = grid.GetLength(0);
|
||||||
|
int depth = grid.GetLength(1);
|
||||||
|
|
||||||
|
Vector2Int[] dirs = new Vector2Int[]
|
||||||
|
{
|
||||||
|
new Vector2Int(0, 1),
|
||||||
|
new Vector2Int(1, 0),
|
||||||
|
new Vector2Int(0, -1),
|
||||||
|
new Vector2Int(-1, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
bool foundFirst = false;
|
||||||
|
|
||||||
|
if (forcedDirection.HasValue)
|
||||||
|
{
|
||||||
|
int fx = cx + forcedDirection.Value.x;
|
||||||
|
int fz = cz + forcedDirection.Value.y;
|
||||||
|
if (fx >= 0 && fx < width && fz >= 0 && fz < depth && IsPathCell(grid[fx, fz]))
|
||||||
|
{
|
||||||
|
foundFirst = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var d in dirs)
|
||||||
|
{
|
||||||
|
int nx = cx + d.x;
|
||||||
|
int nz = cz + d.y;
|
||||||
|
if (nx >= 0 && nx < width && nz >= 0 && nz < depth && IsPathCell(grid[nx, nz]))
|
||||||
|
{
|
||||||
|
if (forcedDirection.HasValue && d == forcedDirection.Value) continue;
|
||||||
|
|
||||||
|
if (!foundFirst) foundFirst = true;
|
||||||
|
else grid[nx, nz] = MazeReworkCellType.Wall;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshSingleCell(MazeReworkCellType[,] grid, MazeCellHighlight[,] highlights, int x, int z, int width, int depth, float yOffset, Transform container)
|
public void RefreshSingleCell(MazeReworkCellType[,] grid, MazeCellHighlight[,] highlights, int x, int z, int width, int depth, float yOffset, Transform container)
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= width || z < 0 || z >= depth) return;
|
if (x < 0 || x >= width || z < 0 || z >= depth) return;
|
||||||
|
|
||||||
@@ -179,6 +179,10 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
MazeReworkCellType type = grid[x, z];
|
MazeReworkCellType type = grid[x, z];
|
||||||
MazeCellHighlight hType = highlights != null ? highlights[x, z] : MazeCellHighlight.None;
|
MazeCellHighlight hType = highlights != null ? highlights[x, z] : MazeCellHighlight.None;
|
||||||
|
|
||||||
|
Transform rootContainer = container != null ? container : transform;
|
||||||
|
int floorIndex = Mathf.RoundToInt(yOffset / (stairHeightOffset > 0 ? stairHeightOffset : 5f)); // Approximation for group naming
|
||||||
|
Transform floorContainer = GetOrCreateGroup(rootContainer, $"Floor_{yOffset}");
|
||||||
|
|
||||||
// 1. Process Highlights
|
// 1. Process Highlights
|
||||||
if (_spawnedHighlights.TryGetValue(pos, out GameObject existingHighlight))
|
if (_spawnedHighlights.TryGetValue(pos, out GameObject existingHighlight))
|
||||||
{
|
{
|
||||||
@@ -198,8 +202,9 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
|
|
||||||
if (hPrefab != null)
|
if (hPrefab != null)
|
||||||
{
|
{
|
||||||
|
Transform highlightContainer = GetOrCreateGroup(floorContainer, "Highlights");
|
||||||
Vector3 localPos = new Vector3(x * spacing, yOffset, z * spacing);
|
Vector3 localPos = new Vector3(x * spacing, yOffset, z * spacing);
|
||||||
GameObject spawnedH = Instantiate(hPrefab, container != null ? container : transform);
|
GameObject spawnedH = Instantiate(hPrefab, highlightContainer);
|
||||||
spawnedH.transform.localPosition = localPos;
|
spawnedH.transform.localPosition = localPos;
|
||||||
spawnedH.name = $"Highlight_{hType}_{x}_{z}";
|
spawnedH.name = $"Highlight_{hType}_{x}_{z}";
|
||||||
// Highlights should pop instantly without animation since they are short-lived cursors
|
// Highlights should pop instantly without animation since they are short-lived cursors
|
||||||
@@ -297,8 +302,17 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
else DestroyImmediate(existingData.Instance);
|
else DestroyImmediate(existingData.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine category for clean grouping
|
||||||
|
string categoryName = "Paths";
|
||||||
|
if (type == MazeReworkCellType.Start || type == MazeReworkCellType.End || type == MazeReworkCellType.StairsUp || type == MazeReworkCellType.StairsDown)
|
||||||
|
categoryName = "Special";
|
||||||
|
else if (isPreviewMode)
|
||||||
|
categoryName = "Preview";
|
||||||
|
|
||||||
|
Transform categoryContainer = GetOrCreateGroup(floorContainer, categoryName);
|
||||||
|
|
||||||
Vector3 localPosition = new Vector3(x * spacing, yOffset, z * spacing);
|
Vector3 localPosition = new Vector3(x * spacing, yOffset, z * spacing);
|
||||||
GameObject spawnedObj = Instantiate(targetPrefab, container != null ? container : transform);
|
GameObject spawnedObj = Instantiate(targetPrefab, categoryContainer);
|
||||||
spawnedObj.transform.localPosition = localPosition;
|
spawnedObj.transform.localPosition = localPosition;
|
||||||
spawnedObj.transform.localRotation = Quaternion.Euler(0f, targetRot, 0f);
|
spawnedObj.transform.localRotation = Quaternion.Euler(0f, targetRot, 0f);
|
||||||
spawnedObj.name = $"{targetName}_{x}_{z}";
|
spawnedObj.name = $"{targetName}_{x}_{z}";
|
||||||
@@ -307,6 +321,20 @@ namespace Baba_yaga.GameSetup.MazeRework
|
|||||||
_spawnedGridCells[pos] = new SpawnedCellData { Instance = spawnedObj, Prefab = targetPrefab, Rotation = targetRot };
|
_spawnedGridCells[pos] = new SpawnedCellData { Instance = spawnedObj, Prefab = targetPrefab, Rotation = targetRot };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Transform GetOrCreateGroup(Transform parent, string groupName)
|
||||||
|
{
|
||||||
|
if (parent == null) return null;
|
||||||
|
Transform group = parent.Find(groupName);
|
||||||
|
if (group == null)
|
||||||
|
{
|
||||||
|
GameObject go = new GameObject(groupName);
|
||||||
|
go.transform.SetParent(parent, false);
|
||||||
|
go.transform.localPosition = Vector3.zero;
|
||||||
|
group = go.transform;
|
||||||
|
}
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
private (GameObject, float) GetModularPrefabAndRotation(MazeReworkCellType[,] grid, int x, int z, int width, int depth)
|
private (GameObject, float) GetModularPrefabAndRotation(MazeReworkCellType[,] grid, int x, int z, int width, int depth)
|
||||||
{
|
{
|
||||||
bool top = IsPath(grid, x, z + 1, width, depth);
|
bool top = IsPath(grid, x, z + 1, width, depth);
|
||||||
|
|||||||
Reference in New Issue
Block a user