示例#1
0
        public void SetTimestamp(IntVec3 position, long timestamp = 0)
        {
            if (position.x < 0 || position.x >= mapSizeX || position.z < 0 || position.z >= mapSizeZ)
            {
                return;
            }
            var cell = grid[CellToIndex(position)];

            if (cell == null)
            {
                grid[CellToIndex(position)] = new Pheromone(timestamp);
            }
            else
            {
                grid[CellToIndex(position)].timestamp = timestamp;
            }
        }
示例#2
0
        public Pheromone GetPheromone(IntVec3 position, bool create = true)
        {
            if (position.x < 0 || position.x >= mapSizeX || position.z < 0 || position.z >= mapSizeZ)
            {
                return(null);
            }

            var idx  = (position.z * mapSizeX) + position.x;
            var cell = grid[idx];

            if (cell == null && create)
            {
                cell      = new Pheromone();
                grid[idx] = cell;
            }
            return(cell);
        }
示例#3
0
        public void ChangeZombieCount(IntVec3 position, int change)
        {
            if (position.x < 0 || position.x >= mapSizeX || position.z < 0 || position.z >= mapSizeZ)
            {
                return;
            }
            var cell = grid[CellToIndex(position)];

            if (cell == null)
            {
                grid[CellToIndex(position)] = new Pheromone()
                {
                    zombieCount = Math.Max(0, change)
                };
            }
            else
            {
                grid[CellToIndex(position)].zombieCount = Math.Max(0, cell.zombieCount + change);
            }
        }