Пример #1
0
        internal GidFileWorldGenerateTask(GidFileGenerationTask parent, NetScriptFramework.SkyrimSE.TESWorldSpace ws, string wsName)
        {
            this.Parent     = parent;
            this.WorldSpace = ws;
            this.Name       = wsName;
            _grid           = new GidFileCellGenerateTask[129 * 129];

            ugrid = Memory.ReadInt32(GidFileGenerationTask.addr_uGrids + 8);
            uhalf = ugrid / 2;
        }
Пример #2
0
        private GidFileCellGenerateTask FindBestTodo()
        {
            GidFileCellGenerateTask best = null;
            int bestCount = 0;

            int ufull = ugrid * ugrid;

            foreach (var n in this.CellTodo)
            {
                int minx = n.X - uhalf;
                int maxx = n.X + uhalf;
                int miny = n.Y - uhalf;
                int maxy = n.Y + uhalf;
                int cur  = 0;

                for (int x = minx; x <= maxx; x++)
                {
                    for (int y = miny; y <= maxy; y++)
                    {
                        var t = GetGrid(x, y);
                        if (t != null)
                        {
                            cur++;
                        }
                    }
                }

                if (cur == 0)
                {
                    throw new InvalidOperationException();
                }

                if (best == null || cur > bestCount)
                {
                    best      = n;
                    bestCount = cur;

                    if (bestCount >= ufull)
                    {
                        break;
                    }
                }
            }

            return(best);
        }
Пример #3
0
        internal void Remove(GidFileCellGenerateTask t)
        {
            if (t.Node == null)
            {
                return;
            }

            t.Node.List.Remove(t.Node);
            t.Node = null;

            int x  = t.X + 64;
            int y  = t.Y + 64;
            int ix = x * 129 + y;

            if (_grid[ix] == t)
            {
                _grid[ix] = null;
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Пример #4
0
        private void Begin()
        {
            int min = -64;
            int max = 64;

            this.TotalCellDo = 129 * 129;

            for (int x = min; x <= max; x++)
            {
                for (int y = min; y <= max; y++)
                {
                    if (this.Parent.HasDone(GidFileGenerationTask.KeyCell, this.Name, x, y))
                    {
                        this.DidCellDo++;
                        continue;
                    }

                    var cg = new GidFileCellGenerateTask(this, x, y);
                    cg.Node = this.CellTodo.AddLast(cg);
                    _grid[(x + 64) * 129 + (y + 64)] = cg;
                }
            }
        }