Exemple #1
0
        public SurfaceController(SurfaceControllerConfig config, AiNavSystem system)
        {
            Config      = config;
            AiNavSystem = system;

            Builder = new NavMeshBuilder(Config.BuildSettings, Config.AgentSettings);

            Colliders         = new NativeList <PhysicsCollider>(Allocator.Persistent);
            TilesToBuild      = new NativeQueue <NavMeshTileBounds>(Allocator.Persistent);
            BuildInputs       = new NativeQueue <NavMeshBuildInput>(Allocator.Persistent);
            CurrentTileStatus = new NativeArray <int>(1, Allocator.Persistent);
            BoxFilters        = new NativeList <BoxFilter>(Allocator.Persistent);
            MeshSourceMap     = new MeshSourceMap(Builder.BuildSettings);
            TilesSavedStatus  = new NativeArray <int>(1, Allocator.Persistent);

            TilesHandle = GCHandle.Alloc(Tiles);
            TilesPtr    = GCHandle.ToIntPtr(TilesHandle);

            RebuiltTilesHandle = GCHandle.Alloc(RebuiltTiles);
            RebuiltTilesPtr    = GCHandle.ToIntPtr(RebuiltTilesHandle);

            NavMesh = new AiNavMesh(Builder.BuildSettings.TileSize, Builder.BuildSettings.CellSize);

            bool loaded = NavMeshStoreSystem.Instance.LoadTiles(Config.SurfaceId, Tiles);

            foreach (NavMeshTile tile in Tiles.Values)
            {
                NavMesh.AddOrReplaceTile(tile.Data);
            }

            if (Config.CrowdEnabled)
            {
                CrowdController = new CrowdController(NavMesh, this);
            }

            HandlesToWaitFor = new NativeList <JobHandle>(Allocator.Persistent);

            SurfaceData.Load(this);
        }
Exemple #2
0
 public void SaveSourcesAndFilters()
 {
     SurfaceData.SaveScene(SurfaceId);
 }