void NameRegions(Rand64 random) { for (int n = 0; n < regions.Count; n++) { regions[n].baseName = generator.GenerateName(regions[n].languageIndex, random); regions[n].displayName = generator.GenerateRegionName(regions[n].baseName, random); } }
public GalaxyCell(GalaxyGenerator generator, int cellX, int cellY, bool fullGeneration = true) { this.generator = generator; this.cellX = cellX; this.cellY = cellY; Rand64 random = new Rand64((ulong)(cellY * GalaxyGenerator.galaxySize + cellX + GalaxyGenerator.galaxySeed)); int numStars = random.Range(1, 10); for (int n = 0; n < numStars; n++) { StarSystemId id = new StarSystemId(cellX, cellY, n); StarSystem star = new StarSystem(id, random); starSystems.Add(star); } if (cellY > 0) { PickConnector(random, StarSystem.Attributes.NorthConnector); } if (cellX < GalaxyGenerator.galaxySize - 1) { PickConnector(random, StarSystem.Attributes.EastConnector); } if (cellY < GalaxyGenerator.galaxySize - 1) { PickConnector(random, StarSystem.Attributes.SouthConnector); } if (cellX > 0) { PickConnector(random, StarSystem.Attributes.WestConnector); } ConstrainPositions(); if (fullGeneration) { if (cellY > 0) { jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.NorthConnector).id, GetCell(cellX, cellY - 1).GetSystemWithAttribute(StarSystem.Attributes.SouthConnector).id)); } if (cellX < GalaxyGenerator.galaxySize - 1) { jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.EastConnector).id, GetCell(cellX + 1, cellY).GetSystemWithAttribute(StarSystem.Attributes.WestConnector).id)); } if (cellY < GalaxyGenerator.galaxySize - 1) { jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.SouthConnector).id, GetCell(cellX, cellY + 1).GetSystemWithAttribute(StarSystem.Attributes.NorthConnector).id)); } if (cellX > 0) { jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.WestConnector).id, GetCell(cellX - 1, cellY).GetSystemWithAttribute(StarSystem.Attributes.EastConnector).id)); } if (!IsFullyConnected()) { TryConnectClosest(); } int itCount = 0; while (!IsFullyConnected()) { bool avoidIntersections = itCount < 100; TryAddJumpGate(starSystems[random.Range(0, starSystems.Count)].id, starSystems[random.Range(0, starSystems.Count)].id, avoidIntersections); itCount++; } AssignRegions(); for (int n = 0; n < starSystems.Count; n++) { Region region = generator.GetRegion(starSystems[n].regionId); if ((starSystems[n].attributes & StarSystem.Attributes.Capital) != 0) { starSystems[n].name = generator.GenerateCapitalName(region, random); } else { starSystems[n].name = generator.GenerateName(region.languageIndex, random); } } } }