├── .gitattributes ├── .gitignore ├── .vsconfig ├── Assets ├── Examples.meta ├── Examples │ ├── Prefabs.meta │ ├── Prefabs │ │ ├── Agent.prefab │ │ ├── Agent.prefab.meta │ │ ├── Flow.prefab │ │ ├── Flow.prefab.meta │ │ ├── Materials.meta │ │ ├── Materials │ │ │ ├── AgentMaterial.mat │ │ │ ├── AgentMaterial.mat.meta │ │ │ ├── FlowMaterial.mat │ │ │ └── FlowMaterial.mat.meta │ │ ├── Wall.prefab │ │ └── Wall.prefab.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── 1_GraphExample.unity │ │ ├── 1_GraphExample.unity.meta │ │ ├── 2_AgentExample.unity │ │ ├── 2_AgentExample.unity.meta │ │ ├── 3_TerrainExample.unity │ │ ├── 3_TerrainExample.unity.meta │ │ ├── 4_StressTestExample.unity │ │ ├── 4_StressTestExample.unity.meta │ │ ├── 5_ChangingStressTestExample.unity │ │ ├── 5_ChangingStressTestExample.unity.meta │ │ ├── Subscenes.meta │ │ └── Subscenes │ │ │ ├── SubScene.unity │ │ │ └── SubScene.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Authors.meta │ │ ├── Authors │ │ │ ├── AgentAuthor.cs │ │ │ ├── AgentAuthor.cs.meta │ │ │ ├── FlowAuthor.cs │ │ │ ├── FlowAuthor.cs.meta │ │ │ ├── PrefabsAuthor.cs │ │ │ ├── PrefabsAuthor.cs.meta │ │ │ ├── WallAuthor.cs │ │ │ └── WallAuthor.cs.meta │ │ ├── Components.meta │ │ ├── Components │ │ │ ├── AgentData.cs │ │ │ ├── AgentData.cs.meta │ │ │ ├── ColorOverride.cs │ │ │ ├── ColorOverride.cs.meta │ │ │ ├── LevelSetup.cs │ │ │ ├── LevelSetup.cs.meta │ │ │ ├── PrefabLinks.cs │ │ │ ├── PrefabLinks.cs.meta │ │ │ ├── StressTestData.cs │ │ │ ├── StressTestData.cs.meta │ │ │ ├── WallData.cs │ │ │ └── WallData.cs.meta │ │ ├── Level.meta │ │ ├── Level │ │ │ ├── DemoLevel.cs │ │ │ ├── DemoLevel.cs.meta │ │ │ ├── LevelGeneration.cs │ │ │ ├── LevelGeneration.cs.meta │ │ │ ├── SpawnAgentCommand.cs │ │ │ ├── SpawnAgentCommand.cs.meta │ │ │ ├── TerrainType.cs │ │ │ ├── TerrainType.cs.meta │ │ │ ├── TravelType.cs │ │ │ ├── TravelType.cs.meta │ │ │ ├── Visualisation.cs │ │ │ ├── Visualisation.cs.meta │ │ │ ├── VisualiseMode.cs │ │ │ └── VisualiseMode.cs.meta │ │ ├── SceneManagers.meta │ │ ├── SceneManagers │ │ │ ├── AgentExampleManager.cs │ │ │ ├── AgentExampleManager.cs.meta │ │ │ ├── ChangingStressTextExampleManager.cs │ │ │ ├── ChangingStressTextExampleManager.cs.meta │ │ │ ├── GraphExampleManager.cs │ │ │ ├── GraphExampleManager.cs.meta │ │ │ ├── MovingWall.cs │ │ │ ├── MovingWall.cs.meta │ │ │ ├── StressTextExampleManager.cs │ │ │ ├── StressTextExampleManager.cs.meta │ │ │ ├── TerrainExampleManager.cs │ │ │ └── TerrainExampleManager.cs.meta │ │ ├── Systems.meta │ │ └── Systems │ │ │ ├── LevelSetupSystem.cs │ │ │ ├── LevelSetupSystem.cs.meta │ │ │ ├── LevelUpdateSystem.cs │ │ │ ├── LevelUpdateSystem.cs.meta │ │ │ ├── MovementSystem.cs │ │ │ ├── MovementSystem.cs.meta │ │ │ ├── StressTestSystem.cs │ │ │ └── StressTestSystem.cs.meta │ ├── Settings.meta │ ├── Settings │ │ ├── Renderer2D.asset │ │ ├── Renderer2D.asset.meta │ │ ├── UniversalRP.asset │ │ ├── UniversalRP.asset.meta │ │ ├── UniversalRenderPipelineGlobalSettings.asset │ │ └── UniversalRenderPipelineGlobalSettings.asset.meta │ ├── Sprites.meta │ └── Sprites │ │ ├── agent.png │ │ ├── agent.png.meta │ │ ├── flow.png │ │ ├── flow.png.meta │ │ ├── wall.png │ │ └── wall.png.meta ├── FlowTiles.meta ├── FlowTiles │ ├── ECS.meta │ ├── ECS │ │ ├── Caches.meta │ │ ├── Caches │ │ │ ├── CacheKeys.cs │ │ │ ├── CacheKeys.cs.meta │ │ │ ├── CachedFlowField.cs │ │ │ ├── CachedFlowField.cs.meta │ │ │ ├── CachedPortalPath.cs │ │ │ ├── CachedPortalPath.cs.meta │ │ │ ├── CachedSightline.cs │ │ │ ├── CachedSightline.cs.meta │ │ │ ├── FlowCache.cs │ │ │ ├── FlowCache.cs.meta │ │ │ ├── FlowRequest.cs │ │ │ ├── FlowRequest.cs.meta │ │ │ ├── LineCache.cs │ │ │ ├── LineCache.cs.meta │ │ │ ├── LineRequest.cs │ │ │ ├── LineRequest.cs.meta │ │ │ ├── PathCache.cs │ │ │ ├── PathCache.cs.meta │ │ │ ├── PathRequest.cs │ │ │ └── PathRequest.cs.meta │ │ ├── Components.meta │ │ ├── Components │ │ │ ├── FlowData.cs │ │ │ ├── FlowData.cs.meta │ │ │ ├── FlowDebugData.cs │ │ │ ├── FlowDebugData.cs.meta │ │ │ ├── FlowDirection.cs │ │ │ ├── FlowDirection.cs.meta │ │ │ ├── FlowGoal.cs │ │ │ ├── FlowGoal.cs.meta │ │ │ ├── FlowPosition.cs │ │ │ ├── FlowPosition.cs.meta │ │ │ ├── FlowProgress.cs │ │ │ ├── FlowProgress.cs.meta │ │ │ ├── GlobalPathfindingData.cs │ │ │ ├── GlobalPathfindingData.cs.meta │ │ │ ├── InvalidPathData.cs │ │ │ ├── InvalidPathData.cs.meta │ │ │ ├── MissingFlowData.cs │ │ │ ├── MissingFlowData.cs.meta │ │ │ ├── MissingPathData.cs │ │ │ ├── MissingPathData.cs.meta │ │ │ ├── MissingSightlineData.cs │ │ │ ├── MissingSightlineData.cs.meta │ │ │ ├── PathSmoothingMode.cs │ │ │ └── PathSmoothingMode.cs.meta │ │ ├── Jobs.meta │ │ ├── Jobs │ │ │ ├── DebugPathsJob.cs │ │ │ ├── DebugPathsJob.cs.meta │ │ │ ├── FindFlowsJob.cs │ │ │ ├── FindFlowsJob.cs.meta │ │ │ ├── FindPathsJob.cs │ │ │ ├── FindPathsJob.cs.meta │ │ │ ├── FindSightlinesJob.cs │ │ │ ├── FindSightlinesJob.cs.meta │ │ │ ├── FollowPathsJob.cs │ │ │ ├── FollowPathsJob.cs.meta │ │ │ ├── InvalidatePathsJob.cs │ │ │ ├── InvalidatePathsJob.cs.meta │ │ │ ├── RebuildGraphJob.cs │ │ │ ├── RebuildGraphJob.cs.meta │ │ │ ├── RecalculateContinentsJob.cs │ │ │ ├── RecalculateContinentsJob.cs.meta │ │ │ ├── RequestFlowsJob.cs │ │ │ ├── RequestFlowsJob.cs.meta │ │ │ ├── RequestPathsJob.cs │ │ │ ├── RequestPathsJob.cs.meta │ │ │ ├── RequestSightlinesJob.cs │ │ │ └── RequestSightlinesJob.cs.meta │ │ ├── Systems.meta │ │ └── Systems │ │ │ ├── PathfindingSystem.cs │ │ │ └── PathfindingSystem.cs.meta │ ├── FlowFields.meta │ ├── FlowFields │ │ ├── FlowCalculator.cs │ │ ├── FlowCalculator.cs.meta │ │ ├── FlowField.cs │ │ └── FlowField.cs.meta │ ├── Level.meta │ ├── Level │ │ ├── CostStamp.cs │ │ ├── CostStamp.cs.meta │ │ ├── PathableLevel.cs │ │ ├── PathableLevel.cs.meta │ │ ├── SectorFlags.cs │ │ └── SectorFlags.cs.meta │ ├── PortalPaths.meta │ ├── PortalPaths │ │ ├── ContinentPathfinder.cs │ │ ├── ContinentPathfinder.cs.meta │ │ ├── PortalGraph.meta │ │ ├── PortalGraph │ │ │ ├── GraphSector.cs │ │ │ ├── GraphSector.cs.meta │ │ │ ├── PathableGraph.cs │ │ │ ├── PathableGraph.cs.meta │ │ │ ├── Portal.cs │ │ │ ├── Portal.cs.meta │ │ │ ├── PortalEdge.cs │ │ │ ├── PortalEdge.cs.meta │ │ │ ├── SectorCell.cs │ │ │ ├── SectorCell.cs.meta │ │ │ ├── SectorCosts.cs │ │ │ ├── SectorCosts.cs.meta │ │ │ ├── SectorData.cs │ │ │ ├── SectorData.cs.meta │ │ │ ├── SectorIslands.cs │ │ │ ├── SectorIslands.cs.meta │ │ │ ├── SectorLayout.cs │ │ │ ├── SectorLayout.cs.meta │ │ │ ├── SectorPortals.cs │ │ │ ├── SectorPortals.cs.meta │ │ │ ├── SectorRoot.cs │ │ │ └── SectorRoot.cs.meta │ │ ├── PortalPathNode.cs │ │ ├── PortalPathNode.cs.meta │ │ ├── PortalPathfinder.cs │ │ ├── PortalPathfinder.cs.meta │ │ ├── SectorPathfinder.cs │ │ └── SectorPathfinder.cs.meta │ ├── Utils.meta │ └── Utils │ │ ├── CellRect.cs │ │ ├── CellRect.cs.meta │ │ ├── Collections.meta │ │ ├── Collections │ │ ├── NativeField.cs │ │ ├── NativeField.cs.meta │ │ ├── NativePriorityQueue.cs │ │ ├── NativePriorityQueue.cs.meta │ │ ├── NativeStack.cs │ │ ├── NativeStack.cs.meta │ │ ├── PathfinderNode.cs │ │ ├── PathfinderNode.cs.meta │ │ ├── UnsafeArray.cs │ │ ├── UnsafeArray.cs.meta │ │ ├── UnsafeField.cs │ │ └── UnsafeField.cs.meta │ │ ├── Constants.cs │ │ ├── Constants.cs.meta │ │ ├── FlowTileUtils.cs │ │ ├── FlowTileUtils.cs.meta │ │ ├── TimerMessage.cs │ │ ├── TimerMessage.cs.meta │ │ ├── Visualisation.cs │ │ └── Visualisation.cs.meta ├── GlobalEntitiesDependencies.meta ├── SceneDependencyCache.meta └── SceneDependencyCache │ ├── 12ee09150bce8c611a562640b944ff62.sceneWithBuildSettings │ ├── 12ee09150bce8c611a562640b944ff62.sceneWithBuildSettings.meta │ ├── 97f89aeb4fe48824a1c880029cf250cb.sceneWithBuildSettings │ └── 97f89aeb4fe48824a1c880029cf250cb.sceneWithBuildSettings.meta ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── EntitiesClientSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── ShaderGraphSettings.asset ├── TagManager.asset ├── TimeManager.asset ├── URPProjectSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset ├── license.md ├── readme.md └── sublicense.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | debug.log 74 | Assets/GlobalEntitiesDependencies/* 75 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b7f9cee8f9479d47bdfd02fd443161d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c28d86451b557a545960089abc1efb42 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Agent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &4463320159658762581 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2078810066851485949} 12 | - component: {fileID: 1485422654859997337} 13 | - component: {fileID: 8935708311255375877} 14 | - component: {fileID: 9094793574871101695} 15 | m_Layer: 0 16 | m_Name: Agent 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &2078810066851485949 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 4463320159658762581} 29 | serializedVersion: 2 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_ConstrainProportionsScale: 0 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!114 &1485422654859997337 38 | MonoBehaviour: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 4463320159658762581} 44 | m_Enabled: 1 45 | m_EditorHideFlags: 0 46 | m_Script: {fileID: 11500000, guid: 470457b94618b804e8e4268012293287, type: 3} 47 | m_Name: 48 | m_EditorClassIdentifier: 49 | --- !u!33 &8935708311255375877 50 | MeshFilter: 51 | m_ObjectHideFlags: 0 52 | m_CorrespondingSourceObject: {fileID: 0} 53 | m_PrefabInstance: {fileID: 0} 54 | m_PrefabAsset: {fileID: 0} 55 | m_GameObject: {fileID: 4463320159658762581} 56 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 57 | --- !u!23 &9094793574871101695 58 | MeshRenderer: 59 | m_ObjectHideFlags: 0 60 | m_CorrespondingSourceObject: {fileID: 0} 61 | m_PrefabInstance: {fileID: 0} 62 | m_PrefabAsset: {fileID: 0} 63 | m_GameObject: {fileID: 4463320159658762581} 64 | m_Enabled: 1 65 | m_CastShadows: 1 66 | m_ReceiveShadows: 1 67 | m_DynamicOccludee: 1 68 | m_StaticShadowCaster: 0 69 | m_MotionVectors: 1 70 | m_LightProbeUsage: 1 71 | m_ReflectionProbeUsage: 1 72 | m_RayTracingMode: 2 73 | m_RayTraceProcedural: 0 74 | m_RenderingLayerMask: 1 75 | m_RendererPriority: 0 76 | m_Materials: 77 | - {fileID: 2100000, guid: 19c75d96b04601e42bc94f880ab23f6b, type: 2} 78 | m_StaticBatchInfo: 79 | firstSubMesh: 0 80 | subMeshCount: 0 81 | m_StaticBatchRoot: {fileID: 0} 82 | m_ProbeAnchor: {fileID: 0} 83 | m_LightProbeVolumeOverride: {fileID: 0} 84 | m_ScaleInLightmap: 1 85 | m_ReceiveGI: 1 86 | m_PreserveUVs: 0 87 | m_IgnoreNormalsForChartDetection: 0 88 | m_ImportantGI: 0 89 | m_StitchLightmapSeams: 1 90 | m_SelectedEditorRenderState: 3 91 | m_MinimumChartSize: 4 92 | m_AutoUVMaxDistance: 0.5 93 | m_AutoUVMaxAngle: 89 94 | m_LightmapParameters: {fileID: 0} 95 | m_SortingLayerID: 0 96 | m_SortingLayer: 0 97 | m_SortingOrder: 0 98 | m_AdditionalVertexStreams: {fileID: 0} 99 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Agent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 279f6604938ec2a4d95465aa15aebabd 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Flow.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &4463320159658762581 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2078810066851485949} 12 | - component: {fileID: 2863726689307091008} 13 | - component: {fileID: 8935708311255375877} 14 | - component: {fileID: 9094793574871101695} 15 | m_Layer: 0 16 | m_Name: Flow 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &2078810066851485949 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 4463320159658762581} 29 | serializedVersion: 2 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_ConstrainProportionsScale: 0 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!114 &2863726689307091008 38 | MonoBehaviour: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 4463320159658762581} 44 | m_Enabled: 1 45 | m_EditorHideFlags: 0 46 | m_Script: {fileID: 11500000, guid: 395f26410925d1d46a733263a5412f29, type: 3} 47 | m_Name: 48 | m_EditorClassIdentifier: 49 | --- !u!33 &8935708311255375877 50 | MeshFilter: 51 | m_ObjectHideFlags: 0 52 | m_CorrespondingSourceObject: {fileID: 0} 53 | m_PrefabInstance: {fileID: 0} 54 | m_PrefabAsset: {fileID: 0} 55 | m_GameObject: {fileID: 4463320159658762581} 56 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 57 | --- !u!23 &9094793574871101695 58 | MeshRenderer: 59 | m_ObjectHideFlags: 0 60 | m_CorrespondingSourceObject: {fileID: 0} 61 | m_PrefabInstance: {fileID: 0} 62 | m_PrefabAsset: {fileID: 0} 63 | m_GameObject: {fileID: 4463320159658762581} 64 | m_Enabled: 1 65 | m_CastShadows: 1 66 | m_ReceiveShadows: 1 67 | m_DynamicOccludee: 1 68 | m_StaticShadowCaster: 0 69 | m_MotionVectors: 1 70 | m_LightProbeUsage: 1 71 | m_ReflectionProbeUsage: 1 72 | m_RayTracingMode: 2 73 | m_RayTraceProcedural: 0 74 | m_RenderingLayerMask: 1 75 | m_RendererPriority: 0 76 | m_Materials: 77 | - {fileID: 2100000, guid: 87e5f58b7cbc4954399bda97f6d7b592, type: 2} 78 | m_StaticBatchInfo: 79 | firstSubMesh: 0 80 | subMeshCount: 0 81 | m_StaticBatchRoot: {fileID: 0} 82 | m_ProbeAnchor: {fileID: 0} 83 | m_LightProbeVolumeOverride: {fileID: 0} 84 | m_ScaleInLightmap: 1 85 | m_ReceiveGI: 1 86 | m_PreserveUVs: 0 87 | m_IgnoreNormalsForChartDetection: 0 88 | m_ImportantGI: 0 89 | m_StitchLightmapSeams: 1 90 | m_SelectedEditorRenderState: 3 91 | m_MinimumChartSize: 4 92 | m_AutoUVMaxDistance: 0.5 93 | m_AutoUVMaxAngle: 89 94 | m_LightmapParameters: {fileID: 0} 95 | m_SortingLayerID: 0 96 | m_SortingLayer: 0 97 | m_SortingOrder: 0 98 | m_AdditionalVertexStreams: {fileID: 0} 99 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Flow.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a56f605929bc11641887d5e78d1b4032 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 388fea0b061daf34f8cbe0659dfe0c78 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Materials/AgentMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19c75d96b04601e42bc94f880ab23f6b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Materials/FlowMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 32 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: FlowMaterial 11 | m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3} 12 | m_Parent: {fileID: 0} 13 | m_ModifiedSerializedProperties: 0 14 | m_ValidKeywords: 15 | - _ALPHATEST_ON 16 | m_InvalidKeywords: [] 17 | m_LightmapFlags: 4 18 | m_EnableInstancingVariants: 0 19 | m_DoubleSidedGI: 0 20 | m_CustomRenderQueue: 2450 21 | stringTagMap: 22 | RenderType: TransparentCutout 23 | disabledShaderPasses: [] 24 | m_LockedProperties: 25 | m_SavedProperties: 26 | serializedVersion: 3 27 | m_TexEnvs: 28 | - _AlphaTex: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _BaseMap: 33 | m_Texture: {fileID: 2800000, guid: b9da0e44cf4ad2b4688d504daaffa3d6, type: 3} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _MainTex: 37 | m_Texture: {fileID: 2800000, guid: b9da0e44cf4ad2b4688d504daaffa3d6, type: 3} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _MaskTex: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _NormalMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | m_Ints: [] 49 | m_Floats: 50 | - _AlphaClip: 1 51 | - _AlphaToMask: 1 52 | - _Blend: 0 53 | - _BlendOp: 0 54 | - _Cull: 2 55 | - _Cutoff: 0.5 56 | - _DstBlend: 0 57 | - _DstBlendAlpha: 0 58 | - _EnableExternalAlpha: 0 59 | - _QueueOffset: 0 60 | - _SampleGI: 0 61 | - _SrcBlend: 1 62 | - _SrcBlendAlpha: 1 63 | - _Surface: 0 64 | - _ZWrite: 1 65 | m_Colors: 66 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 67 | - _Color: {r: 1, g: 1, b: 1, a: 1} 68 | - _Flip: {r: 1, g: 1, b: 1, a: 1} 69 | - _RendererColor: {r: 1, g: 1, b: 1, a: 1} 70 | m_BuildTextureStacks: [] 71 | --- !u!114 &1471945867292140295 72 | MonoBehaviour: 73 | m_ObjectHideFlags: 11 74 | m_CorrespondingSourceObject: {fileID: 0} 75 | m_PrefabInstance: {fileID: 0} 76 | m_PrefabAsset: {fileID: 0} 77 | m_GameObject: {fileID: 0} 78 | m_Enabled: 1 79 | m_EditorHideFlags: 0 80 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 81 | m_Name: 82 | m_EditorClassIdentifier: 83 | version: 7 84 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Materials/FlowMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87e5f58b7cbc4954399bda97f6d7b592 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Wall.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &4463320159658762581 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2078810066851485949} 12 | - component: {fileID: 4241016447898997233} 13 | - component: {fileID: 8935708311255375877} 14 | - component: {fileID: 9094793574871101695} 15 | m_Layer: 0 16 | m_Name: Wall 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &2078810066851485949 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 4463320159658762581} 29 | serializedVersion: 2 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 0, y: 0, z: 0} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_ConstrainProportionsScale: 0 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!114 &4241016447898997233 38 | MonoBehaviour: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 4463320159658762581} 44 | m_Enabled: 1 45 | m_EditorHideFlags: 0 46 | m_Script: {fileID: 11500000, guid: 078dd2e067cd0354da953a62bc90b4ff, type: 3} 47 | m_Name: 48 | m_EditorClassIdentifier: 49 | --- !u!33 &8935708311255375877 50 | MeshFilter: 51 | m_ObjectHideFlags: 0 52 | m_CorrespondingSourceObject: {fileID: 0} 53 | m_PrefabInstance: {fileID: 0} 54 | m_PrefabAsset: {fileID: 0} 55 | m_GameObject: {fileID: 4463320159658762581} 56 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 57 | --- !u!23 &9094793574871101695 58 | MeshRenderer: 59 | m_ObjectHideFlags: 0 60 | m_CorrespondingSourceObject: {fileID: 0} 61 | m_PrefabInstance: {fileID: 0} 62 | m_PrefabAsset: {fileID: 0} 63 | m_GameObject: {fileID: 4463320159658762581} 64 | m_Enabled: 1 65 | m_CastShadows: 1 66 | m_ReceiveShadows: 1 67 | m_DynamicOccludee: 1 68 | m_StaticShadowCaster: 0 69 | m_MotionVectors: 1 70 | m_LightProbeUsage: 1 71 | m_ReflectionProbeUsage: 1 72 | m_RayTracingMode: 2 73 | m_RayTraceProcedural: 0 74 | m_RenderingLayerMask: 1 75 | m_RendererPriority: 0 76 | m_Materials: 77 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} 78 | m_StaticBatchInfo: 79 | firstSubMesh: 0 80 | subMeshCount: 0 81 | m_StaticBatchRoot: {fileID: 0} 82 | m_ProbeAnchor: {fileID: 0} 83 | m_LightProbeVolumeOverride: {fileID: 0} 84 | m_ScaleInLightmap: 1 85 | m_ReceiveGI: 1 86 | m_PreserveUVs: 0 87 | m_IgnoreNormalsForChartDetection: 0 88 | m_ImportantGI: 0 89 | m_StitchLightmapSeams: 1 90 | m_SelectedEditorRenderState: 3 91 | m_MinimumChartSize: 4 92 | m_AutoUVMaxDistance: 0.5 93 | m_AutoUVMaxAngle: 89 94 | m_LightmapParameters: {fileID: 0} 95 | m_SortingLayerID: 0 96 | m_SortingLayer: 0 97 | m_SortingOrder: 0 98 | m_AdditionalVertexStreams: {fileID: 0} 99 | -------------------------------------------------------------------------------- /Assets/Examples/Prefabs/Wall.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9e5fe92cde044f428823928513930d1 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3412a122e729204995b8d62caa8c1f8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/1_GraphExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9f735c5dc174a64ba1b297a9eff1fba 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/2_AgentExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c9cfa26abfee488c85f1582747f6a02 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/3_TerrainExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae62c5c6b64d6cf4a9be620e89f06afb 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/4_StressTestExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f64a773c3c5b734480c8c8a786120ca 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/5_ChangingStressTestExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f6b74f24d6dbd2448ad623bef19fdce 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/Subscenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1770ba49c6b1a734f8f307acd8186550 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scenes/Subscenes/SubScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c98e0d59331703d4ab11ea46077ccd3c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9dae4d36ce0b314a944bcfadc572b7f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad178bc29e4017840a554a4b9565809c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/AgentAuthor.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | public class AgentAuthor : MonoBehaviour { 7 | 8 | public class MyBaker : Baker { 9 | public override void Bake(AgentAuthor authoring) { 10 | var entity = GetEntity(TransformUsageFlags.None); 11 | AddComponent(entity, new AgentData { }); 12 | 13 | AddComponent(entity, new FlowPosition { }); 14 | AddComponent(entity, new FlowGoal { }); 15 | AddComponent(entity, new FlowProgress { }); 16 | AddComponent(entity, new FlowDirection { }); 17 | } 18 | } 19 | 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/AgentAuthor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 470457b94618b804e8e4268012293287 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/FlowAuthor.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | public class FlowAuthor : MonoBehaviour { 7 | 8 | public class MyBaker : Baker { 9 | public override void Bake(FlowAuthor authoring) { 10 | var entity = GetEntity(TransformUsageFlags.None); 11 | AddComponent(entity, new FlowData { }); 12 | } 13 | } 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/FlowAuthor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 395f26410925d1d46a733263a5412f29 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/PrefabsAuthor.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace FlowTiles.Examples { 5 | 6 | public class PrefabsAuthor : MonoBehaviour { 7 | 8 | public GameObject WallPrefab; 9 | public GameObject AgentPrefab; 10 | public GameObject FlowPrefab; 11 | 12 | public class MyBaker : Baker { 13 | public override void Bake(PrefabsAuthor authoring) { 14 | var entity = GetEntity(TransformUsageFlags.Dynamic); 15 | AddComponent(entity, new PrefabLinks { 16 | Wall = GetEntity(authoring.WallPrefab, TransformUsageFlags.None), 17 | Agent = GetEntity(authoring.AgentPrefab, TransformUsageFlags.Dynamic), 18 | Flow = GetEntity(authoring.FlowPrefab, TransformUsageFlags.Dynamic), 19 | }); 20 | } 21 | } 22 | 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/PrefabsAuthor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf4bf0628d34f384ebf1ece5d909923a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/WallAuthor.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | 7 | public class WallAuthor : MonoBehaviour { 8 | 9 | public class MyBaker : Baker { 10 | public override void Bake(WallAuthor authoring) { 11 | var entity = GetEntity(TransformUsageFlags.None); 12 | AddComponent(entity, new WallData { }); 13 | AddComponent(entity, new ColorOverride { Value = new float4(1) }); 14 | } 15 | } 16 | 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Authors/WallAuthor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 078dd2e067cd0354da953a62bc90b4ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ad8b2db2d8090a4ba3ae4b40198c2d9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/AgentData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.Examples { 5 | 6 | public struct AgentData : IComponentData { 7 | 8 | public float2 Speed; 9 | public int TravelType; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/AgentData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df6608f2d4e9d2e4eafb68c9d17e13f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/ColorOverride.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using Unity.Rendering; 4 | 5 | namespace FlowTiles.Examples { 6 | [MaterialProperty("_BaseColor")] 7 | public struct ColorOverride : IComponentData { 8 | public float4 Value; 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/ColorOverride.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4185eb072e66bba4dac3c24347742ac1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/LevelSetup.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.Utils; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | 5 | namespace FlowTiles.Examples { 6 | public struct LevelSetup : IComponentData { 7 | 8 | public int2 Size; 9 | public NativeField Walls; 10 | public NativeField Terrain; 11 | public NativeField Obstacles; 12 | public NativeField Flows; 13 | 14 | public bool VisualiseColors; 15 | public NativeField Colors; 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/LevelSetup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1126405fa3f454448438b01b645b25a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/PrefabLinks.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace FlowTiles.Examples { 4 | 5 | public struct PrefabLinks : IComponentData { 6 | 7 | public Entity Wall; 8 | public Entity Agent; 9 | public Entity Flow; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/PrefabLinks.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9fd4080b6075d94a99f3346d87d3d09 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/StressTestData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.Examples { 5 | 6 | public struct StressTestData : IComponentData { 7 | 8 | public Random Random; 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/StressTestData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a69ec7ccf8b27a4391319a363496b0e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/WallData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.Examples { 5 | public struct WallData : IComponentData { 6 | 7 | public int2 cell; 8 | public bool isWall; 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Components/WallData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7321537f2a4cea740bff531eb9b57f97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd3156843f4807a438a1336d291a52cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/DemoLevel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a31edc409ea62d9409cf46522f72fd9f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/LevelGeneration.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | namespace FlowTiles.Examples { 4 | 5 | public static class LevelGeneration { 6 | 7 | public static void InitialiseRandomObstacles(PathableLevel level, bool clearEdges) { 8 | if (clearEdges) { 9 | for (int x = 1; x < level.Size.x - 1; x++) { 10 | for (int y = 1; y < level.Size.y - 1; y++) { 11 | if (UnityEngine.Random.value < 0.2f) { 12 | level.SetBlocked(x, y, true); 13 | } 14 | } 15 | } 16 | } else { 17 | for (int x = 0; x < level.Size.x; x++) { 18 | for (int y = 0; y < level.Size.y; y++) { 19 | if (x == 0 && y == 0) { 20 | continue; 21 | } 22 | if (UnityEngine.Random.value < 0.2f) { 23 | level.SetBlocked(x, y, true); 24 | } 25 | } 26 | } 27 | } 28 | } 29 | 30 | public static void InitialiseRandomWalls(PathableLevel level, int length) { 31 | var sep = math.max(2, length / 4); 32 | // Add horizontal walls 33 | for (int y = 1; y < level.Size.y - 1; y += sep) { 34 | var minX = 1; 35 | var maxX = level.Size.x - 2 - length; 36 | var xStart = UnityEngine.Random.Range(minX, maxX); 37 | for (int x = 0; x < length; x++) { 38 | level.SetBlocked(x + xStart, y, true); 39 | } 40 | } 41 | // Add vertical walls 42 | for (int x = 1; x < level.Size.x - 1; x += sep) { 43 | var minY = 1; 44 | var maxY = level.Size.y - 2 - length; 45 | var yStart = UnityEngine.Random.Range(minY, maxY); 46 | for (int y = 0; y < length; y++) { 47 | level.SetBlocked(x, y + yStart, true); 48 | } 49 | } 50 | } 51 | 52 | public static void InitialiseWaterPools(PathableLevel level) { 53 | var size = level.Size; 54 | var sizeSectors = level.Layout.SizeSectors; 55 | var resolution = level.Layout.Resolution; 56 | 57 | for (int sector = 0; sector < sizeSectors.x; sector++) { 58 | var x0 = sector * resolution; 59 | var x1 = x0 + resolution; 60 | for (int x = x0 + 2; x < x1 - 2; x++) { 61 | var yGap = sector * resolution + resolution / 2; 62 | for (int y = 2; y < size.y - 2; y++) { 63 | var gapDist = math.abs(yGap - y); 64 | if (gapDist >= 2) { 65 | level.SetTerrain(x, y, (byte)TerrainType.WATER); 66 | } 67 | } 68 | } 69 | } 70 | 71 | } 72 | 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/LevelGeneration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 717ba8d624bbd7f458031327875811fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/SpawnAgentCommand.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.Examples { 5 | 6 | public struct SpawnAgentCommand { 7 | public int2 Cell; 8 | public int TravelType; 9 | public AgentType Type; 10 | public PathSmoothingMode LOSMode; 11 | } 12 | 13 | public enum AgentType { SINGLE, MULTIPLE, STRESS_TEST } 14 | 15 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/SpawnAgentCommand.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a1b0b539a27e4c4db096d3ab46b87e3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/TerrainType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace FlowTiles.Examples { 3 | public enum TerrainType { 4 | GROUND, WATER 5 | } 6 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/TerrainType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c122c8bc3db59e4d961fff77f7ce566 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/TravelType.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace FlowTiles.Examples { 3 | public enum TravelType { 4 | GroundOnly, Amphibious 5 | } 6 | 7 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/TravelType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d466cc3697cbad44b58de72d90fca4a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/Visualisation.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using Unity.Collections; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace FlowTiles.Examples { 7 | 8 | public static class Visualisation { 9 | 10 | public static void DrawSectors (PathableGraph graph) { 11 | var numSectors = graph.Layout.NumSectorsInLevel; 12 | for (int index = 0; index < numSectors; index++) { 13 | if (!graph.SectorIsInitialised(index)) continue; 14 | var sector = graph.IndexToSector(index); 15 | DrawRect(sector.Bounds, Color.blue, 0); 16 | } 17 | } 18 | 19 | public static void DrawSectorPortals (PathableGraph graph, int travelType) { 20 | var numSectors = graph.Layout.NumSectorsInLevel; 21 | for (int index = 0; index < numSectors; index++) { 22 | if (!graph.SectorIsInitialised(index)) continue; 23 | 24 | var sector = graph.IndexToSectorMap(index, travelType); 25 | var nodes = sector.Portals.Exits; 26 | for (int i = 0; i < nodes.Length; i++) { 27 | DrawRect(nodes[i].Bounds, Color.red); 28 | } 29 | } 30 | } 31 | 32 | public static void DrawSectorConnections(PathableGraph graph, int travelType) { 33 | var numSectors = graph.Layout.NumSectorsInLevel; 34 | for (int index = 0; index < numSectors; index++) { 35 | if (!graph.SectorIsInitialised(index)) continue; 36 | 37 | var sector = graph.IndexToSectorMap(index, travelType); 38 | var nodes = sector.Portals.Exits; 39 | DrawSectorConnections(nodes); 40 | } 41 | } 42 | 43 | private static void DrawSectorConnections(INativeList nodes) { 44 | for (int n = 0; n < nodes.Length; n++) { 45 | var node = nodes[n]; 46 | for (int e = 0; e < node.Edges.Length; e++) { 47 | var edge = node.Edges[e]; 48 | var pos1 = edge.start.Cell; 49 | var pos2 = edge.end.Cell; 50 | var diff = pos2 - pos1; 51 | Debug.DrawLine( 52 | new Vector3(pos1.x, pos1.y), 53 | new Vector3(pos2.x, pos2.y), 54 | Color.red); 55 | } 56 | } 57 | } 58 | 59 | public static void DrawPortalLink(float2 from, float2 to, Color color) { 60 | Debug.DrawLine(ToVector(from), ToVector(to), color); 61 | } 62 | 63 | public static void DrawRect(CellRect bounds, Color color, float border = 0.1f) { 64 | var pos00 = ToVector(bounds.MinCell.x, bounds.MinCell.y) + new Vector3(-0.5f + border, -0.5f + border); 65 | var pos01 = ToVector(bounds.MinCell.x, bounds.MaxCell.y) + new Vector3(-0.5f + border, 0.5f - border); 66 | var pos10 = ToVector(bounds.MaxCell.x, bounds.MinCell.y) + new Vector3(0.5f - border, -0.5f + border); 67 | var pos11 = ToVector(bounds.MaxCell.x, bounds.MaxCell.y) + new Vector3(0.5f - border, 0.5f - border); 68 | 69 | Debug.DrawLine(pos00, pos01, color); 70 | Debug.DrawLine(pos00, pos10, color); 71 | Debug.DrawLine(pos11, pos01, color); 72 | Debug.DrawLine(pos11, pos10, color); 73 | } 74 | 75 | private static Vector3 ToVector(float2 cell) => new Vector3(cell.x, cell.y); 76 | private static Vector3 ToVector(float x, float y) => new Vector3(x, y); 77 | 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/Visualisation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c7befee0cd43314bb6ac1c8f086a1bf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/VisualiseMode.cs: -------------------------------------------------------------------------------- 1 | namespace FlowTiles.Examples { 2 | public enum VisualiseMode { 3 | None, 4 | OnlySectors, 5 | Portals, 6 | Connections, 7 | Costs, 8 | Islands, 9 | Continents, 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Level/VisualiseMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c88409b5c9f76a04e89fd0f7101fd673 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98872e8a92911874ea75d7dd59b0182c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/AgentExampleManager.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | 7 | public class AgentExampleManager : MonoBehaviour { 8 | 9 | public int LevelSize = 100; 10 | public int Resolution = 10; 11 | public bool AddRandomWalls; 12 | public PathSmoothingMode PathSmoothingMode; 13 | public VisualiseMode VisualiseMode; 14 | 15 | private DemoLevel Level; 16 | 17 | void Awake() { 18 | 19 | var map = new PathableLevel(LevelSize, LevelSize, Resolution); 20 | if (AddRandomWalls) { 21 | LevelGeneration.InitialiseRandomObstacles(map, false); 22 | } 23 | 24 | Level = new DemoLevel(map, Resolution); 25 | Level.SpawnAgentAt(0, AgentType.SINGLE, PathSmoothingMode); 26 | 27 | } 28 | 29 | void Update() { 30 | Level.Update(); 31 | Level.VisualiseMode = VisualiseMode; 32 | Level.VisualiseAgentFlows(); 33 | 34 | var position = Camera.main.ScreenToWorldPoint(Input.mousePosition); 35 | var mouseCell = new int2((int)(position.x + 0.5f), (int)(position.y + 0.5f)); 36 | if (mouseCell.x >= 0 && mouseCell.y >= 0 && mouseCell.x < LevelSize && mouseCell.y < LevelSize) { 37 | 38 | if (Input.GetMouseButtonDown(0)) { 39 | var isBlocked = Level.GetWallAt(mouseCell); 40 | if (!isBlocked) { 41 | Level.SetAgentDestinations(mouseCell, PathSmoothingMode); 42 | } 43 | } 44 | if (Input.GetMouseButtonDown(1)) { 45 | Level.FlipWallAt(mouseCell); 46 | } 47 | 48 | } 49 | } 50 | 51 | void OnDestroy() { 52 | Level?.Dispose(); 53 | } 54 | 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/AgentExampleManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 752084520ef13854ba6d8792ab28dd34 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/ChangingStressTextExampleManager.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | 7 | public class ChangingStressTestExampleManager : MonoBehaviour { 8 | 9 | public int LevelSize = 100; 10 | public int Resolution = 10; 11 | public float LevelChangeFrequency = 1f; 12 | public PathSmoothingMode PathSmoothingMode; 13 | 14 | private DemoLevel Level; 15 | 16 | void Awake() { 17 | 18 | var map = new PathableLevel(LevelSize, LevelSize, Resolution); 19 | 20 | Level = new DemoLevel(map, Resolution); 21 | 22 | var direction = 1; 23 | for (int i = Resolution / 2; i < LevelSize; i += Resolution) { 24 | Level.AddMovingWall(i, LevelSize / 2, direction, LevelChangeFrequency); 25 | direction *= -1; 26 | } 27 | 28 | for (int x = 0; x < LevelSize; x++) { 29 | for (int y = 0; y < LevelSize; y++) { 30 | if (map.Obstacles[x, y] == 0) { 31 | Level.SpawnAgentAt(new int2(x, y), AgentType.STRESS_TEST, PathSmoothingMode); 32 | } 33 | } 34 | } 35 | 36 | } 37 | 38 | void Update() { 39 | Level.Update(); 40 | } 41 | 42 | void OnDestroy() { 43 | Level?.Dispose(); 44 | } 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/ChangingStressTextExampleManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cec59139500e1c46800a015555135db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/GraphExampleManager.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using UnityEngine; 3 | 4 | namespace FlowTiles.Examples { 5 | 6 | public class GraphExampleManager : MonoBehaviour { 7 | 8 | public int LevelSize = 100; 9 | public int Resolution = 20; 10 | public bool AddRandomWalls; 11 | public VisualiseMode VisualiseMode; 12 | public bool VisualiseLineOfSightSmoothing; 13 | 14 | private DemoLevel Level; 15 | private int2 startCell; 16 | 17 | void Awake() { 18 | var map = new PathableLevel(LevelSize, LevelSize, Resolution, 1, 2); 19 | if (AddRandomWalls) { 20 | LevelGeneration.InitialiseRandomObstacles(map, false); 21 | } 22 | 23 | Level = new DemoLevel(map, Resolution); 24 | } 25 | 26 | void Update() { 27 | Level.Update(); 28 | Level.VisualiseMode = VisualiseMode; 29 | 30 | var position = Camera.main.ScreenToWorldPoint(Input.mousePosition); 31 | var mouseCell = new int2((int)(position.x + 0.5f), (int)(position.y + 0.5f)); 32 | if (mouseCell.x >= 0 && mouseCell.y >= 0 && mouseCell.x < LevelSize && mouseCell.y < LevelSize) { 33 | 34 | if (Input.GetMouseButtonDown(0)) { 35 | startCell = mouseCell; 36 | } 37 | if (Input.GetMouseButtonDown(1)) { 38 | Level.FlipWallAt(mouseCell); 39 | } 40 | 41 | Level.VisualiseTestPath(startCell, mouseCell, true, VisualiseLineOfSightSmoothing); 42 | } 43 | 44 | } 45 | 46 | void OnDestroy() { 47 | Level?.Dispose(); 48 | } 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/GraphExampleManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39ca6ebc4593ca94792179d55ba468ab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/MovingWall.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using UnityEngine; 3 | 4 | namespace FlowTiles.Examples { 5 | public class MovingWall { 6 | 7 | private CostStamp Stamp; 8 | private int2 Corner; 9 | private int Direction; 10 | private int Length; 11 | private float Frequency; 12 | private int DelayTicks; 13 | private PathableLevel Level; 14 | private int lastMovedTick; 15 | 16 | public MovingWall (int2 corner, int length, int direction, int delayTicks, PathableLevel level, float fequency) { 17 | var values = new byte[length, 2]; 18 | for (int i = 0; i < length; i++) { 19 | values[i, 0] = 255; 20 | values[i, 1] = 255; 21 | } 22 | 23 | Stamp = new CostStamp(values); 24 | Corner = corner; 25 | Length = length; 26 | Direction = direction; 27 | Frequency = fequency; 28 | DelayTicks = delayTicks; 29 | Level = level; 30 | 31 | Place(); 32 | } 33 | 34 | public void Update () { 35 | int tick = (int)(Time.time * Frequency); 36 | if (tick != lastMovedTick) { 37 | int offset = (tick - DelayTicks); 38 | if (offset > 0 && offset % 5 == 0) { 39 | lastMovedTick = tick; 40 | Move(); 41 | } 42 | } 43 | } 44 | 45 | public void Dispose () { 46 | Stamp.Dispose(); 47 | } 48 | 49 | private void Move() { 50 | Clear(); 51 | 52 | var shift = (Length / 4) * Direction; 53 | Corner.x += shift; 54 | if (Corner.x >= Level.Size.x) { 55 | Corner.x -= Level.Size.x; 56 | } 57 | if (Corner.x <= -Length) { 58 | Corner.x += Level.Size.x; 59 | } 60 | 61 | Place(); 62 | } 63 | 64 | private void Place () { 65 | Level.PlaceStamp(Corner.x, Corner.y, Stamp); 66 | Level.PlaceStamp(Corner.x - Level.Size.x, Corner.y, Stamp); 67 | Level.PlaceStamp(Corner.x + Level.Size.x, Corner.y, Stamp); 68 | } 69 | 70 | private void Clear() { 71 | Level.ClearStamp(Corner.x, Corner.y, Stamp); 72 | Level.ClearStamp(Corner.x - Level.Size.x, Corner.y, Stamp); 73 | Level.ClearStamp(Corner.x + Level.Size.x, Corner.y, Stamp); 74 | } 75 | 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/MovingWall.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8a31bbad2d47734f9ccacdf63254afc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/StressTextExampleManager.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | 7 | public class StressTestExampleManager : MonoBehaviour { 8 | 9 | public int LevelSize = 100; 10 | public int Resolution = 10; 11 | public PathSmoothingMode PathSmoothingMode; 12 | 13 | private DemoLevel Level; 14 | 15 | void Awake() { 16 | 17 | var map = new PathableLevel(LevelSize, LevelSize, Resolution); 18 | LevelGeneration.InitialiseRandomWalls(map, LevelSize / 5); 19 | 20 | Level = new DemoLevel(map, Resolution); 21 | 22 | for (int x = 0; x < LevelSize; x++) { 23 | for (int y = 1; y < LevelSize; y++) { 24 | if (!map.Blocked[x, y]) { 25 | Level.SpawnAgentAt(new int2(x, y), AgentType.STRESS_TEST, PathSmoothingMode); 26 | } 27 | } 28 | } 29 | 30 | } 31 | 32 | void Update() { 33 | Level.Update(); 34 | 35 | var position = Camera.main.ScreenToWorldPoint(Input.mousePosition); 36 | var mouseCell = new int2((int)(position.x + 0.5f), (int)(position.y + 0.5f)); 37 | if (mouseCell.x >= 0 && mouseCell.y >= 0 && mouseCell.x < LevelSize && mouseCell.y < LevelSize) { 38 | 39 | if (Input.GetMouseButtonDown(1)) { 40 | Level.FlipWallAt(mouseCell); 41 | } 42 | } 43 | 44 | } 45 | 46 | void OnDestroy() { 47 | Level?.Dispose(); 48 | } 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/StressTextExampleManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 744be2a684226db46a85f87eb6686975 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/TerrainExampleManager.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles.Examples { 6 | 7 | public class TerrainExampleManager : MonoBehaviour { 8 | 9 | public int LevelSize = 100; 10 | public int Resolution = 10; 11 | public PathSmoothingMode PathSmoothingMode; 12 | public TravelType VisualisedTravelType; 13 | public VisualiseMode VisualiseMode; 14 | 15 | private DemoLevel Level; 16 | 17 | void Awake() { 18 | 19 | // Initialise the map with terrain and travel types 20 | var map = new PathableLevel(LevelSize, LevelSize, Resolution, 2, 2); 21 | map.SetTerrainCost((int)TravelType.GroundOnly, (int)TerrainType.WATER, 10); 22 | map.SetTerrainCost((int)TravelType.Amphibious, (int)TerrainType.GROUND, 2); 23 | 24 | LevelGeneration.InitialiseWaterPools(map); 25 | 26 | Level = new DemoLevel(map, Resolution); 27 | 28 | var pos1 = new int2(0, (int)(LevelSize * 0.33f)); 29 | var pos2 = new int2(0, (int)(LevelSize * 0.66f)); 30 | Level.SpawnAgentAt(pos1, AgentType.SINGLE, PathSmoothingMode, travelType: (int)TravelType.GroundOnly); 31 | Level.SpawnAgentAt(pos2, AgentType.SINGLE, PathSmoothingMode, travelType: (int)TravelType.Amphibious); 32 | 33 | } 34 | 35 | void Update() { 36 | Level.Update(); 37 | Level.VisualiseMode = VisualiseMode; 38 | Level.VisualisedTravelType = (int)VisualisedTravelType; 39 | 40 | var position = Camera.main.ScreenToWorldPoint(Input.mousePosition); 41 | var mouseCell = new int2((int)(position.x + 0.5f), (int)(position.y + 0.5f)); 42 | if (mouseCell.x >= 0 && mouseCell.y >= 0 && mouseCell.x < LevelSize && mouseCell.y < LevelSize) { 43 | 44 | if (Input.GetMouseButtonDown(0)) { 45 | Level.SetAgentDestinations(mouseCell, PathSmoothingMode); 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | void OnDestroy() { 53 | Level?.Dispose(); 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/SceneManagers/TerrainExampleManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8140f14750fa2064ab274e54ee56c251 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f385cd90142fbe4db129f5ee254076e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/LevelSetupSystem.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using Unity.Transforms; 5 | 6 | namespace FlowTiles.Examples { 7 | 8 | public partial struct LevelSetupSystem : ISystem { 9 | 10 | private static bool instantiated = false; 11 | 12 | public void OnCreate(ref SystemState state) { 13 | state.RequireForUpdate(); 14 | state.RequireForUpdate(); 15 | } 16 | 17 | public void OnUpdate (ref SystemState state) { 18 | if (instantiated) { 19 | return; 20 | } 21 | instantiated = true; 22 | 23 | var setup = SystemAPI.GetSingleton(); 24 | var prefabs = SystemAPI.GetSingleton(); 25 | 26 | for (int i = 0; i < setup.Size.x; i++) { 27 | for (int j = 0; j < setup.Size.y; j++) { 28 | 29 | // Create wall 30 | var wall = state.EntityManager.Instantiate(prefabs.Wall); 31 | state.EntityManager.SetComponentData(wall, new WallData { 32 | cell = new int2(i, j), 33 | }); 34 | state.EntityManager.SetComponentData(wall, new LocalTransform { 35 | Position = new float3(i, j, 0f), 36 | Scale = 1, 37 | }); 38 | 39 | // Create flow marker 40 | var flow = state.EntityManager.Instantiate(prefabs.Flow); 41 | state.EntityManager.SetComponentData(flow, new FlowData { 42 | cell = new int2(i, j), 43 | }); 44 | state.EntityManager.SetComponentData(flow, new LocalTransform { 45 | Position = new float3(i, j, -0.5f), 46 | Scale = 0, 47 | }); 48 | 49 | } 50 | } 51 | 52 | } 53 | 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/LevelSetupSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0f0c67fe23c985499dc28e83e89c220 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/LevelUpdateSystem.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using FlowTiles.Utils; 3 | using Unity.Burst; 4 | using Unity.Collections; 5 | using Unity.Entities; 6 | using Unity.Mathematics; 7 | using Unity.Transforms; 8 | 9 | namespace FlowTiles.Examples { 10 | 11 | [BurstCompile] 12 | public partial struct LevelUpdateSystem : ISystem { 13 | 14 | public void OnCreate(ref SystemState state) { 15 | state.RequireForUpdate(); 16 | } 17 | 18 | [BurstCompile] 19 | public void OnUpdate(ref SystemState state) { 20 | var setup = SystemAPI.GetSingleton(); 21 | 22 | new WallsJob { 23 | LevelSize = setup.Size, 24 | LevelWalls = setup.Walls, 25 | LevelTerrain = setup.Terrain, 26 | LevelStamps = setup.Obstacles, 27 | LevelColors = setup.Colors, 28 | VisualiseColors = setup.VisualiseColors, 29 | }.ScheduleParallel(); 30 | 31 | new FlowJob { 32 | LevelSize = setup.Size, 33 | LevelFlows = setup.Flows, 34 | }.ScheduleParallel(); 35 | } 36 | 37 | [BurstCompile] 38 | public partial struct WallsJob : IJobEntity { 39 | 40 | public int2 LevelSize; 41 | public bool VisualiseColors; 42 | [ReadOnly] public NativeField LevelWalls; 43 | [ReadOnly] public NativeField LevelTerrain; 44 | [ReadOnly] public NativeField LevelStamps; 45 | [ReadOnly] public NativeField LevelColors; 46 | 47 | [BurstCompile] 48 | private void Execute(Aspect quad, [ChunkIndexInQuery] int sortKey) { 49 | var cell = quad.Cell; 50 | var wall = LevelWalls[cell.x, cell.y] || LevelStamps[cell.x, cell.y] >= 255; 51 | var terrain = LevelTerrain[cell.x, cell.y]; 52 | 53 | float4 color = 1; 54 | if (terrain == (byte)TerrainType.WATER) { 55 | color = new float4(0.2f, 0.36f, 1f, 1f); 56 | } 57 | if (VisualiseColors) { 58 | color = LevelColors[cell.x, cell.y]; 59 | if (wall) { 60 | color *= 0.16f; 61 | } 62 | } 63 | else if (wall) { 64 | color = 0; 65 | } 66 | 67 | quad.Color = color; 68 | } 69 | 70 | public readonly partial struct Aspect : IAspect { 71 | 72 | public readonly Entity Entity; 73 | private readonly RefRW _wall; 74 | private readonly RefRW _color; 75 | 76 | public int2 Cell => _wall.ValueRO.cell; 77 | 78 | public float4 Color { 79 | get => _color.ValueRW.Value; 80 | set => _color.ValueRW.Value = value; 81 | } 82 | 83 | } 84 | 85 | } 86 | 87 | [BurstCompile] 88 | public partial struct FlowJob : IJobEntity { 89 | 90 | public int2 LevelSize; 91 | [ReadOnly] public NativeField LevelFlows; 92 | 93 | [BurstCompile] 94 | private void Execute(Aspect flow, [ChunkIndexInQuery] int sortKey) { 95 | var cell = flow.Cell; 96 | var data = LevelFlows[cell.x, cell.y]; 97 | 98 | flow.SetFlow(data); 99 | } 100 | 101 | public readonly partial struct Aspect : IAspect { 102 | 103 | public readonly Entity Entity; 104 | private readonly RefRW _flow; 105 | private readonly RefRW _transform; 106 | 107 | public int2 Cell => _flow.ValueRO.cell; 108 | 109 | public void SetFlow(float2 newFlow) { 110 | if (math.length(newFlow) == 0) { 111 | _transform.ValueRW.Scale = 0; 112 | } 113 | else { 114 | var angle = math.atan2(newFlow.y, newFlow.x); 115 | _transform.ValueRW.Scale = 1; 116 | _transform.ValueRW.Rotation = quaternion.Euler( 117 | new float3(0, 0, angle) 118 | ); 119 | } 120 | } 121 | 122 | } 123 | 124 | } 125 | 126 | } 127 | 128 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/LevelUpdateSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb6fec0a5ccbdb141a95faf6e4b8639b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/MovementSystem.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Burst; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | using Unity.Transforms; 6 | 7 | namespace FlowTiles.Examples { 8 | 9 | [BurstCompile] 10 | public partial struct MovementSystem : ISystem { 11 | 12 | public void OnCreate(ref SystemState state) { 13 | state.RequireForUpdate(); 14 | } 15 | 16 | [BurstCompile] 17 | public void OnUpdate(ref SystemState state) { 18 | var level = SystemAPI.GetSingleton(); 19 | new Job { 20 | LevelSize = level.Size, 21 | DeltaTime = SystemAPI.Time.DeltaTime, 22 | }.ScheduleParallel(); 23 | } 24 | 25 | [BurstCompile] 26 | public partial struct Job : IJobEntity { 27 | 28 | public int2 LevelSize; 29 | public float DeltaTime; 30 | 31 | [BurstCompile] 32 | private void Execute(ref AgentData agent, ref FlowPosition cell, ref FlowDirection direction, ref LocalTransform transform) { 33 | var speed = agent.Speed; 34 | var dir = direction.Direction; 35 | speed = math.lerp(speed, dir, math.saturate(DeltaTime * 5)); 36 | agent.Speed = speed; 37 | 38 | var position = transform.Position; 39 | position += new float3(speed * DeltaTime * 3.3f, 0); 40 | position.x = math.clamp(position.x, 0, LevelSize.x - 1); 41 | position.y = math.clamp(position.y, 0, LevelSize.y - 1); 42 | 43 | transform.Position = position; 44 | cell.Position = new float2(position.x, position.y); 45 | } 46 | 47 | } 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/MovementSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc34f7a86eb90094991611407916e6fb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/StressTestSystem.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Burst; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | using Unity.Transforms; 6 | 7 | namespace FlowTiles.Examples { 8 | 9 | [BurstCompile] 10 | public partial struct StressTestSystem : ISystem { 11 | 12 | public void OnCreate(ref SystemState state) { 13 | state.RequireForUpdate(); 14 | } 15 | 16 | [BurstCompile] 17 | public void OnUpdate(ref SystemState state) { 18 | var level = SystemAPI.GetSingleton(); 19 | new Job { 20 | LevelSize = level.Size 21 | }.ScheduleParallel(); 22 | } 23 | 24 | [BurstCompile] 25 | public partial struct Job : IJobEntity { 26 | 27 | public int2 LevelSize; 28 | 29 | [BurstCompile] 30 | private void Execute(ref AgentData agent, ref FlowPosition cell, ref FlowProgress progress, ref FlowGoal goal, ref LocalTransform transform, ref StressTestData data) { 31 | var random = data.Random; 32 | 33 | var position = cell.PositionCell; 34 | if (!goal.HasGoal || position.y == 0) { 35 | 36 | if (position.y <= 0) { 37 | var newPosition = new int2(random.NextInt(LevelSize.x), LevelSize.y - 1); 38 | cell.Position = newPosition; 39 | transform.Position = new float3(newPosition.x, newPosition.y, transform.Position.z); 40 | agent.Speed = 0; 41 | } 42 | 43 | var newGoal = new int2(random.NextInt(LevelSize.x), 0); 44 | newGoal.x = math.min(newGoal.x / 4 * 4 + 2, LevelSize.x - 1); 45 | goal.Goal = newGoal; 46 | goal.HasGoal = true; 47 | progress.HasPath = false; 48 | } 49 | 50 | data.Random = random; 51 | } 52 | 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /Assets/Examples/Scripts/Systems/StressTestSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d498240ee2983cd4b9642c9893f93ccc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Examples/Settings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0220aab0833d04faeb927d84ca6cc40c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/Renderer2D.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 11145981673336645838492a2d98e247, type: 3} 13 | m_Name: Renderer2D 14 | m_EditorClassIdentifier: 15 | debugShaders: 16 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3} 17 | hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3} 18 | m_RendererFeatures: [] 19 | m_RendererFeatureMap: 20 | m_UseNativeRenderPass: 0 21 | m_TransparencySortMode: 0 22 | m_TransparencySortAxis: {x: 0, y: 1, z: 0} 23 | m_HDREmulationScale: 1 24 | m_LightRenderTextureScale: 0.5 25 | m_LightBlendStyles: 26 | - name: Multiply 27 | maskTextureChannel: 0 28 | blendMode: 1 29 | - name: Additive 30 | maskTextureChannel: 0 31 | blendMode: 0 32 | - name: Multiply with Mask 33 | maskTextureChannel: 1 34 | blendMode: 1 35 | - name: Additive with Mask 36 | maskTextureChannel: 1 37 | blendMode: 0 38 | m_UseDepthStencilBuffer: 1 39 | m_UseCameraSortingLayersTexture: 0 40 | m_CameraSortingLayersTextureBound: -1 41 | m_CameraSortingLayerDownsamplingMethod: 0 42 | m_MaxLightRenderTextureCount: 16 43 | m_MaxShadowRenderTextureCount: 1 44 | m_ShapeLightShader: {fileID: 4800000, guid: d79e1c784eaf80c4585c0be7391f757a, type: 3} 45 | m_ShapeLightVolumeShader: {fileID: 4800000, guid: 7e60080c8cd24a2468cb08b4bfee5606, type: 3} 46 | m_PointLightShader: {fileID: 4800000, guid: e35a31e1679aeff489e202f5cc4853d5, type: 3} 47 | m_PointLightVolumeShader: {fileID: 4800000, guid: c7d04ca57e5449d49ad9cee1c604bc26, type: 3} 48 | m_CoreBlitShader: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 49 | m_BlitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3} 50 | m_CoreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3} 51 | m_SamplingShader: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 52 | m_ProjectedShadowShader: {fileID: 4800000, guid: ce09d4a80b88c5a4eb9768fab4f1ee00, type: 3} 53 | m_SpriteShadowShader: {fileID: 4800000, guid: 44fc62292b65ab04eabcf310e799ccf6, type: 3} 54 | m_SpriteUnshadowShader: {fileID: 4800000, guid: de02b375720b5c445afe83cd483bedf3, type: 3} 55 | m_GeometryUnshadowShader: {fileID: 4800000, guid: 77774d9009bb81447b048c907d4c6273, type: 3} 56 | m_FallbackErrorShader: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 57 | m_PostProcessData: {fileID: 0} 58 | m_FallOffLookup: {fileID: 2800000, guid: 5688ab254e4c0634f8d6c8e0792331ca, type: 3} 59 | m_DefaultMaterialType: 1 60 | m_DefaultCustomMaterial: {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} 61 | m_DefaultLitMaterial: {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} 62 | m_DefaultUnlitMaterial: {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2} 63 | m_DefaultMaskMaterial: {fileID: 2100000, guid: 15d0c3709176029428a0da2f8cecf0b5, type: 2} 64 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/Renderer2D.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 424799608f7334c24bf367e4bbfa7f9a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/UniversalRP.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: UniversalRP 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 11 16 | k_AssetPreviousVersion: 11 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: 424799608f7334c24bf367e4bbfa7f9a, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_SupportsHDR: 0 27 | m_HDRColorBufferPrecision: 0 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_UpscalingFilter: 0 31 | m_FsrOverrideSharpness: 0 32 | m_FsrSharpness: 0.92 33 | m_EnableLODCrossFade: 1 34 | m_LODCrossFadeDitheringType: 1 35 | m_ShEvalMode: 0 36 | m_MainLightRenderingMode: 0 37 | m_MainLightShadowsSupported: 1 38 | m_MainLightShadowmapResolution: 2048 39 | m_AdditionalLightsRenderingMode: 1 40 | m_AdditionalLightsPerObjectLimit: 4 41 | m_AdditionalLightShadowsSupported: 0 42 | m_AdditionalLightsShadowmapResolution: 2048 43 | m_AdditionalLightsShadowResolutionTierLow: 512 44 | m_AdditionalLightsShadowResolutionTierMedium: 1024 45 | m_AdditionalLightsShadowResolutionTierHigh: 2048 46 | m_ReflectionProbeBlending: 0 47 | m_ReflectionProbeBoxProjection: 0 48 | m_ShadowDistance: 50 49 | m_ShadowCascadeCount: 1 50 | m_Cascade2Split: 0.25 51 | m_Cascade3Split: {x: 0.1, y: 0.3} 52 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 53 | m_CascadeBorder: 0.1 54 | m_ShadowDepthBias: 1 55 | m_ShadowNormalBias: 1 56 | m_AnyShadowsSupported: 1 57 | m_SoftShadowsSupported: 0 58 | m_ConservativeEnclosingSphere: 0 59 | m_NumIterationsEnclosingSphere: 64 60 | m_SoftShadowQuality: 2 61 | m_AdditionalLightsCookieResolution: 2048 62 | m_AdditionalLightsCookieFormat: 3 63 | m_UseSRPBatcher: 1 64 | m_SupportsDynamicBatching: 0 65 | m_MixedLightingSupported: 1 66 | m_SupportsLightCookies: 1 67 | m_SupportsLightLayers: 0 68 | m_DebugLevel: 0 69 | m_StoreActionsOptimization: 0 70 | m_EnableRenderGraph: 0 71 | m_UseAdaptivePerformance: 1 72 | m_ColorGradingMode: 0 73 | m_ColorGradingLutSize: 32 74 | m_UseFastSRGBLinearConversion: 0 75 | m_SupportDataDrivenLensFlare: 1 76 | m_ShadowType: 1 77 | m_LocalShadowsSupported: 0 78 | m_LocalShadowsAtlasResolution: 256 79 | m_MaxPixelLights: 0 80 | m_ShadowAtlasResolution: 256 81 | m_VolumeFrameworkUpdateMode: 0 82 | m_Textures: 83 | blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3} 84 | bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3} 85 | m_PrefilteringModeMainLightShadows: 1 86 | m_PrefilteringModeAdditionalLight: 4 87 | m_PrefilteringModeAdditionalLightShadows: 1 88 | m_PrefilterXRKeywords: 0 89 | m_PrefilteringModeForwardPlus: 1 90 | m_PrefilteringModeDeferredRendering: 1 91 | m_PrefilteringModeScreenSpaceOcclusion: 1 92 | m_PrefilterDebugKeywords: 0 93 | m_PrefilterWriteRenderingLayers: 0 94 | m_PrefilterHDROutput: 0 95 | m_PrefilterSSAODepthNormals: 0 96 | m_PrefilterSSAOSourceDepthLow: 0 97 | m_PrefilterSSAOSourceDepthMedium: 0 98 | m_PrefilterSSAOSourceDepthHigh: 0 99 | m_PrefilterSSAOInterleaved: 0 100 | m_PrefilterSSAOBlueNoise: 0 101 | m_PrefilterSSAOSampleCountLow: 0 102 | m_PrefilterSSAOSampleCountMedium: 0 103 | m_PrefilterSSAOSampleCountHigh: 0 104 | m_PrefilterDBufferMRT1: 0 105 | m_PrefilterDBufferMRT2: 0 106 | m_PrefilterDBufferMRT3: 0 107 | m_PrefilterSoftShadowsQualityLow: 0 108 | m_PrefilterSoftShadowsQualityMedium: 0 109 | m_PrefilterSoftShadowsQualityHigh: 0 110 | m_PrefilterSoftShadows: 0 111 | m_PrefilterScreenCoord: 0 112 | m_PrefilterNativeRenderPass: 0 113 | m_ShaderVariantLogLevel: 0 114 | m_ShadowCascades: 0 115 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/UniversalRP.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 681886c5eb7344803b6206f758bf0b1c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/UniversalRenderPipelineGlobalSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3} 13 | m_Name: UniversalRenderPipelineGlobalSettings 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 3 16 | lightLayerName0: 17 | lightLayerName1: 18 | lightLayerName2: 19 | lightLayerName3: 20 | lightLayerName4: 21 | lightLayerName5: 22 | lightLayerName6: 23 | lightLayerName7: 24 | m_StripDebugVariants: 1 25 | m_StripUnusedPostProcessingVariants: 0 26 | m_StripUnusedVariants: 1 27 | supportRuntimeDebugDisplay: 0 28 | -------------------------------------------------------------------------------- /Assets/Examples/Settings/UniversalRenderPipelineGlobalSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93b439a37f63240aca3dd4e01d978a9f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Sprites.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea48a9f5605665942bba0836c4226f17 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Sprites/agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lycheelabs/Flow-Tiles/5684bdcae0e519d599dd01cda0f56875df9699db/Assets/Examples/Sprites/agent.png -------------------------------------------------------------------------------- /Assets/Examples/Sprites/agent.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7de2f1890cfe3f84482072db0a45b38e 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 13 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | flipGreenChannel: 0 24 | isReadable: 0 25 | streamingMipmaps: 0 26 | streamingMipmapsPriority: 0 27 | vTOnly: 0 28 | ignoreMipmapLimit: 0 29 | grayScaleToAlpha: 0 30 | generateCubemap: 6 31 | cubemapConvolution: 0 32 | seamlessCubemap: 0 33 | textureFormat: 1 34 | maxTextureSize: 2048 35 | textureSettings: 36 | serializedVersion: 2 37 | filterMode: 1 38 | aniso: 1 39 | mipBias: 0 40 | wrapU: 1 41 | wrapV: 1 42 | wrapW: 1 43 | nPOTScale: 0 44 | lightmap: 0 45 | compressionQuality: 50 46 | spriteMode: 1 47 | spriteExtrude: 1 48 | spriteMeshType: 1 49 | alignment: 0 50 | spritePivot: {x: 0.5, y: 0.5} 51 | spritePixelsToUnits: 50 52 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 53 | spriteGenerateFallbackPhysicsShape: 1 54 | alphaUsage: 1 55 | alphaIsTransparency: 1 56 | spriteTessellationDetail: -1 57 | textureType: 8 58 | textureShape: 1 59 | singleChannelComponent: 0 60 | flipbookRows: 1 61 | flipbookColumns: 1 62 | maxTextureSizeSet: 0 63 | compressionQualitySet: 0 64 | textureFormatSet: 0 65 | ignorePngGamma: 0 66 | applyGammaDecoding: 0 67 | swizzle: 50462976 68 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: Standalone 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | spriteSheet: 97 | serializedVersion: 2 98 | sprites: [] 99 | outline: [] 100 | physicsShape: [] 101 | bones: [] 102 | spriteID: 5e97eb03825dee720800000000000000 103 | internalID: 0 104 | vertices: [] 105 | indices: 106 | edges: [] 107 | weights: [] 108 | secondaryTextures: [] 109 | nameFileIdTable: {} 110 | mipmapLimitGroupName: 111 | pSDRemoveMatte: 0 112 | userData: 113 | assetBundleName: 114 | assetBundleVariant: 115 | -------------------------------------------------------------------------------- /Assets/Examples/Sprites/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lycheelabs/Flow-Tiles/5684bdcae0e519d599dd01cda0f56875df9699db/Assets/Examples/Sprites/flow.png -------------------------------------------------------------------------------- /Assets/Examples/Sprites/flow.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9da0e44cf4ad2b4688d504daaffa3d6 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 13 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | flipGreenChannel: 0 24 | isReadable: 0 25 | streamingMipmaps: 0 26 | streamingMipmapsPriority: 0 27 | vTOnly: 0 28 | ignoreMipmapLimit: 0 29 | grayScaleToAlpha: 0 30 | generateCubemap: 6 31 | cubemapConvolution: 0 32 | seamlessCubemap: 0 33 | textureFormat: 1 34 | maxTextureSize: 2048 35 | textureSettings: 36 | serializedVersion: 2 37 | filterMode: 1 38 | aniso: 1 39 | mipBias: 0 40 | wrapU: 1 41 | wrapV: 1 42 | wrapW: 1 43 | nPOTScale: 0 44 | lightmap: 0 45 | compressionQuality: 50 46 | spriteMode: 1 47 | spriteExtrude: 1 48 | spriteMeshType: 1 49 | alignment: 0 50 | spritePivot: {x: 0.5, y: 0.5} 51 | spritePixelsToUnits: 50 52 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 53 | spriteGenerateFallbackPhysicsShape: 1 54 | alphaUsage: 1 55 | alphaIsTransparency: 1 56 | spriteTessellationDetail: -1 57 | textureType: 8 58 | textureShape: 1 59 | singleChannelComponent: 0 60 | flipbookRows: 1 61 | flipbookColumns: 1 62 | maxTextureSizeSet: 0 63 | compressionQualitySet: 0 64 | textureFormatSet: 0 65 | ignorePngGamma: 0 66 | applyGammaDecoding: 0 67 | swizzle: 50462976 68 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: Standalone 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | spriteSheet: 97 | serializedVersion: 2 98 | sprites: [] 99 | outline: [] 100 | physicsShape: [] 101 | bones: [] 102 | spriteID: 5e97eb03825dee720800000000000000 103 | internalID: 0 104 | vertices: [] 105 | indices: 106 | edges: [] 107 | weights: [] 108 | secondaryTextures: [] 109 | nameFileIdTable: {} 110 | mipmapLimitGroupName: 111 | pSDRemoveMatte: 0 112 | userData: 113 | assetBundleName: 114 | assetBundleVariant: 115 | -------------------------------------------------------------------------------- /Assets/Examples/Sprites/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lycheelabs/Flow-Tiles/5684bdcae0e519d599dd01cda0f56875df9699db/Assets/Examples/Sprites/wall.png -------------------------------------------------------------------------------- /Assets/Examples/Sprites/wall.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eab6f1efabfd4c45a9d396029b61ce5 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 13 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | flipGreenChannel: 0 24 | isReadable: 0 25 | streamingMipmaps: 0 26 | streamingMipmapsPriority: 0 27 | vTOnly: 0 28 | ignoreMipmapLimit: 0 29 | grayScaleToAlpha: 0 30 | generateCubemap: 6 31 | cubemapConvolution: 0 32 | seamlessCubemap: 0 33 | textureFormat: 1 34 | maxTextureSize: 2048 35 | textureSettings: 36 | serializedVersion: 2 37 | filterMode: 1 38 | aniso: 1 39 | mipBias: 0 40 | wrapU: 1 41 | wrapV: 1 42 | wrapW: 1 43 | nPOTScale: 0 44 | lightmap: 0 45 | compressionQuality: 50 46 | spriteMode: 1 47 | spriteExtrude: 1 48 | spriteMeshType: 1 49 | alignment: 0 50 | spritePivot: {x: 0.5, y: 0.5} 51 | spritePixelsToUnits: 50 52 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 53 | spriteGenerateFallbackPhysicsShape: 1 54 | alphaUsage: 1 55 | alphaIsTransparency: 1 56 | spriteTessellationDetail: -1 57 | textureType: 8 58 | textureShape: 1 59 | singleChannelComponent: 0 60 | flipbookRows: 1 61 | flipbookColumns: 1 62 | maxTextureSizeSet: 0 63 | compressionQualitySet: 0 64 | textureFormatSet: 0 65 | ignorePngGamma: 0 66 | applyGammaDecoding: 0 67 | swizzle: 50462976 68 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: Standalone 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | spriteSheet: 97 | serializedVersion: 2 98 | sprites: [] 99 | outline: [] 100 | physicsShape: [] 101 | bones: [] 102 | spriteID: 5e97eb03825dee720800000000000000 103 | internalID: 0 104 | vertices: [] 105 | indices: 106 | edges: [] 107 | weights: [] 108 | secondaryTextures: [] 109 | nameFileIdTable: {} 110 | mipmapLimitGroupName: 111 | pSDRemoveMatte: 0 112 | userData: 113 | assetBundleName: 114 | assetBundleVariant: 115 | -------------------------------------------------------------------------------- /Assets/FlowTiles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89fc657ebe46b574ca6e484e12f3f5ec 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6356133a998e2464282712f570d272ea 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab7bf6caf9747d947b891c141136b6cb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CacheKeys.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | namespace FlowTiles.ECS { 4 | 5 | public static class CacheKeys { 6 | 7 | public static int4 ToFlowKey(int2 start, int2 direction, int travelType) { 8 | var directionIndex = direction.x + direction.y * 3; 9 | return new int4(start, directionIndex, travelType); 10 | } 11 | 12 | public static int4 ToPathKey(int2 start, int2 dest, int2 levelSize, int travelType) { 13 | return new int4(CellToIndex(start, levelSize), CellToIndex(dest, levelSize), travelType, 0); 14 | } 15 | 16 | public static bool DestMatchesPathKey(int2 dest, int2 levelSize, int4 key) { 17 | return CellToIndex(dest, levelSize) == key.y; 18 | } 19 | 20 | public static int2 ToDestCell(int4 key, int2 levelSize) { 21 | return IndexToCell(key.y, levelSize); 22 | } 23 | 24 | // ------------------------------------------------------- 25 | private static int CellToIndex(int2 cell, int2 levelSize) { 26 | return cell.x + cell.y * levelSize.x; 27 | } 28 | private static int2 IndexToCell(int index, int2 levelSize) { 29 | return new int2((index % levelSize.x), (index / levelSize.x)); 30 | } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CacheKeys.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67beb91bd10d1444abc6a02c60320204 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedFlowField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FlowTiles.FlowFields; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct CachedFlowField { 6 | 7 | public bool IsPending; 8 | public bool HasBeenQueued; 9 | 10 | public FlowField FlowField; 11 | 12 | public void Dispose() { 13 | FlowField.Dispose(); 14 | } 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedFlowField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6d97a289c51b8a4583743739609a318 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedPortalPath.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections.LowLevel.Unsafe; 2 | using FlowTiles.PortalPaths; 3 | using System; 4 | 5 | namespace FlowTiles.ECS { 6 | public struct CachedPortalPath { 7 | 8 | public bool IsPending; 9 | public bool HasBeenQueued; 10 | 11 | public int GraphVersionAtSearch; 12 | public UnsafeList Nodes; 13 | 14 | public void Dispose() { 15 | Nodes.Dispose(); 16 | } 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedPortalPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57b836be06b1e2747a1c7d0082747112 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedSightline.cs: -------------------------------------------------------------------------------- 1 | namespace FlowTiles.ECS { 2 | public struct CachedSightline { 3 | 4 | public bool IsPending; 5 | public bool HasBeenQueued; 6 | 7 | public bool WasFound; 8 | public int GraphVersionAtSearch; 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/CachedSightline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c78959e5a7970b94183c7d42b7b82cb4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/FlowCache.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using Unity.Collections; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | public struct FlowCache { 8 | 9 | private NativeHashMap Cache; 10 | private NativeHashMap> Lookup; 11 | 12 | public FlowCache (int capacity) { 13 | Cache = new NativeHashMap(capacity, Allocator.Persistent); 14 | Lookup = new NativeHashMap>(capacity, Allocator.Persistent); 15 | } 16 | 17 | /// Returns whether the given key has been cached 18 | public bool ContainsField (int4 key) { 19 | return Cache.ContainsKey(key); 20 | } 21 | 22 | /// Retrieves a flow tile with the given key 23 | public bool TryGetField (int4 key, out CachedFlowField flowField) { 24 | return Cache.TryGetValue(key, out flowField); 25 | } 26 | 27 | /// Caches a flow tile with the given sector and key 28 | public void StoreField (int sectorIndex, int4 key, CachedFlowField item) { 29 | if (TryGetField(key, out var existing)) { 30 | existing.Dispose(); 31 | Cache[key] = item; 32 | return; 33 | } 34 | 35 | // Store key in lookup 36 | var hasLookup = Lookup.TryGetValue(sectorIndex, out var keys); 37 | if (!hasLookup) { 38 | keys = new UnsafeList(Constants.EXPECTED_MAX_EXITS, Allocator.Persistent); 39 | } 40 | keys.Add(key); 41 | Lookup[sectorIndex] = keys; 42 | 43 | // Store field in cache 44 | Cache[key] = item; 45 | } 46 | 47 | /// Clears all flow tiles for the given sector 48 | public void ClearSector (int sectorIndex) { 49 | var exists = Lookup.TryGetValue(sectorIndex, out var keys); 50 | if (exists) { 51 | foreach (var key in keys) { 52 | var flowField = Cache[key]; 53 | flowField.Dispose(); 54 | Cache.Remove(key); 55 | } 56 | keys.Dispose(); 57 | Lookup.Remove(sectorIndex); 58 | } 59 | } 60 | 61 | public void Dispose() { 62 | var cacheValues = Cache.GetValueArray(Allocator.Temp); 63 | foreach (var value in cacheValues) { 64 | value.Dispose(); 65 | } 66 | var lookupValues = Lookup.GetValueArray(Allocator.Temp); 67 | foreach (var value in lookupValues) { 68 | value.Dispose(); 69 | } 70 | Cache.Dispose(); 71 | Lookup.Dispose(); 72 | } 73 | 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/FlowCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12e1b9911846ba942a7088a754c4a161 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/FlowRequest.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct FlowRequest : IBufferElementData { 6 | 7 | public int2 goalCell; 8 | public int2 goalDirection; 9 | public int travelType; 10 | 11 | public int4 CacheKey => CacheKeys.ToFlowKey(goalCell, goalDirection, travelType); 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/FlowRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2613c262ec79a8d45bcfaa62f386b637 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/LineCache.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using Unity.Collections; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | public struct LineCache { 7 | 8 | private NativeHashMap Cache; 9 | 10 | public LineCache(int capacity) { 11 | Cache = new NativeHashMap(capacity, Allocator.Persistent); 12 | } 13 | 14 | /// Returns whether the given line has been cached 15 | public bool ContainsLine(int4 key, int graphVersion) { 16 | if (Cache.TryGetValue(key, out CachedSightline value)) { 17 | return value.GraphVersionAtSearch == graphVersion; 18 | } 19 | return false; 20 | } 21 | 22 | /// Returns the cached sightline data 23 | public bool TryGetSightline(int4 key, int graphVersion, out CachedSightline existing) { 24 | existing = default; 25 | if (Cache.TryGetValue(key, out CachedSightline value)) { 26 | if (graphVersion != value.GraphVersionAtSearch) { 27 | return false; 28 | } 29 | existing = value; 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | /// Caches a line with the given key 36 | public void SetSightline(int4 key, CachedSightline line) { 37 | Cache[key] = line; 38 | } 39 | 40 | /// Clears all cached lines 41 | public void ClearAllLines () { 42 | Cache.Clear(); 43 | } 44 | 45 | public void Dispose() { 46 | Cache.Dispose(); 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/LineCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 181e1413df4b57345b1812f6394119b2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/LineRequest.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct LineRequest : IBufferElementData { 6 | 7 | public int2 startCell; 8 | public int2 endCell; 9 | public int2 levelSize; 10 | public int travelType; 11 | 12 | public int4 CacheKey => CacheKeys.ToPathKey(startCell, endCell, levelSize, travelType); 13 | 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/LineRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3ad5a1dd7b05144daccb8cf31947207 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/PathCache.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using Unity.Collections; 3 | using System; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | public struct PathCache { 8 | 9 | private int Capacity; 10 | private NativeHashMap Cache; 11 | private NativeQueue Queue; 12 | 13 | public PathCache(int capacity) { 14 | Capacity = capacity; 15 | Cache = new NativeHashMap(capacity, Allocator.Persistent); 16 | Queue = new NativeQueue(Allocator.Persistent); 17 | } 18 | 19 | /// Returns whether the given key has been cached 20 | public bool ContainsPath(int4 key) { 21 | return Cache.ContainsKey(key); 22 | } 23 | 24 | /// Retrieves a flow tile with the given key 25 | public bool TryGetPath(int4 key, out CachedPortalPath path) { 26 | return Cache.TryGetValue(key, out path); 27 | } 28 | 29 | /// Caches a path with the given key 30 | public void StorePath(int4 key, CachedPortalPath item) { 31 | 32 | // If full, deallocate the oldest 33 | if (Cache.Count >= Capacity) { 34 | while (Queue.Count > 0) { 35 | var last = Queue.Dequeue(); 36 | if (Cache.TryGetValue(last, out var lastPath)) { 37 | lastPath.Dispose(); 38 | Cache.Remove(last); 39 | break; 40 | } 41 | } 42 | } 43 | 44 | // If the key exists, replace the path 45 | if (TryGetPath(key, out var existing)) { 46 | existing.Dispose(); 47 | Cache[key] = item; 48 | return; 49 | } 50 | 51 | // Add to the cache 52 | Cache[key] = item; 53 | Queue.Enqueue(key); 54 | 55 | } 56 | 57 | /// Disposes and removes the path with the given key 58 | public void DisposePath(int4 key) { 59 | if (Cache.ContainsKey(key)) { 60 | Cache[key].Dispose(); 61 | Cache.Remove(key); 62 | } 63 | } 64 | 65 | public void Dispose() { 66 | var cacheValues = Cache.GetValueArray(Allocator.Temp); 67 | foreach (var value in cacheValues) { 68 | value.Dispose(); 69 | } 70 | Cache.Dispose(); 71 | Queue.Dispose(); 72 | } 73 | 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/PathCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 508fb59abcf18e94e8f1eba54b4807b6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/PathRequest.cs: -------------------------------------------------------------------------------- 1 |  2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | public struct PathRequest : IBufferElementData { 8 | 9 | public int2 originCell; 10 | public int2 destCell; 11 | public int2 levelSize; 12 | public int travelType; 13 | 14 | public int4 CacheKey => CacheKeys.ToPathKey(originCell, destCell, levelSize, travelType); 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Caches/PathRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 055a0c63168145240a42a8e6ae83061e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4954cde06101be245adef3ea5bdb0eca 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | public struct FlowData : IComponentData { 7 | 8 | public int2 cell; 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a64e3dba7f628024dbed329c6043030e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowDebugData.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.FlowFields; 2 | using Unity.Entities; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | // Only attach this component to visualise flow data for debugging 7 | public struct FlowDebugData : IComponentData { 8 | 9 | public FlowField CurrentFlowTile; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowDebugData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f86a63ad77ce04f4b8d1b3d1047b7820 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowDirection.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | // This component returns the current flow direction for use by other systems 7 | public struct FlowDirection : IComponentData { 8 | 9 | public float2 Direction; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowDirection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f54e3950bac9e2458ff026135b6a951 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowGoal.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | // Update this component to start/stop pathfinding or change your destination. 7 | public struct FlowGoal : IComponentData { 8 | 9 | public bool HasGoal; 10 | 11 | public int2 Goal; 12 | public int TravelType; 13 | public PathSmoothingMode SmoothingMode; 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowGoal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32670f675d2268748ada1088c4e301ac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowPosition.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using Unity.VisualScripting; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | // This component lets the pathfinder know which tile to search from. 8 | // Important: Update this every time the agent moves! 9 | public struct FlowPosition : IComponentData { 10 | 11 | public float2 Position; 12 | public int2 PositionCell => new int2( 13 | (int) math.round(Position.x), 14 | (int) math.round(Position.y)); 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowPosition.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 260601fd7944b754294703b9f14375cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowProgress.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | public struct FlowProgress : IComponentData { 7 | 8 | // Follow the path 9 | public bool HasPath; 10 | public int4 PathKey; 11 | public int NodeIndex; 12 | 13 | // Follow the flow 14 | public bool HasFlow; 15 | public int4 FlowKey; 16 | 17 | // Follow the sightline 18 | public int4 KnownSightlineKey; 19 | public int4 NewSightlineKey; 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/FlowProgress.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d6d4ffb674934d4a87090d89ddac4fd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/GlobalPathfindingData.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using Unity.Entities; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct GlobalPathfindingData : IComponentData { 6 | 7 | public bool IsInitialised; 8 | public PathableLevel Level; 9 | public PathableGraph Graph; 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/GlobalPathfindingData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0125c02b095c934390382088591ff92 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/InvalidPathData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct InvalidPathData : IComponentData { 6 | 7 | public int4 Key; 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/InvalidPathData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bc29c6db47c94d4f8fa79c61bce8296 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingFlowData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct MissingFlowData : IComponentData { 6 | 7 | public int SectorIndex; 8 | 9 | public int2 Cell; 10 | public int2 Direction; 11 | public int TravelType; 12 | 13 | public int4 Key => CacheKeys.ToFlowKey(Cell, Direction, TravelType); 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingFlowData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce3b1d6a186ba01449828435542a1014 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingPathData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct MissingPathData : IComponentData { 6 | 7 | public int2 Start; 8 | public int2 Dest; 9 | public int2 LevelSize; 10 | public int TravelType; 11 | 12 | public int4 Key => CacheKeys.ToPathKey(Start, Dest, LevelSize, TravelType); 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingPathData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b83bdfeeb2aebc4ca134b746cc6cb3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingSightlineData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.ECS { 5 | public struct MissingSightlineData : IComponentData { 6 | 7 | public int2 Start; 8 | public int2 End; 9 | public int2 LevelSize; 10 | public int TravelType; 11 | 12 | public int4 Key => CacheKeys.ToPathKey(Start, End, LevelSize, TravelType); 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/MissingSightlineData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0af6d7f5e1208be4a8162de723b72ff1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/PathSmoothingMode.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace FlowTiles.ECS { 3 | 4 | public enum PathSmoothingMode { 5 | None, LookaheadOneTile, LineOfSight 6 | } 7 | 8 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Components/PathSmoothingMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e795170cda7ad4a4d8742021b82984bb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecb0bdc916b6e39458ee37a576e3bbfe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/DebugPathsJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | [BurstCompile] 8 | public partial struct DebugPathsJob : IJobEntity { 9 | 10 | [ReadOnly] public FlowCache FlowCache; 11 | 12 | [BurstCompile] 13 | private void Execute(RefRO progress, ref FlowDebugData debug) { 14 | debug.CurrentFlowTile = default; 15 | 16 | if (!progress.ValueRO.HasFlow) { 17 | return; 18 | } 19 | var foundFlow = FlowCache.TryGetField(progress.ValueRO.FlowKey, out var flow); 20 | if (!foundFlow || flow.IsPending) { 21 | return; 22 | } 23 | 24 | debug.CurrentFlowTile = flow.FlowField; 25 | } 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/DebugPathsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 742c1a2edb3229d45862872abd3caca9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindFlowsJob.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.FlowFields; 2 | using FlowTiles.PortalPaths; 3 | using FlowTiles.Utils; 4 | using Unity.Burst; 5 | using Unity.Collections; 6 | using Unity.Jobs; 7 | using Unity.Mathematics; 8 | 9 | namespace FlowTiles.ECS { 10 | 11 | [BurstCompile] 12 | public struct FindFlowsJob : IJobFor { 13 | 14 | public struct Task { 15 | 16 | [ReadOnly] public int4 CacheKey; 17 | [ReadOnly] public SectorData Sector; 18 | [ReadOnly] public CellRect GoalBounds; 19 | [ReadOnly] public int2 ExitDirection; 20 | 21 | public int IslandIndex; 22 | public UnsafeField Flow; 23 | public UnsafeField Distances; 24 | 25 | public FlowField ResultAsFlowField() { 26 | var goalCell = GoalBounds.CentreCell - Sector.Bounds.MinCell; 27 | var goalIsland = Sector.Islands.Cells[goalCell.x, goalCell.y]; 28 | 29 | return new FlowField { 30 | SectorIndex = Sector.Index, 31 | IslandIndex = goalIsland, 32 | Version = Sector.Version, 33 | Directions = Flow, 34 | Distances = Distances, 35 | Size = Sector.Bounds.SizeCells, 36 | Corner = Sector.Bounds.MinCell, 37 | }; 38 | } 39 | 40 | public void DisposeTempData() { 41 | // 42 | } 43 | 44 | public void Dispose() { 45 | Flow.Dispose(); 46 | } 47 | 48 | } 49 | 50 | public NativeArray Tasks; 51 | 52 | public FindFlowsJob (NativeArray tasks) { 53 | Tasks = tasks; 54 | } 55 | 56 | public void Execute(int index) { 57 | var task = Tasks[index]; 58 | var calculator = new FlowCalculator(task, Allocator.Temp); 59 | 60 | var flow = task.Flow; 61 | var distance = task.Distances; 62 | calculator.Calculate(ref flow, ref distance); 63 | task.Flow = flow; 64 | } 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindFlowsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c251a70d846a7846a41d6c3056b3363 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindPathsJob.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.FlowFields; 2 | using FlowTiles.PortalPaths; 3 | using FlowTiles.Utils; 4 | using Unity.Burst; 5 | using Unity.Collections; 6 | using Unity.Collections.LowLevel.Unsafe; 7 | using Unity.Jobs; 8 | using Unity.Mathematics; 9 | 10 | namespace FlowTiles.ECS { 11 | 12 | [BurstCompile] 13 | public struct FindPathsJob : IJobFor { 14 | 15 | public struct Task { 16 | [ReadOnly] public int4 CacheKey; 17 | [ReadOnly] public int2 Start; 18 | [ReadOnly] public int2 Dest; 19 | [ReadOnly] public FlowField StartField; 20 | [ReadOnly] public FlowField DestField; 21 | [ReadOnly] public int TravelType; 22 | 23 | public UnsafeArray Success; // Expecting size = 1 24 | public UnsafeList Path; 25 | 26 | public void DisposeTempData() { 27 | Success.Dispose(); 28 | } 29 | 30 | public void Dispose() { 31 | Success.Dispose(); 32 | Path.Dispose(); 33 | } 34 | 35 | } 36 | 37 | [ReadOnly] public PathableGraph Graph; 38 | public NativeArray Tasks; 39 | 40 | public FindPathsJob (PathableGraph graph, NativeArray tasks) { 41 | Graph = graph; 42 | Tasks = tasks; 43 | } 44 | 45 | [BurstCompile] 46 | public void Execute(int index) { 47 | var task = Tasks[index]; 48 | var pathfinder = new PortalPathfinder(Graph, Constants.EXPECTED_MAX_SEARCHED_NODES, Allocator.Temp); 49 | var path = task.Path; 50 | 51 | var success = pathfinder.TryFindPath(task.Start, task.StartField, task.Dest, task.DestField, task.TravelType, ref path); 52 | task.Path = path; 53 | task.Success[0] = success; 54 | Tasks[index] = task; 55 | } 56 | 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindPathsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d79e2c2f168f4d41967c5bbfc6988f8 3 | timeCreated: 1693508644 -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindSightlinesJob.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using FlowTiles.Utils; 3 | using Unity.Burst; 4 | using Unity.Collections; 5 | using Unity.Jobs; 6 | using Unity.Mathematics; 7 | 8 | namespace FlowTiles.ECS { 9 | 10 | [BurstCompile] 11 | public struct FindSightlinesJob : IJobFor { 12 | 13 | public struct Task { 14 | 15 | [ReadOnly] public int4 CacheKey; 16 | [ReadOnly] public int2 StartCell; 17 | [ReadOnly] public int2 EndCell; 18 | [ReadOnly] public int TravelType; 19 | 20 | public UnsafeArray SightlineExists; // Expecting size = 1 21 | 22 | public void DisposeTempData() { 23 | SightlineExists.Dispose(); 24 | } 25 | 26 | public void Dispose() { 27 | SightlineExists.Dispose(); 28 | } 29 | 30 | } 31 | 32 | public NativeArray Tasks; 33 | [ReadOnly] public PathableGraph Graph; 34 | 35 | public FindSightlinesJob(NativeArray tasks, PathableGraph graph) { 36 | Tasks = tasks; 37 | Graph = graph; 38 | } 39 | 40 | public void Execute(int index) { 41 | var task = Tasks[index]; 42 | var result = FlowTileUtils.HasLineOfSight( 43 | task.StartCell, 44 | task.EndCell, 45 | ref Graph, 46 | task.TravelType, 47 | precise: true); 48 | 49 | task.SightlineExists[0] = result; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FindSightlinesJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec217a1021d120140a32e765ae40ea82 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/FollowPathsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b41bee84c45a2ec49bf18435aed87176 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/InvalidatePathsJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Entities; 3 | 4 | namespace FlowTiles.ECS { 5 | 6 | [BurstCompile] 7 | public partial struct InvalidatePathsJob : IJobEntity { 8 | 9 | public PathCache PathCache; 10 | public EntityCommandBuffer ECB; 11 | 12 | [BurstCompile] 13 | private void Execute(RefRO data, Entity entity) { 14 | 15 | PathCache.DisposePath(data.ValueRO.Key); 16 | 17 | // Remove component 18 | ECB.RemoveComponent(entity); 19 | } 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/InvalidatePathsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7f172c9290c0fc418162147e6384b3b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RebuildGraphJob.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using Unity.Burst; 3 | using Unity.Collections; 4 | using Unity.Jobs; 5 | 6 | namespace FlowTiles.ECS { 7 | 8 | [BurstCompile] 9 | public struct RebuildGraphJob : IJobFor { 10 | 11 | [ReadOnly] public NativeList Requests; 12 | 13 | [NativeDisableParallelForRestriction] 14 | // This job is still safe, because the indexes in 'Requests' are used instead of the job indexes, 15 | // And these indexes are always unique. 16 | public PathableGraph Graph; 17 | 18 | [BurstCompile] 19 | public void Execute(int index) { 20 | var sectorIndex = Requests[index]; 21 | Graph.BuildSector(sectorIndex); 22 | } 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RebuildGraphJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1fd00cdeb55833489e25aee41aeb4fa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RecalculateContinentsJob.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using Unity.Burst; 3 | using Unity.Jobs; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | [BurstCompile] 8 | public struct RecalculateContinentsJob : IJob { 9 | 10 | public PathableGraph Graph; 11 | public ContinentPathfinder Pathfinder; 12 | 13 | public RecalculateContinentsJob(PathableGraph graph, ContinentPathfinder pathfinder) : this() { 14 | Graph = graph; 15 | Pathfinder = pathfinder; 16 | } 17 | 18 | [BurstCompile] 19 | public void Execute() { 20 | Pathfinder.RecalculateContinents(ref Graph); 21 | } 22 | 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RecalculateContinentsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9c8f835683510f44a074d11fd4d04b0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestFlowsJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | [BurstCompile] 8 | public partial struct RequestFlowsJob : IJobEntity { 9 | 10 | public FlowCache FlowCache; 11 | public NativeQueue FlowRequests; 12 | 13 | public EntityCommandBuffer ECB; 14 | 15 | [BurstCompile] 16 | private void Execute(RefRO data, Entity entity) { 17 | var key = data.ValueRO.Key; 18 | if (!FlowCache.ContainsField(key)) { 19 | 20 | // Request a flow be generated 21 | FlowRequests.Enqueue(new FlowRequest { 22 | goalCell = data.ValueRO.Cell, 23 | goalDirection = data.ValueRO.Direction, 24 | travelType = data.ValueRO.TravelType, 25 | }); 26 | 27 | // Store temp data in the cache 28 | var sector = data.ValueRO.SectorIndex; 29 | FlowCache.StoreField (sector, key, new CachedFlowField { 30 | IsPending = true 31 | }); 32 | 33 | } 34 | 35 | // Remove component 36 | ECB.RemoveComponent(entity); 37 | } 38 | } 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestFlowsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc656b3274c220e46a427afb2f9c2294 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestPathsJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | 6 | namespace FlowTiles.ECS { 7 | 8 | [BurstCompile] 9 | public partial struct RequestPathsJob : IJobEntity { 10 | 11 | public PathCache PathCache; 12 | public NativeQueue PathRequests; 13 | 14 | public EntityCommandBuffer ECB; 15 | 16 | [BurstCompile] 17 | private void Execute(RefRO data, Entity entity) { 18 | var key = data.ValueRO.Key; 19 | if (!PathCache.ContainsPath(key)) { 20 | 21 | // Request a path be generated 22 | PathRequests.Enqueue(new PathRequest { 23 | originCell = data.ValueRO.Start, 24 | destCell = data.ValueRO.Dest, 25 | levelSize = data.ValueRO.LevelSize, 26 | travelType = data.ValueRO.TravelType, 27 | }); 28 | 29 | // Store temp data in the cache 30 | PathCache.StorePath(key, new CachedPortalPath { 31 | IsPending = true 32 | }); 33 | 34 | } 35 | 36 | // Remove component 37 | ECB.RemoveComponent(entity); 38 | } 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestPathsJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f5ec801c0a916e45b3ba08ad901bb81 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestSightlinesJob.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | 5 | namespace FlowTiles.ECS { 6 | 7 | [BurstCompile] 8 | public partial struct RequestSightlinesJob : IJobEntity { 9 | 10 | public LineCache LineCache; 11 | public NativeQueue LineRequests; 12 | public int GraphVersion; 13 | public EntityCommandBuffer ECB; 14 | 15 | [BurstCompile] 16 | private void Execute(RefRO data, Entity entity) { 17 | var key = data.ValueRO.Key; 18 | if (!LineCache.ContainsLine(key, GraphVersion)) { 19 | 20 | // Request a sightline be generated 21 | LineRequests.Enqueue(new LineRequest { 22 | startCell = data.ValueRO.Start, 23 | endCell = data.ValueRO.End, 24 | levelSize = data.ValueRO.LevelSize, 25 | travelType = data.ValueRO.TravelType, 26 | }); 27 | 28 | // Store temp data in the cache 29 | LineCache.SetSightline(key, new CachedSightline { 30 | IsPending = true, 31 | GraphVersionAtSearch = GraphVersion, 32 | }); 33 | 34 | } 35 | 36 | // Remove component 37 | ECB.RemoveComponent(entity); 38 | } 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Jobs/RequestSightlinesJob.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76cafb61ffa65f545bc38aa589c7733d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0685afc15f3623749b235102ca119e8d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/ECS/Systems/PathfindingSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb4920ee63186034ab809e10eac780f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/FlowFields.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cc0667a4bcc4a639856d4da8595b766 3 | timeCreated: 1680353744 -------------------------------------------------------------------------------- /Assets/FlowTiles/FlowFields/FlowCalculator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 597ef49519b135d4ab7071b00728cd0b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/FlowFields/FlowField.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.Utils; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.FlowFields { 5 | 6 | public struct FlowField { 7 | 8 | public int SectorIndex; 9 | public int IslandIndex; 10 | 11 | public int2 Size; 12 | public int2 Corner; 13 | public UnsafeField Directions; 14 | public UnsafeField Distances; 15 | 16 | public int Version; 17 | 18 | public void Dispose() { 19 | Directions.Dispose(); 20 | Distances.Dispose(); 21 | } 22 | 23 | public float2 GetFlow (int x, int y) { 24 | x = math.clamp(x, 0, Size.x - 1); 25 | y = math.clamp(y, 0, Size.y - 1); 26 | return Directions[x, y]; 27 | } 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/FlowFields/FlowField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2938b9789f282a4392f19233cb95203 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Level.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6e34cc6ffb8ccd4bb881c85ed987a27 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Level/CostStamp.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.Utils; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles { 5 | 6 | public struct CostStamp { 7 | 8 | public int Width => Values.Size.x; 9 | public int Height => Values.Size.y; 10 | public int2 Size => Values.Size; 11 | 12 | private readonly NativeField Values; 13 | 14 | public CostStamp(NativeField values) { 15 | Values = values; 16 | } 17 | 18 | public CostStamp(byte[,] values) { 19 | var size = new int2(values.GetLength(0), values.GetLength(1)); 20 | Values = new NativeField(size, Unity.Collections.Allocator.Persistent); 21 | for (int x = 0; x < size.x; x++) { 22 | for (int y = 0; y < size.y; y++) { 23 | Values[x, y] = values[x, y]; 24 | } 25 | } 26 | } 27 | 28 | public byte this[int x, int y] { 29 | get => Values[x + y * Size.x]; 30 | } 31 | 32 | public void Dispose () { 33 | Values.Dispose(); 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Level/CostStamp.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a55bef5b08433e542bb38428225415f0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Level/PathableLevel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26598923780b79f44b3dca06bf426729 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Level/SectorFlags.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace FlowTiles { 4 | 5 | public struct SectorFlags { 6 | 7 | public static readonly SectorFlags Rebuild = new SectorFlags { NeedsRebuilding = true }; 8 | 9 | public bool NeedsRebuilding; 10 | public bool IsReinitialised; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Level/SectorFlags.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1219fde1dc819f64fac3e98ed97f7ff9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca3cc787e8b7114f8d12c1f285eb03f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/ContinentPathfinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 504ca97f4bc591946b906f77f0cf913b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59d8bfe018b929c4d8a756bad20a7da5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/GraphSector.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using FlowTiles.Utils; 3 | 4 | namespace FlowTiles.PortalPaths { 5 | 6 | /// 7 | /// Contains all the data representing a sub-region of the PathableGraph. 8 | /// A different copy of the data is kept for each travel type. 9 | /// 10 | public struct GraphSector { 11 | 12 | public readonly int Index; 13 | public readonly int Version; 14 | public readonly CellRect Bounds; 15 | public UnsafeArray DataSets; 16 | 17 | public GraphSector(int index, int version, CellRect boundaries, PathableLevel level, int numTravelTypes) { 18 | Index = index; 19 | Bounds = boundaries; 20 | Version = version; 21 | 22 | DataSets = new UnsafeArray(numTravelTypes, Allocator.Persistent); 23 | for (int i = 0; i < DataSets.Length; i++) { 24 | var data = new SectorData(Index, Bounds, i, version); 25 | data.Costs.Initialise(level); 26 | DataSets[i] = data; 27 | } 28 | } 29 | 30 | public bool IsCreated => DataSets.IsCreated; 31 | 32 | public SectorData GetData (int travelType) { 33 | return DataSets[travelType]; 34 | } 35 | 36 | public void UpdateData(int travelType, SectorData data) { 37 | DataSets[travelType] = data; 38 | } 39 | 40 | public void Dispose () { 41 | for (int i = 0; i < DataSets.Length; i++) { 42 | DataSets[i].Dispose(); 43 | } 44 | DataSets.Dispose(); 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/GraphSector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ce062c38c5f0bd49acc04aa45eac0c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/PathableGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2936b3be88e36eb4193b641b56c302a8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/Portal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using Unity.Mathematics; 5 | 6 | namespace FlowTiles.PortalPaths { 7 | 8 | public struct Portal { 9 | 10 | public readonly SectorCell Center; 11 | public readonly CellRect Bounds; 12 | 13 | public int Island; 14 | public int Continent; 15 | public UnsafeList Edges; 16 | 17 | public Portal(int2 corner1, int2 corner2, int sector) { 18 | Center = new SectorCell(sector, (corner1 + corner2) / 2); 19 | Bounds = new CellRect(corner1, corner2); 20 | Edges = new UnsafeList(Constants.EXPECTED_MAX_EDGES, Allocator.Persistent); 21 | Island = -1; 22 | Continent = -1; 23 | } 24 | 25 | public void Dispose() { 26 | Edges.Dispose(); 27 | } 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/Portal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85424efbb3e77ed4aab16f977259bca0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/PortalEdge.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | namespace FlowTiles.PortalPaths { 4 | 5 | public struct PortalEdge { 6 | 7 | public SectorCell start; 8 | public SectorCell end; 9 | public float weight; 10 | 11 | public bool SpansTwoSectors => end.SectorIndex != start.SectorIndex; 12 | public int2 Span => end.Cell - start.Cell; 13 | 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/PortalEdge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c99f1b4b2079ab47be812b4fb72967c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorCell.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.PortalPaths { 5 | 6 | public struct SectorCell { 7 | 8 | public int SectorIndex; 9 | public int2 Cell; 10 | 11 | public SectorCell (int sector, int2 cell) { 12 | SectorIndex = sector; 13 | Cell = cell; 14 | } 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorCell.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dee586d32b0c0944c98ac29f4a44e2a6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorCosts.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.Utils; 2 | using Unity.Collections; 3 | using Unity.Mathematics; 4 | 5 | namespace FlowTiles.PortalPaths { 6 | 7 | public struct SectorCosts { 8 | 9 | public readonly int Index; 10 | public readonly CellRect Bounds; 11 | public readonly int MovementType; 12 | 13 | public UnsafeField Cells; 14 | 15 | public SectorCosts(int index, CellRect boundaries, int movementType) { 16 | Index = index; 17 | Bounds = new CellRect(); 18 | MovementType = movementType; 19 | 20 | Bounds = boundaries; 21 | Cells = new UnsafeField(Bounds.SizeCells, Allocator.Persistent, initialiseTo: 1); 22 | } 23 | 24 | public void Initialise(PathableLevel map) { 25 | CopyCosts(map, Bounds.MinCell); 26 | } 27 | 28 | public void Dispose() { 29 | Cells.Dispose(); 30 | } 31 | 32 | public bool Contains(int2 pos) { 33 | return pos.x >= Bounds.MinCell.x && 34 | pos.x <= Bounds.MaxCell.x && 35 | pos.y >= Bounds.MinCell.y && 36 | pos.y <= Bounds.MaxCell.y; 37 | } 38 | 39 | public bool IsOpenAt(int2 pos) { 40 | var localPos = pos - Bounds.MinCell; 41 | return Contains(pos) 42 | && Cells[localPos.x, localPos.y] < PathableLevel.MAX_COST; 43 | } 44 | 45 | public byte GetCostAt(int2 pos) { 46 | var localPos = pos - Bounds.MinCell; 47 | return Cells[localPos.x, localPos.y]; 48 | } 49 | 50 | // -------------------------------------------------------------- 51 | 52 | private void CopyCosts(PathableLevel map, int2 corner) { 53 | for (int x = 0; x < Cells.Size.x; x++) { 54 | for (var y = 0; y < Cells.Size.y; y++) { 55 | Cells[x, y] = map.GetCostAt(corner.x + x, corner.y + y, MovementType); 56 | } 57 | } 58 | } 59 | 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorCosts.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f346667b6d40e44fb0bbde675b9c775 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorData.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | namespace FlowTiles.PortalPaths { 4 | 5 | public struct SectorData { 6 | 7 | public readonly int Index; 8 | public readonly CellRect Bounds; 9 | public readonly int Version; 10 | 11 | public SectorCosts Costs; 12 | public SectorIslands Islands; 13 | public SectorPortals Portals; 14 | 15 | public SectorData (int index, CellRect boundaries, int travelType, int version) { 16 | Index = index; 17 | Bounds = boundaries; 18 | Version = version; 19 | 20 | Costs = new SectorCosts(index, boundaries, travelType); 21 | Islands = new SectorIslands(index, boundaries); 22 | Portals = new SectorPortals(index, boundaries); 23 | } 24 | 25 | public void Initialise(PathableLevel level) { 26 | Costs.Initialise(level); 27 | } 28 | 29 | public void Dispose() { 30 | Costs.Dispose(); 31 | Islands.Dispose(); 32 | Portals.Dispose(); 33 | } 34 | 35 | public int GetCellIsland(int2 cell) { 36 | var localCell = cell - Bounds.MinCell; 37 | return Islands.Cells[localCell.x, localCell.y]; 38 | } 39 | 40 | public SectorRoot GetRoot(int2 cell) { 41 | var localCell = cell - Bounds.MinCell; 42 | var island = Islands.Cells[localCell.x, localCell.y]; 43 | return Portals.Roots[island - 1]; 44 | } 45 | 46 | public bool TryGetPortal(int2 cell, out Portal portal) { 47 | if (!Portals.HasExitPortalAt(cell)) { 48 | portal = default; 49 | return false; 50 | } 51 | portal = Portals.GetExitPortalAt(cell); 52 | return true; 53 | } 54 | 55 | public Portal GetPortal(int2 cell) { 56 | return Portals.GetExitPortalAt(cell); 57 | } 58 | 59 | public void SetPortal(int2 cell, Portal portal) { 60 | Portals.SetExitPortalAt(cell, portal); 61 | } 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d128413be2e5b5d43b964453c0351153 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorIslands.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e810c63c83f210e469ff5eddf6333057 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorLayout.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using UnityEngine; 3 | 4 | namespace FlowTiles.PortalPaths { 5 | public struct SectorLayout { 6 | 7 | public readonly int2 SizeCells; 8 | public readonly int2 SizeSectors; 9 | public readonly int Resolution; 10 | 11 | public SectorLayout (int2 sizeCells, int resolution) { 12 | SizeCells = sizeCells; 13 | Resolution = resolution; 14 | 15 | var sectorsW = Mathf.CeilToInt((float)sizeCells.x / resolution); 16 | var sectorsH = Mathf.CeilToInt((float)sizeCells.y / resolution); 17 | SizeSectors = new int2(sectorsW, sectorsH); 18 | } 19 | 20 | public int NumSectorsInLevel => SizeSectors.x * SizeSectors.y; 21 | public int NumCellsInSector => Resolution * Resolution; 22 | 23 | public int IndexOfCell (int2 cell) { 24 | return cell.x + SizeCells.x * cell.y; 25 | } 26 | 27 | public int IndexOfCell(int cellX, int cellY) { 28 | return cellX + SizeCells.x * cellY; 29 | } 30 | 31 | public int IndexOfSector(int2 sector) { 32 | return sector.x + SizeSectors.x * sector.y; 33 | } 34 | 35 | public int IndexOfSector(int sectorX, int sectorY) { 36 | return sectorX + SizeSectors.x * sectorY; 37 | } 38 | 39 | public int2 CellToSector(int2 cell) { 40 | return new int2(cell.x / Resolution, cell.y / Resolution); 41 | } 42 | 43 | public int2 CellToSector (int cellX, int cellY) { 44 | return new int2(cellX / Resolution, cellY / Resolution); 45 | } 46 | 47 | public int CellToSectorIndex(int2 cell) { 48 | return IndexOfSector(CellToSector(cell)); 49 | } 50 | 51 | public int CellToSectorIndex(int cellX, int cellY) { 52 | return IndexOfSector(CellToSector(cellX, cellY)); 53 | } 54 | 55 | public int2 GetMinCorner(int index) { 56 | var x = index % SizeSectors.x; 57 | var y = index / SizeSectors.x; 58 | var min = new int2(x * Resolution, y * Resolution); 59 | return min; 60 | } 61 | 62 | public CellRect GetSectorBounds(int index) { 63 | var x = index % SizeSectors.x; 64 | var y = index / SizeSectors.x; 65 | var min = new int2(x * Resolution, y * Resolution); 66 | var max = new int2( 67 | Mathf.Min(min.x + Resolution - 1, SizeCells.x - 1), 68 | Mathf.Min(min.y + Resolution - 1, SizeCells.y - 1)); 69 | return new CellRect { MinCell = min, MaxCell = max }; 70 | 71 | } 72 | 73 | public CellRect GetSectorBounds (int x, int y) { 74 | var min = new int2(x * Resolution, y * Resolution); 75 | var max = new int2( 76 | Mathf.Min(min.x + Resolution - 1, SizeCells.x - 1), 77 | Mathf.Min(min.y + Resolution - 1, SizeCells.y - 1)); 78 | return new CellRect { MinCell = min, MaxCell = max }; 79 | 80 | } 81 | 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorLayout.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f057aadaac673d247b1d0c860f2f5621 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorPortals.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f7720115c4464e40b639563700e896e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorRoot.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | 4 | namespace FlowTiles.PortalPaths { 5 | public struct SectorRoot { 6 | 7 | public readonly int SectorIndex; 8 | public readonly int Island; 9 | public int Continent; 10 | 11 | public UnsafeList Portals; 12 | 13 | public SectorRoot(int sector, int island) { 14 | SectorIndex = sector; 15 | Island = island; 16 | Continent = -1; 17 | Portals = new UnsafeList(Constants.EXPECTED_MAX_EDGES, Allocator.Persistent); 18 | } 19 | 20 | public void Dispose() { 21 | Portals.Dispose(); 22 | } 23 | 24 | public bool ConnectsToPortal(Portal portal) { 25 | return portal.Center.SectorIndex == SectorIndex && portal.Island == Island; 26 | } 27 | 28 | public bool Matches(SectorRoot other) { 29 | return SectorIndex == other.SectorIndex && Island == other.Island; 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalGraph/SectorRoot.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 666461e93e4fb5f4a89dd3ad6cd5f6d7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalPathNode.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.ECS; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.PortalPaths { 5 | 6 | public struct PortalPathNode { 7 | 8 | public static PortalPathNode NewDestNode(SectorCell dest, int version) { 9 | return new PortalPathNode { 10 | Position = dest, 11 | GoalBounds = new CellRect(dest.Cell), 12 | Direction = 0, 13 | Version = version, 14 | }; 15 | } 16 | 17 | // ---------------------------------------------------------------------- 18 | 19 | public SectorCell Position; 20 | public CellRect GoalBounds; 21 | public int2 Direction; 22 | public int Version; 23 | 24 | public int4 FlowCacheKey (int travelType) => CacheKeys.ToFlowKey(Position.Cell, Direction, travelType); 25 | 26 | } 27 | 28 | 29 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalPathNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5c704b7a618d084da026201179407ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/PortalPathfinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54e10d4024f000d4ebba3330d9c5bafa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/SectorPathfinder.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.Utils; 2 | using Unity.Collections; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace FlowTiles.PortalPaths { 7 | 8 | public struct SectorPathfinder { 9 | 10 | private NativeHashSet Visited; 11 | private NativeHashMap Parent; 12 | private NativeHashMap GScore; 13 | private NativePriorityQueue Queue; 14 | private NativeArray Directions; 15 | 16 | public SectorPathfinder(int sectorCells, Allocator allocator) { 17 | Visited = new NativeHashSet(sectorCells, allocator); 18 | Parent = new NativeHashMap(sectorCells, allocator); 19 | GScore = new NativeHashMap(sectorCells, allocator); 20 | Queue = new NativePriorityQueue(sectorCells * 2, allocator); 21 | 22 | Directions = new NativeArray(4, allocator); 23 | Directions[0] = new int2(1, 0); 24 | Directions[1] = new int2(-1, 0); 25 | Directions[2] = new int2(0, 1); 26 | Directions[3] = new int2(0, -1); 27 | } 28 | 29 | public void Dispose () { 30 | Visited.Dispose(); 31 | Parent.Dispose(); 32 | GScore.Dispose(); 33 | Queue.Dispose(); 34 | Directions.Dispose(); 35 | } 36 | 37 | public int FindTravelCost(UnsafeField costs, int2 start, int2 dest) { 38 | Visited.Clear(); 39 | Parent.Clear(); 40 | GScore.Clear(); 41 | Queue.Clear(); 42 | 43 | GScore[start] = 0; 44 | Queue.Enqueue(new PathfinderNode(start, EuclidianDistance(start, dest))); 45 | int2 current; 46 | 47 | while (!Queue.IsEmpty) { 48 | current = Queue.Dequeue().Position; 49 | 50 | if (current.Equals(dest)) { 51 | //Rebuild path and return it 52 | return GScore[current]; 53 | } 54 | 55 | Visited.Add(current); 56 | 57 | //Visit all neighbours through edges going out of node 58 | foreach (var offset in Directions) { 59 | 60 | // Find the neighbor cell 61 | var next = current + offset; 62 | if (next.x < 0 || next.y < 0 || 63 | next.x >= costs.Size.x || next.y >= costs.Size.y) { 64 | continue; 65 | } 66 | 67 | //Check if we visited the outer end of the edge 68 | if (Visited.Contains(next)) { 69 | continue; 70 | } 71 | 72 | // Check if the cell is passable 73 | var cost = costs[next.x, next.y]; 74 | if (cost == PathableLevel.MAX_COST) { 75 | continue; 76 | } 77 | 78 | int temp_gCost = GScore[current] + cost; 79 | 80 | //If new value is not better then do nothing 81 | if (GScore.TryGetValue(next, out int prev_gCost) && temp_gCost >= prev_gCost) 82 | continue; 83 | 84 | //Otherwise store the new value and add the destination into the queue 85 | Parent[next] = current; 86 | GScore[next] = temp_gCost; 87 | 88 | Queue.Enqueue(new PathfinderNode(next, temp_gCost + EuclidianDistance(next, dest))); 89 | } 90 | } 91 | 92 | return 0; 93 | } 94 | 95 | private static float EuclidianDistance(int2 tile1, int2 tile2) { 96 | return Mathf.Sqrt(Mathf.Pow(tile2.x - tile1.x, 2) + Mathf.Pow(tile2.y - tile1.y, 2)); 97 | } 98 | 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/PortalPaths/SectorPathfinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aab74ad9aebfb81468ba66fe30f228a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84a9cf0e537e60846940c773fd28efba 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/CellRect.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace FlowTiles { 6 | 7 | public struct CellRect { 8 | 9 | public int2 MinCell; 10 | public int2 MaxCell; 11 | 12 | public CellRect(int2 cell) { 13 | MinCell = cell; 14 | MaxCell = cell; 15 | } 16 | 17 | public CellRect (int2 min, int2 max) { 18 | MinCell = min; 19 | MaxCell = max; 20 | 21 | if (min.x > max.x || min.y > max.y) { 22 | throw new System.ArgumentException("The provided min boundary exceeds the max boundary"); 23 | } 24 | } 25 | 26 | public int WidthCells => MaxCell.x - MinCell.x + 1; 27 | public int HeightCells => MaxCell.y - MinCell.y + 1; 28 | public int2 SizeCells => MaxCell - MinCell + 1; 29 | public int2 CentreCell => (MinCell + MaxCell) / 2; 30 | public float2 CentrePoint => (float2)(MinCell + MaxCell) / 2f; 31 | 32 | public bool ContainsCell (int2 cell) { 33 | return cell.x >= MinCell.x && cell.y >= MinCell.y 34 | && cell.x <= MaxCell.x && cell.y <= MaxCell.y; 35 | } 36 | 37 | public bool ContainsCell(int2 cell, int margin) { 38 | return cell.x >= MinCell.x - margin && cell.y >= MinCell.y - margin 39 | && cell.x <= MaxCell.x + margin && cell.y <= MaxCell.y + margin; 40 | } 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/CellRect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20e6ba19787071841866f1bed3fb910e 3 | timeCreated: 1491141263 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a77cab33388a584eb3c424061c5256f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/NativeField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfcd91e8a4a4430469fb8547927c4e10 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/NativePriorityQueue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a50805ef204f04047851174cedb9dbe2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/NativeStack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a254876dd30ca8c4390f07cde1ab625c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/PathfinderNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Mathematics; 3 | 4 | namespace FlowTiles.Utils { 5 | public struct PathfinderNode : IComparable { 6 | 7 | public readonly int2 Position; 8 | public readonly float Cost; 9 | public readonly bool IsStartNode; 10 | 11 | public PathfinderNode(int2 position, float expectedCost, bool isStartNode = false) { 12 | Position = position; 13 | Cost = expectedCost; 14 | IsStartNode = isStartNode; 15 | } 16 | 17 | public int CompareTo(PathfinderNode other) { 18 | return (int)math.sign(Cost - other.Cost); 19 | } 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/PathfinderNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c73e6f50e75e6a448ac413d05d46c49e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/UnsafeArray.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | 4 | namespace FlowTiles.Utils { 5 | 6 | public struct UnsafeArray where T : unmanaged { 7 | 8 | public readonly int Length; 9 | private UnsafeList data; 10 | 11 | public UnsafeArray(int size, Allocator allocator, T initialiseTo = default) { 12 | Length = size; 13 | data = new UnsafeList(size, allocator); 14 | data.Length = size; 15 | for (int i = 0; i < size; i++) { 16 | data[i] = initialiseTo; 17 | } 18 | } 19 | 20 | public bool IsCreated => data.IsCreated; 21 | 22 | public T this[int i] { 23 | get => data[i]; 24 | set => data[i] = value; 25 | } 26 | 27 | public void Dispose () { 28 | data.Dispose(); 29 | } 30 | 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/UnsafeArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76a3a90450e90584999cb9f966ffd726 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/UnsafeField.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | using Unity.Mathematics; 4 | 5 | namespace FlowTiles.Utils { 6 | 7 | public struct UnsafeField where T : unmanaged { 8 | 9 | public readonly int2 Size; 10 | public int FlatSize; 11 | private UnsafeList data; 12 | 13 | public UnsafeField(int2 size, Allocator allocator, T initialiseTo = default) { 14 | Size = size; 15 | FlatSize = size.x * size.y; 16 | data = new UnsafeList(FlatSize, allocator); 17 | data.Length = FlatSize; 18 | 19 | InitialiseTo(initialiseTo); 20 | } 21 | 22 | public bool IsCreated => data.IsCreated; 23 | 24 | public void InitialiseTo (T value) { 25 | for (int i = 0; i < FlatSize; i++) { 26 | data[i] = value; 27 | } 28 | } 29 | 30 | public T this[int i, int j] { 31 | get => data[i + j * Size.x]; 32 | set => data[i + j * Size.x] = value; 33 | } 34 | 35 | public void Dispose() { 36 | data.Dispose(); 37 | } 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Collections/UnsafeField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee50a4b1101042b4c824182e4362ea8d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Constants.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace FlowTiles { 4 | 5 | public static class Constants { 6 | 7 | // These constants are used to provide default sizes of native collections. 8 | // Setting them smaller saves memory. Setting them too small will trigger re-sizing, which is slow. 9 | public const int EXPECTED_MAX_ISLANDS = 8; 10 | public const int EXPECTED_MAX_EXITS = 16; 11 | public const int EXPECTED_MAX_EDGES = 16; 12 | public const int EXPECTED_MAX_PATH_LENGTH = 32; 13 | public const int EXPECTED_MAX_SEARCHED_NODES = 200; 14 | 15 | // These constants help split work over multiple frames. 16 | public const int MAX_REBUILDS_PER_FRAME = 8; 17 | public const int MAX_PATHFINDS_PER_FRAME = 32; 18 | public const int MAX_FLOWFIELDS_PER_FRAME = 16; 19 | public const int MAX_SIGHTLINES_PER_FRAME = 64; 20 | 21 | // This constant limits the number of paths that will be cached. 22 | // Older paths will be disposed when the limit is reached. 23 | // If this isn't set large enough, no agents will get paths as they fight over slots. 24 | public const int MAX_CACHED_PATHS = 10000; 25 | 26 | // This constant limits how many nodes are tested in a line-of-sight check. 27 | public const int MAX_LINE_OF_SIGHT_LOOKAHEAD = 5; 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Constants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86021e606b779974aacc59226ef0d519 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/FlowTileUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e46781e4d0d6f364aa41a02a3e0bfd1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/TimerMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | 4 | namespace FlowTiles.Utils { 5 | 6 | public static class TimerMessage { 7 | 8 | private static Stack instances = new Stack(); 9 | 10 | public static void Start() { 11 | var instance = new Stopwatch(); 12 | instance.Start(); 13 | instances.Push(instance); 14 | } 15 | 16 | public static void Stop (string message) { 17 | if (instances.Count > 0) { 18 | var instance = instances.Pop(); 19 | instance.Stop(); 20 | var ms = (int)instance.Elapsed.TotalMilliseconds; 21 | UnityEngine.Debug.Log(string.Format("{0} in: {1} ms", message, ms)); 22 | } 23 | } 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/TimerMessage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0199997c82cbc9d439df1e26f30a2263 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Visualisation.cs: -------------------------------------------------------------------------------- 1 | using FlowTiles.PortalPaths; 2 | using Unity.Collections; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace FlowTiles { 7 | 8 | public static class Visualisation { 9 | 10 | public static void DrawSectors (PathableGraph graph) { 11 | var numSectors = graph.Layout.NumSectorsInLevel; 12 | for (int index = 0; index < numSectors; index++) { 13 | var sector = graph.IndexToSector(index); 14 | DrawRect(sector.Bounds, Color.blue, 0); 15 | } 16 | } 17 | 18 | public static void DrawSectorPortals (PathableGraph graph, int travelType) { 19 | var numSectors = graph.Layout.NumSectorsInLevel; 20 | for (int index = 0; index < numSectors; index++) { 21 | if (!graph.SectorIsInitialised(index)) continue; 22 | 23 | var sector = graph.IndexToSectorMap(index, travelType); 24 | var nodes = sector.Portals.Exits; 25 | for (int i = 0; i < nodes.Length; i++) { 26 | DrawRect(nodes[i].Bounds, Color.green); 27 | } 28 | } 29 | } 30 | 31 | public static void DrawSectorConnections(PathableGraph graph, int travelType) { 32 | var numSectors = graph.Layout.NumSectorsInLevel; 33 | for (int index = 0; index < numSectors; index++) { 34 | if (!graph.SectorIsInitialised(index)) continue; 35 | 36 | var sector = graph.IndexToSectorMap(index, travelType); 37 | var nodes = sector.Portals.Exits; 38 | DrawSectorConnections(nodes); 39 | } 40 | } 41 | 42 | private static void DrawSectorConnections(INativeList nodes) { 43 | for (int n = 0; n < nodes.Length; n++) { 44 | var node = nodes[n]; 45 | for (int e = 0; e < node.Edges.Length; e++) { 46 | var edge = node.Edges[e]; 47 | var pos1 = edge.start.Cell; 48 | var pos2 = edge.end.Cell; 49 | var diff = pos2 - pos1; 50 | Debug.DrawLine( 51 | new Vector3(pos1.x + 0.5f, 0, pos1.y + 0.5f), 52 | new Vector3(pos2.x + 0.5f, 0, pos2.y + 0.5f), 53 | Color.red); 54 | } 55 | } 56 | } 57 | 58 | public static void DrawPortalLink(float2 from, float2 to) { 59 | Debug.DrawLine(ToVector(from), ToVector(to), Color.green); 60 | } 61 | 62 | public static void DrawRect(CellRect bounds, Color color, float border = 0.1f) { 63 | var pos00 = ToVector(bounds.MinCell.x, bounds.MinCell.y) + new Vector3(border, 0, +border); 64 | var pos01 = ToVector(bounds.MinCell.x, bounds.MaxCell.y + 1) + new Vector3(border, 0, -border); 65 | var pos10 = ToVector(bounds.MaxCell.x + 1, bounds.MinCell.y) + new Vector3(-border, 0, +border); 66 | var pos11 = ToVector(bounds.MaxCell.x + 1, bounds.MaxCell.y + 1) + new Vector3(-border, 0, -border); 67 | 68 | Debug.DrawLine(pos00, pos01, color); 69 | Debug.DrawLine(pos00, pos10, color); 70 | Debug.DrawLine(pos11, pos01, color); 71 | Debug.DrawLine(pos11, pos10, color); 72 | } 73 | 74 | private static Vector3 ToVector(float2 cell) => new Vector3(cell.x, 0, cell.y); 75 | private static Vector3 ToVector(float x, float y) => new Vector3(x, 0, y); 76 | 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /Assets/FlowTiles/Utils/Visualisation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfe7221ab34b3864d9ef66c0ea3b8b0f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GlobalEntitiesDependencies.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 726292a3b6d95f640bf9d29af67de769 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SceneDependencyCache.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6322e5721564f9c468b92a6000301998 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SceneDependencyCache/12ee09150bce8c611a562640b944ff62.sceneWithBuildSettings: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /Assets/SceneDependencyCache/12ee09150bce8c611a562640b944ff62.sceneWithBuildSettings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12ee09150bce8c611a562640b944ff62 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SceneDependencyCache/97f89aeb4fe48824a1c880029cf250cb.sceneWithBuildSettings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lycheelabs/Flow-Tiles/5684bdcae0e519d599dd01cda0f56875df9699db/Assets/SceneDependencyCache/97f89aeb4fe48824a1c880029cf250cb.sceneWithBuildSettings -------------------------------------------------------------------------------- /Assets/SceneDependencyCache/97f89aeb4fe48824a1c880029cf250cb.sceneWithBuildSettings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97f89aeb4fe48824a1c880029cf250cb 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "2.5.2", 4 | "com.unity.entities": "1.2.3", 5 | "com.unity.entities.graphics": "1.2.3", 6 | "com.unity.feature.2d": "2.0.1", 7 | "com.unity.ide.rider": "3.0.34", 8 | "com.unity.ide.visualstudio": "2.0.22", 9 | "com.unity.inputsystem": "1.11.2", 10 | "com.unity.render-pipelines.universal": "14.0.11", 11 | "com.unity.test-framework": "1.1.33", 12 | "com.unity.textmeshpro": "3.0.7", 13 | "com.unity.timeline": "1.7.6", 14 | "com.unity.ugui": "1.0.0", 15 | "com.unity.visualscripting": "1.9.4", 16 | "com.unity.modules.ai": "1.0.0", 17 | "com.unity.modules.androidjni": "1.0.0", 18 | "com.unity.modules.animation": "1.0.0", 19 | "com.unity.modules.assetbundle": "1.0.0", 20 | "com.unity.modules.audio": "1.0.0", 21 | "com.unity.modules.cloth": "1.0.0", 22 | "com.unity.modules.director": "1.0.0", 23 | "com.unity.modules.imageconversion": "1.0.0", 24 | "com.unity.modules.imgui": "1.0.0", 25 | "com.unity.modules.jsonserialize": "1.0.0", 26 | "com.unity.modules.particlesystem": "1.0.0", 27 | "com.unity.modules.physics": "1.0.0", 28 | "com.unity.modules.physics2d": "1.0.0", 29 | "com.unity.modules.screencapture": "1.0.0", 30 | "com.unity.modules.terrain": "1.0.0", 31 | "com.unity.modules.terrainphysics": "1.0.0", 32 | "com.unity.modules.tilemap": "1.0.0", 33 | "com.unity.modules.ui": "1.0.0", 34 | "com.unity.modules.uielements": "1.0.0", 35 | "com.unity.modules.umbra": "1.0.0", 36 | "com.unity.modules.unityanalytics": "1.0.0", 37 | "com.unity.modules.unitywebrequest": "1.0.0", 38 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 39 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 40 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 41 | "com.unity.modules.unitywebrequestwww": "1.0.0", 42 | "com.unity.modules.vehicles": "1.0.0", 43 | "com.unity.modules.video": "1.0.0", 44 | "com.unity.modules.vr": "1.0.0", 45 | "com.unity.modules.wind": "1.0.0", 46 | "com.unity.modules.xr": "1.0.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 0 20 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0.1 18 | m_ClothInterCollisionStiffness: 0.2 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 26 | m_ContactPairsMode: 0 27 | m_BroadphaseType: 0 28 | m_WorldBounds: 29 | m_Center: {x: 0, y: 0, z: 0} 30 | m_Extent: {x: 250, y: 250, z: 250} 31 | m_WorldSubdivisions: 8 32 | m_FrictionType: 0 33 | m_EnableEnhancedDeterminism: 0 34 | m_EnableUnifiedHeightmaps: 1 35 | m_SolverType: 0 36 | m_DefaultMaxAngularSpeed: 50 37 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Examples/Scenes/2_AgentExample.unity 10 | guid: 8c9cfa26abfee488c85f1582747f6a02 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 1 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 5 13 | m_SpritePackerPaddingPower: 1 14 | m_Bc7TextureCompressor: 0 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp 20 | m_ProjectGenerationRootNamespace: 21 | m_EnableTextureStreamingInEditMode: 1 22 | m_EnableTextureStreamingInPlayMode: 1 23 | m_AsyncShaderCompilation: 1 24 | m_CachingShaderPreprocessor: 1 25 | m_PrefabModeAllowAutoSave: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_GameObjectNamingDigits: 1 29 | m_GameObjectNamingScheme: 0 30 | m_AssetNamingUsesSpace: 1 31 | m_UseLegacyProbeSampleCount: 0 32 | m_SerializeInlineMappingsOnOneLine: 1 33 | m_DisableCookiesInLightmapper: 1 34 | m_AssetPipelineMode: 1 35 | m_CacheServerMode: 0 36 | m_CacheServerEndpoint: 37 | m_CacheServerNamespacePrefix: default 38 | m_CacheServerEnableDownload: 1 39 | m_CacheServerEnableUpload: 1 40 | m_CacheServerEnableAuth: 0 41 | m_CacheServerEnableTls: 0 42 | -------------------------------------------------------------------------------- /ProjectSettings/EntitiesClientSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 53 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: e2ea235c1fcfe29488ed97c467a0da53, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | FilterSettings: 16 | ExcludedBakingSystemAssemblies: [] 17 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 15 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_DepthNormals: 17 | m_Mode: 1 18 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 19 | m_MotionVectors: 20 | m_Mode: 1 21 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 22 | m_LightHalo: 23 | m_Mode: 1 24 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LensFlare: 26 | m_Mode: 1 27 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 28 | m_VideoShadersIncludeMode: 2 29 | m_AlwaysIncludedShaders: 30 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 31 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 32 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 37 | m_PreloadedShaders: [] 38 | m_PreloadShadersBatchTimeLimit: -1 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} 40 | m_CustomRenderPipeline: {fileID: 11400000, guid: 681886c5eb7344803b6206f758bf0b1c, type: 2} 41 | m_TransparencySortMode: 0 42 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 43 | m_DefaultRenderingPath: 1 44 | m_DefaultMobileRenderingPath: 1 45 | m_TierSettings: [] 46 | m_LightmapStripping: 0 47 | m_FogStripping: 0 48 | m_InstancingStripping: 0 49 | m_BrgStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 1 61 | m_LightsUseColorTemperature: 1 62 | m_DefaultRenderingLayerMask: 1 63 | m_LogWhenShaderIsCompiled: 0 64 | m_SRPDefaultSettings: 65 | UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 93b439a37f63240aca3dd4e01d978a9f, type: 2} 66 | m_LightProbeOutsideHullStrategy: 0 67 | m_CameraRelativeLightCulling: 0 68 | m_CameraRelativeShadowCulling: 0 69 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 53 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_AdvancedSettingsExpanded: 1 17 | m_ScopedRegistriesSettingsExpanded: 1 18 | m_SeeAllPackageVersions: 0 19 | m_DismissPreviewPackagesInUse: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_ConfigSource: 0 29 | m_UserSelectedRegistryName: 30 | m_UserAddingNewScopedRegistry: 0 31 | m_RegistryInfoDraft: 32 | m_Modified: 0 33 | m_ErrorMessage: 34 | m_UserModificationsInstanceId: -842 35 | m_OriginalInstanceId: -844 36 | m_LoadAssets: 0 37 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_SimulationMode: 0 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2022.3.54f1 2 | m_EditorVersionWithRevision: 2022.3.54f1 (129125d4e700) 3 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "defaultInstantiationMode": 0 8 | }, 9 | { 10 | "userAdded": false, 11 | "type": "UnityEditor.Animations.AnimatorController", 12 | "defaultInstantiationMode": 0 13 | }, 14 | { 15 | "userAdded": false, 16 | "type": "UnityEngine.AnimatorOverrideController", 17 | "defaultInstantiationMode": 0 18 | }, 19 | { 20 | "userAdded": false, 21 | "type": "UnityEditor.Audio.AudioMixerController", 22 | "defaultInstantiationMode": 0 23 | }, 24 | { 25 | "userAdded": false, 26 | "type": "UnityEngine.ComputeShader", 27 | "defaultInstantiationMode": 1 28 | }, 29 | { 30 | "userAdded": false, 31 | "type": "UnityEngine.Cubemap", 32 | "defaultInstantiationMode": 0 33 | }, 34 | { 35 | "userAdded": false, 36 | "type": "UnityEngine.GameObject", 37 | "defaultInstantiationMode": 0 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEditor.LightingDataAsset", 42 | "defaultInstantiationMode": 0 43 | }, 44 | { 45 | "userAdded": false, 46 | "type": "UnityEngine.LightingSettings", 47 | "defaultInstantiationMode": 0 48 | }, 49 | { 50 | "userAdded": false, 51 | "type": "UnityEngine.Material", 52 | "defaultInstantiationMode": 0 53 | }, 54 | { 55 | "userAdded": false, 56 | "type": "UnityEditor.MonoScript", 57 | "defaultInstantiationMode": 1 58 | }, 59 | { 60 | "userAdded": false, 61 | "type": "UnityEngine.PhysicMaterial", 62 | "defaultInstantiationMode": 0 63 | }, 64 | { 65 | "userAdded": false, 66 | "type": "UnityEngine.PhysicsMaterial2D", 67 | "defaultInstantiationMode": 0 68 | }, 69 | { 70 | "userAdded": false, 71 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 72 | "defaultInstantiationMode": 0 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 77 | "defaultInstantiationMode": 0 78 | }, 79 | { 80 | "userAdded": false, 81 | "type": "UnityEngine.Rendering.VolumeProfile", 82 | "defaultInstantiationMode": 0 83 | }, 84 | { 85 | "userAdded": false, 86 | "type": "UnityEditor.SceneAsset", 87 | "defaultInstantiationMode": 1 88 | }, 89 | { 90 | "userAdded": false, 91 | "type": "UnityEngine.Shader", 92 | "defaultInstantiationMode": 1 93 | }, 94 | { 95 | "userAdded": false, 96 | "type": "UnityEngine.ShaderVariantCollection", 97 | "defaultInstantiationMode": 1 98 | }, 99 | { 100 | "userAdded": false, 101 | "type": "UnityEngine.Texture", 102 | "defaultInstantiationMode": 0 103 | }, 104 | { 105 | "userAdded": false, 106 | "type": "UnityEngine.Texture2D", 107 | "defaultInstantiationMode": 0 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Timeline.TimelineAsset", 112 | "defaultInstantiationMode": 0 113 | } 114 | ], 115 | "defaultDependencyTypeInfo": { 116 | "userAdded": false, 117 | "type": "", 118 | "defaultInstantiationMode": 1 119 | }, 120 | "newSceneOverride": 0 121 | } -------------------------------------------------------------------------------- /ProjectSettings/ShaderGraphSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 53 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | shaderVariantLimit: 128 16 | customInterpolatorErrorThreshold: 32 17 | customInterpolatorWarningThreshold: 16 18 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/URPProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_LastMaterialVersion: 7 16 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | m_PackageRequiringCoreStatsPresent: 0 27 | UnityAdsSettings: 28 | m_Enabled: 0 29 | m_InitializeOnStartup: 1 30 | m_TestMode: 0 31 | m_IosGameId: 32 | m_AndroidGameId: 33 | m_GameIds: {} 34 | m_GameId: 35 | PerformanceReportingSettings: 36 | m_Enabled: 0 37 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Lychee Game Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Flow Tiles Pathfinding (Unity DOTS 2024) 2 | 3 | This package is an implementation of the 'Flow Field Tiles' algorithm first detailed in this paper: 4 | [Crowd Pathfinding and Steering Using Flow Field Tiles.pdf](https://www.gameaipro.com/GameAIPro/GameAIPro_Chapter23_Crowd_Pathfinding_and_Steering_Using_Flow_Field_Tiles.pdf) 5 | 6 | ### I have borrowed and built upon code from other developers. 7 | - The HPA pathfinder was originally based on [this implementation](https://github.com/hugoscurti/hierarchical-pathfinding) 8 | - The NativePriotityQueue collection uses [this implementation](https://gist.github.com/StagPoint/02a845585f6900a48e9035b00f07726e) 9 | - The NativeStack collection uses [this implementation](https://github.com/jacksondunstan/NativeCollections) 10 | 11 | ### This software is provided under the MIT license, without warranty. 12 | - You are free to use this software as you please, personally and commercially. 13 | - If you republish this software edited or unedited, post it under the MIT license. 14 | - I am not responsible for anything bad that happens from using this software. 15 | - Read license.md for more information 16 | 17 | ### The Flow Tiles Algorithm 18 | This algorithm combines the benefits of Hierarchical A* Pathfinding (HPA) with Flow Field pathfinding. 19 | - The world is subdivided into sectors, which contain exits connecting them to neighbor sectors. 20 | - These exits are connected into an HPA graph. Paths through this graph can be found quickly as the graph is coarse. 21 | - To follow the found path, small flow fields are generated lazily for each sector exit as the path is followed. 22 | - Paths can be cached and flow fields can also be cached, making this very fast when many agents follow a 'similar' path (through the same sector exits). 23 | - The level can be modified, triggering a rebuild of the relevant sectors, paths and flows. 24 | - It is possible for different agent types to find different paths (like ground-based and amphibious paths). However each new agent type added is computationally expensive! 25 | - This implementation is fully DOTS compatible, making use of entities, jobs and burst to achieve high numbers of agents. 26 | 27 | ### Algorithm Weaknesses 28 | - This algorithm does not provide perfect paths. There are multiple sources of sub-optimality, resulting in artefacts like zig-zagging. This algorithm should be used when scale is more important than quality. 29 | - This algorithm works best when agents are pathing to a small number of destination points, such as a building in the middle of a base. 30 | - This algorithm does support modifying and rebuilding the level, but works best when this is infrequent (with many frames between each edit). 31 | 32 | ### Example Scenes 33 | - **Graph example:** Demonstrates the building and rebuilding of the HPA graph, with visualisation modes available. 34 | - **Agent example:** Demonstrates an agent finding and following a path. 35 | - **Terrain example:** One agent here prefers ground terrain, while the other prefers water terrain. 36 | - **Stress Test example:** This example shows huge numbers of agents pathing to a range of destination points. 37 | - **Changing Stress Test example:** This example also has moving walls, triggering regular rebuilds of the pathing data. 38 | 39 | ### Help - I opened an example scene but nothing is visible! 40 | - Depending on your version of DOTS, you may need to reimport the ECS subscene or perhaps even clear your entities cache. DOTS is still very finicky, especially when subscenes are involved. -------------------------------------------------------------------------------- /sublicense.md: -------------------------------------------------------------------------------- 1 | This software contains modified software that was originally released under the following license: 2 | 3 | Copyright (c) 2022 Hugo Scurti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------