Пример #1
0
 public GlowCell(GlowCell toBeCopied)
 {
     index       = toBeCopied.index;
     dist        = toBeCopied.dist;
     oldGlow     = toBeCopied.oldGlow;
     addedColour = toBeCopied.addedColour;
 }
Пример #2
0
        public void AddOrUpdateCell(int cellIndex, int dist)
        {
            GlowCell cell = matrix.Select(selector: gcl => gcl.Find(match: gc => gc.index == cellIndex)).First();

            if (cell == null)
            {
                cell = new GlowCell {
                    index = cellIndex, dist = dist
                };
                Add(newCell: cell);
            }
            else
            {
                cell.dist = dist;
            }
        }
Пример #3
0
        public void UpdatePosition(IntVec3 newPosition)
        {
            if (newPosition == position)
            {
                return;
            }

            ticks++;
            _timer.Start();
            int diffX   = newPosition.x - position.x;
            int diffZ   = newPosition.z - position.z;
            int diffInd = diffX + ((diffZ) * mapSizeX);

            position = newPosition;
            Color32[] glowGrid = map.glowGrid.glowGrid;
            int       numRows  = movingCells.NumRows;

            for (int i = 0; i < numRows; i++)
            {
                List <GlowCell> row = movingCells[i];
                for (int j = 0; j < row.Count; j++)
                {
                    if (row[j] != null)
                    {
                        GlowCell cell = row[j];
                        cell.index += diffInd;
                        if (movingCells[i + diffZ, j + diffX] is GlowCell oldCell)
                        {
                            if (cell.NewCellNeedsUpdate(oldCell))
                            {
                                UpdateColor(cell.index, cell.addedColour, glowGrid, cell.oldGlow);
                            }
                        }
                        else
                        {
                            ApplyColour(cell.index, cell.addedColour, glowGrid, out Color32 orgColor);
                            cell.StoreOldColour(orgColor);
                        }
                    }
                }
            }
            //map.mapDrawer.MapMeshDirty(position, MapMeshFlag.GroundGlow);

            _timer.Stop();
        }
Пример #4
0
        public void Add(GlowCell newCell)
        {
            foreach (List <GlowCell> glowCells in matrix)
            {
                if (glowCells.Count == 0)
                {
                    continue;
                }

                if (newCell.index / mapWidth == glowCells[index: 0].index / mapWidth)
                {
                    glowCells.Add(item: newCell);

                    return;
                }
            }

            matrix.Add(item: new List <GlowCell>(capacity: expectedDim)
            {
                newCell
            });
        }
Пример #5
0
 public bool NewCellNeedsUpdate(GlowCell oldCell)
 {
     return(NewCellNeedsUpdate(oldCell.dist, oldCell.oldGlow));
 }