/// <summary>
        /// 
        /// </summary>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="zOffset"></param>
        /// <returns></returns>
        public static Entities.Sector CreateSector(long xOffset, long yOffset, long zOffset)
        {
            Entities.Sector s = new Entities.Sector();
            s.XOffset = xOffset;
            s.YOffset = yOffset;
            s.ZOffset = zOffset;

            s.IsDirty = false;

            s.Blocks = new byte[Entities.Sector.Width * Entities.Sector.Depth * Entities.Sector.Height];

            return s;
        }
Ejemplo n.º 2
0
        public async Task SaveSelectedSectorsAsync(SaveSelectedSectorsDto selectedSectorsDto)
        {
            if (selectedSectorsDto == null)
            {
                throw new ArgumentNullException(nameof(selectedSectorsDto));
            }

            User user = unitOfWork.Users.GetUserByName(selectedSectorsDto.Name);

            if (user == null)
            {
                user = new User()
                {
                    Agreed = selectedSectorsDto.Agreed,
                    Name   = selectedSectorsDto.Name
                };
                await unitOfWork.Users.AddAsync(user);

                await unitOfWork.SaveAsync();
            }

            IEnumerable <Entities.UserSectors> userSectors = unitOfWork.UserSectors.GetSectorByUserId(user.UserId);

            if (userSectors.Any())
            {
                foreach (var userSector in userSectors)
                {
                    unitOfWork.UserSectors.Delete(userSector);
                }
            }

            foreach (var item in selectedSectorsDto.SelectedSectors)
            {
                Entities.Sector sector = unitOfWork.Sectors.GetSectorByValue(item);
                await unitOfWork.UserSectors.AddAsync(new Entities.UserSectors()
                {
                    SectorId = sector.SectorId,
                    UserId   = user.UserId
                });
            }
            await unitOfWork.SaveAsync();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static Entities.Sector GetHollowSectorFromSector(Entities.Sector s)
        {
            var ns = new Entities.Sector();
            ns.XOffset = s.XOffset;
            ns.YOffset = s.YOffset;
            ns.ZOffset = s.ZOffset;

            for (int x = 0; x < Entities.Sector.Width; x++)
            {
                for (int y = 0; y < Entities.Sector.Height; y++)
                {
                    for (int z = 0; z < Entities.Sector.Depth; z++)
                    {
                        if (GetOpenFacesInSector(s, x, y, z).Count < 6)
                            SetSectorBlock(ns, x, y, z, GetBlockFromSector(s, x, y, z));
                    }
                }
            }

            return ns;
        }