Пример #1
0
        public Map2D <TNode> SectorAt(int x, int y)
        {
            var sectorPosition = new SectorPosition(x / _sectorWidth, y / _sectorHeight);

            if (!_sectors.TryGetValue(sectorPosition, out var sector))
            {
                sector = new Map2D <TNode>(_sectorWidth, _sectorHeight);
                _sectors[sectorPosition] = sector;
                _onSectorCreated?.Invoke(sector, sectorPosition.X * _sectorWidth, sectorPosition.Y * _sectorHeight);
            }

            return(sector);
        }
Пример #2
0
        public Map4D <TNode> SectorAt(int x, int y, int z, int w)
        {
            var sectorPosition = new SectorPosition(x / _sectorWidth, y / _sectorHeight, z / _sectorDepth, w / _sectorFourthDimension);

            if (!_sectors.TryGetValue(sectorPosition, out var sector))
            {
                sector = new Map4D <TNode>(_sectorWidth, _sectorHeight, _sectorDepth, _sectorFourthDimension);
                _sectors[sectorPosition] = sector;
                _onSectorCreated?.Invoke(sector, sectorPosition.X * _sectorWidth, sectorPosition.Y * _sectorHeight, sectorPosition.Z * _sectorDepth, sectorPosition.W * _sectorFourthDimension);
            }

            return(sector);
        }