Exemplo n.º 1
0
        public CrowdController(AiNavMesh navMesh, SurfaceController surfaceController)
        {
            NavMesh = navMesh;
            AiNavSurfaceController = surfaceController;

            AiCrowd = new AiCrowd(NavMesh.DtNavMesh);
            Query   = new AiNavQuery(NavMesh, 2048);
            AiCrowd.Update(Time.time);

            UpdateClock = new GameClock(CrowdTicksPerSecond);

            AgentCount     = new NativeArray <int>(1, Allocator.Persistent);
            ReadOnlyAgents = new NativeHashMap <int, NavAgentDebug>(MaxAgents, Allocator.Persistent);
            Path           = new NativeArray <float3>(1024, Allocator.Persistent);
        }
Exemplo n.º 2
0
        public AiNavQuery(AiNavMesh navmesh, int maxNodes)
        {
            NavMeshId = navmesh.Id;

            Id = NextId;
            NextId++;

            DtQuery = Navigation.Query.Create(navmesh.DtNavMesh, maxNodes);
            if (DtQuery == IntPtr.Zero)
            {
                throw new ApplicationException("Unable to create query");
            }

            AiNavWorld.Instance.RegisterQuery(this);
        }
Exemplo n.º 3
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);
        }