コード例 #1
0
ファイル: GlowCell.cs プロジェクト: AndTheManDrew/NightVision
 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
ファイル: GlowCell.cs プロジェクト: AndTheManDrew/NightVision
 public bool NewCellNeedsUpdate(GlowCell oldCell)
 {
     return(NewCellNeedsUpdate(oldCell.dist, oldCell.oldGlow));
 }