private void HandleClear()
        {
            // Abort any in-progress builds.
            Context.AbortAllReqests("User requested.");

            TileBuildData tdata = Context.Build.BuildData;

            int w = tdata.Width;
            int d = tdata.Depth;

            bool needsBaking =
                (tdata.NeedsBakingCount() == 0) ? false : true;

            for (int tx = 0; tx < w; tx++)
            {
                for (int tz = 0; tz < d; tz++)
                {
                    if (needsBaking)
                    {
                        tdata.ClearUnbaked(tx, tz);
                    }
                    else
                    {
                        tdata.Reset(tx, tz);
                    }
                }
            }
        }
Beispiel #2
0
        public bool QueueTask(int tx, int tz, int priority, BuildContext logger)
        {
            // Check for existing task and purge it.

            NavmeshBuild build = Build;

            if (!build)
            {
                return(false);
            }

            TileBuildData tdata = build.BuildData;

            if (build.TileSetDefinition == null && (tx > 0 || tz > 0))
            {
                logger.LogError("Tile build requested, but no tile set found.", this);
                return(false);
            }

            if (AbortRequest(tx, tz, "Overriden by new task."))
            {
                tdata.ClearUnbaked(tx, tz);

                logger.LogWarning(string.Format(
                                      "Existing build task overridden by new task. ({0}, {1})"
                                      , tx, tz), this);
            }

            IncrementalBuilder builder;
            NMGenConfig        config = build.Config;

            if (build.TileSetDefinition == null)
            {
                InputGeometry geom = build.InputGeom;

                if (geom == null)
                {
                    logger.LogError("Input geometry not available.", this);
                    tdata.SetAsFailed(tx, tz);
                    return(false);
                }

                builder = IncrementalBuilder.Create(config.GetConfig()
                                                    , config.ResultOptions
                                                    , geom
                                                    , build.NMGenProcessors);
            }
            else
            {
                builder = IncrementalBuilder.Create(tx, tz
                                                    , config.ResultOptions
                                                    , build.TileSetDefinition
                                                    , build.NMGenProcessors);
            }

            if (builder == null)
            {
                logger.LogError(string.Format("Tile set did not produce a builder. Tile: ({0},{1})"
                                              , tx, tz)
                                , this);
                return(false);
            }

            NMGenTask task = NMGenTask.Create(builder, priority);

            if (!mTaskProcessor.QueueTask(task))
            {
                logger.LogError(string.Format("Processor rejected task. Tile: ({0},{1})"
                                              , tx, tz), this);
                return(false);
            }

            mNMGenTasks.Add(task);
            tdata.SetAsQueued(tx, tz);

            return(true);
        }