private SystemCreator DeployAndConfigureCreatorTo(string systemName, Vector3 location, SystemDesirability systemDesirability, StarCategory starCat, IList<PlanetoidCategory> planetCatsByPlanetIndex) { float systemOrbitSlotsStartRadius; string starDesignName = MakeAndRecordStarDesign(starCat, systemDesirability, out systemOrbitSlotsStartRadius); Stack<OrbitData> innerOrbitSlots; Stack<OrbitData> goldilocksOrbitSlots; Stack<OrbitData> outerOrbitSlots; GenerateSystemOrbitSlots(systemOrbitSlotsStartRadius, out innerOrbitSlots, out goldilocksOrbitSlots, out outerOrbitSlots); OrbitData settlementOrbitSlot = goldilocksOrbitSlots.Pop(); D.AssertNotNull(settlementOrbitSlot); IList<int> unassignedPlanetIndices; IList<OrbitData> planetOrbitSlots; IList<string> planetDesignNames = MakePlanetDesignsAndOrbitSlots(planetCatsByPlanetIndex, systemDesirability, innerOrbitSlots, goldilocksOrbitSlots, outerOrbitSlots, out planetOrbitSlots, out unassignedPlanetIndices); IList<PlanetoidCategory[]> moonCatsByPlanetIndex = GetRandomMoonCats(planetCatsByPlanetIndex); if (unassignedPlanetIndices.Count > Constants.Zero) { // one or more planets could not be assigned an orbit slot and design so eliminate any moons for that planet foreach (var pIndex in unassignedPlanetIndices) { moonCatsByPlanetIndex[pIndex] = Enumerable.Empty<PlanetoidCategory>().ToArray(); planetCatsByPlanetIndex[pIndex] = default(PlanetoidCategory); } } IList<OrbitData[]> moonOrbitSlots; IList<string[]> moonDesignNames = MakeMoonDesignsAndOrbitSlots(planetCatsByPlanetIndex, moonCatsByPlanetIndex, systemDesirability, out moonOrbitSlots); SystemCreatorConfiguration config = new SystemCreatorConfiguration(systemName, starDesignName, settlementOrbitSlot, planetDesignNames, planetOrbitSlots, moonDesignNames, moonOrbitSlots); SystemCreator creator = _systemFactory.MakeCreatorInstance(location); creator.Configuration = config; return creator; }
/// <summary> /// Assigns a configuration to an existing DebugSystemCreator. The configuration is generated from /// the existing creator's EditorSettings. /// </summary> /// <param name="debugCreator">The creator.</param> /// <param name="systemName">Name of the system.</param> public void AssignConfigurationToExistingDebugCreator(DebugSystemCreator debugCreator, string systemName) { StarCategory starCat; IList<PlanetoidCategory[]> moonCatsByPlanetIndex; IList<PlanetoidCategory> planetCatsByPlanetIndex; var editorSettings = debugCreator.EditorSettings; if (editorSettings.IsCompositionPreset) { starCat = editorSettings.PresetStarCategory; planetCatsByPlanetIndex = editorSettings.PresetPlanetCategories; moonCatsByPlanetIndex = editorSettings.PresetMoonCategories; } else { starCat = Enums<StarCategory>.GetRandom(excludeDefault: true); planetCatsByPlanetIndex = RandomExtended.Choices(_acceptablePlanetCategories, editorSettings.NonPresetPlanetQty); moonCatsByPlanetIndex = GetRandomMoonCats(planetCatsByPlanetIndex); } SystemDesirability systemDesirability = editorSettings.Desirability; float systemOrbitSlotsStartRadius; string starDesignName = MakeAndRecordStarDesign(starCat, systemDesirability, out systemOrbitSlotsStartRadius); Stack<OrbitData> innerOrbitSlots; Stack<OrbitData> goldilocksOrbitSlots; Stack<OrbitData> outerOrbitSlots; GenerateSystemOrbitSlots(systemOrbitSlotsStartRadius, out innerOrbitSlots, out goldilocksOrbitSlots, out outerOrbitSlots); OrbitData settlementOrbitSlot = goldilocksOrbitSlots.Pop(); D.AssertNotNull(settlementOrbitSlot); IList<int> unassignedPlanetIndices; IList<OrbitData> planetOrbitSlots; IList<string> planetDesignNames = MakePlanetDesignsAndOrbitSlots(planetCatsByPlanetIndex, systemDesirability, innerOrbitSlots, goldilocksOrbitSlots, outerOrbitSlots, out planetOrbitSlots, out unassignedPlanetIndices); if (unassignedPlanetIndices.Count > Constants.Zero) { // one or more planets could not be assigned an orbit slot and design so eliminate any moons for that planet foreach (var pIndex in unassignedPlanetIndices) { moonCatsByPlanetIndex[pIndex] = Enumerable.Empty<PlanetoidCategory>().ToArray(); planetCatsByPlanetIndex[pIndex] = default(PlanetoidCategory); } } IList<OrbitData[]> moonOrbitSlots; IList<string[]> moonDesignNames = MakeMoonDesignsAndOrbitSlots(planetCatsByPlanetIndex, moonCatsByPlanetIndex, systemDesirability, out moonOrbitSlots); SystemCreatorConfiguration config = new SystemCreatorConfiguration(systemName, starDesignName, settlementOrbitSlot, planetDesignNames, planetOrbitSlots, moonDesignNames, moonOrbitSlots); debugCreator.Configuration = config; //D.Log(ShowDebugLog, "{0} assigned a configuration to {1}.", DebugName, creator.Name); }