public JobHandle OnUpdate(AiNavSystem system, JobHandle inputDeps) { if (AiNavSurfaceController.Building) { return(inputDeps); } if (UpdateClock.Tick(Time.time)) { CrowdAgentsJob updateAgentJob = new CrowdAgentsJob { Debug = GenerateAgentDebugData, AiCrowd = AiCrowd, Query = Query, ReadOnlyAgents = ReadOnlyAgents, PathLookup = system.GetBufferFromEntity <AgentPathBuffer>(false), NavQuerySettings = NavQuerySettings.Default, Path = Path }; inputDeps = updateAgentJob.ScheduleSingle(system, inputDeps); TickCrowdJob updateJob = new TickCrowdJob { DeltaTime = Time.deltaTime, AiCrowd = AiCrowd, AgentCount = AgentCount }; inputDeps = updateJob.Schedule(inputDeps); } return(inputDeps); }
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); }