/// <summary> /// /// </summary> /// <param name="universe"></param> /// <param name="maxStarsPerSector"></param> /// <param name="currentLevel"></param> public Sector(Octree universe, long maxStarsPerSector, int currentLevel) { _universe = universe; CurrentLevel = currentLevel; _stars = new LinkedList<StarBufferIndex>(); MaxStarsPerSector = maxStarsPerSector; SectorTint = Color.FromArgb(_rand.Next(0, 255), _rand.Next(0, 255), _rand.Next(0, 255)).ToArgb(); _numberOfSectors++; if (CurrentLevel > LevelCount) LevelCount = CurrentLevel; }
/// <summary> /// /// </summary> private void InitUniverse() { if (_universe != null) { _universe.Clear(); _universe = null; } if (_starBufferManager != null) { _starBufferManager.Clear(); _starBufferManager = null; } _universe = new Octree(SettingsLocal.GetAsInt("MaxStarsPerSector")); List<string> galaxies = SettingsLocal.AllValuesAsString("Universe" + CurrentUniverseID() +"GalaxyID"); _starBufferManager = new StarBufferManager( SettingsLocal.GetAsInt("StarBufferSize"), GetTotalStarCount(galaxies)); var galaxyStars = new List<LinkedList<StarBufferIndex>>(galaxies.Count); foreach (string galaxyID in galaxies) { long numberfStars = SettingsLocal.GetAsLong( "Galaxy" + galaxyID + "NumberOfStars"); int distributionIterations = SettingsLocal.GetAsInt( "Galaxy" + galaxyID + "DistributionIterations"); float starVelocity = SettingsLocal.GetAsFloat("Galaxy" + galaxyID + "StarVelocity"); var stars = new LinkedList<StarBufferIndex>(); Color col = Color.FromArgb(SettingsLocal.GetAsInt("Galaxy" + galaxyID + "StarColor")); for (long a = 0; a < numberfStars; a++) { stars.AddLast(GenerateRandomStar(galaxyID, distributionIterations, starVelocity, col)); } galaxyStars.Add(stars); var blackHole = new BlackHole { PosX = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionX"), PosY = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionY"), PosZ = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionZ"), Mass = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "SupermassiveBlackHoleSolarMasses") }; _universe.AddBlackHole(blackHole); } bool anyStarsLeft = true; while (anyStarsLeft) { anyStarsLeft = false; for (int a = 0; a < galaxyStars.Count; a++) { if (galaxyStars[a].Count == 0) continue; anyStarsLeft = true; _universe.AddStar(galaxyStars[a].First.Value); galaxyStars[a].RemoveFirst(); } } }