private void CreateObjects(int num, StarMapObjectType type, Vector2 center) { int angle = 0; for (int i = 0; i < num; i++) { List <string> existingObjectNames = new List <string>(); foreach (StarMapObject current in this.SubSectorObjects) { existingObjectNames.Add(current.objectName); } StarMapObject newEntry = new StarMapObject(angle, out angle, center, existingObjectNames, type); angle += 40; this.SubSectorObjects.Add(newEntry); } }
public StarMapObject(int prevAngle, out int curAngle, Vector2 center, List <string> existingObjects, StarMapObjectType newObjectType = StarMapObjectType.PlanetMedium) { this.objectType = newObjectType; List <string> objectNames = existingObjects; float angle = Rand.RangeInclusive(prevAngle + 30, 330); curAngle = (int)angle; switch (this.objectType) { case (StarMapObjectType.PlanetMedium): { this.objectName = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, objectNames, false); this.x = center.x + Rand.Range(160f, 170f) * Mathf.Cos(angle); this.y = center.y - Rand.Range(160f, 170f) * Mathf.Sin(angle); this.width = 60f; this.height = 60f; this.diameter = Rand.Range(50000, 100000); return; } case (StarMapObjectType.PlanetSmall): { this.texPath = "UI/SectorMap/Planet_Small"; this.objectName = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, objectNames, false); this.x = center.x + Rand.Range(110f, 170f) * Mathf.Cos(angle); this.y = center.y - Rand.Range(110f, 170f) * Mathf.Sin(angle); this.width = 36f; this.height = 36f; this.diameter = Rand.Range(3000, 20000); return; } case (StarMapObjectType.Moon): { this.texPath = "UI/SectorMap/Moon"; this.objectName = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, objectNames, false); this.x = center.x + Rand.Range(60f, 70f) * Mathf.Cos(angle); this.y = center.y - Rand.Range(60f, 70f) * Mathf.Sin(angle); this.width = 12f; this.height = 12f; this.diameter = Rand.Range(300, 1000); return; } } }