private void Start() { Debug.Log("Ksp Solar System Start"); if (ConfigSolarNodes.Instance.IsValid("system")) { kspSystemDefinition = ConfigSolarNodes.Instance.GetConfigData(); if (kspSystemDefinition.Stars.Count == 0) { //kill the mod for bad config Debug.Log("Mod fall back , no stars found"); kspSystemDefinition = null; } else { //Load Kerbol var Kerbol = new StarSystemDefintion(); Kerbol.Name = "Kerbol"; Kerbol.Inclination = 0; Kerbol.Eccentricity = 0; Kerbol.SemiMajorAxis = kspSystemDefinition.SemiMajorAxis; Kerbol.LAN = 0; Kerbol.ArgumentOfPeriapsis = 0; Kerbol.MeanAnomalyAtEpoch = 0; Kerbol.Epoch = 0; Kerbol.Mass = 1.7565670E28; Kerbol.Radius = 261600000d; Kerbol.FlightGlobalsIndex = 200; Kerbol.StarColor = PlanetColor.Yellow; Kerbol.ScienceMultiplier = 1f; Kerbol.OrignalStar = true; Kerbol.BodyDescription = "The Sun is the most well known object in the daytime sky. Scientists have noted a particular burning sensation and potential loss of vision if it is stared at for long periods of time. This is especially important to keep in mind considering the effect shiny objects have on the average Kerbal."; kspSystemDefinition.Stars.Add(Kerbol); Debug.Log("Ksp Solar System Defintions loaded"); } } else { //kill the mod for bad config Debug.Log("faild Config for the Mod ,stoped working"); kspSystemDefinition = null; } }
public Star(StarSystemDefintion star, PSystemBody InternalStarPSB, PSystemBody InternalSunPSB) { defintion = star; var InternalStarCB = InternalStarPSB.celestialBody; //Set Star CB and PSB Parameters InternalStarPSB.name = star.Name; InternalStarPSB.flightGlobalsIndex = star.FlightGlobalsIndex; InternalStarPSB.children.Clear(); InternalStarPSB.enabled = false; InternalStarCB.bodyName = star.Name; InternalStarCB.Radius = star.Radius; InternalStarCB.CBUpdate(); //Add Star to Sun children InternalSunPSB.children.Add(InternalStarPSB); }
List <StarSystemDefintion> getStars(ConfigNode[] stars_config) { List <StarSystemDefintion> returnValue = new List <StarSystemDefintion>(); //Grab star info foreach (var star in stars_config) { if (IsStarValid(star)) { var sun = star.GetNode("Sun"); StarSystemDefintion starSystemDefintion = new StarSystemDefintion(); starSystemDefintion.Name = sun.GetNode("CelestialBody").GetValue("name"); starSystemDefintion.FlightGlobalsIndex = int.Parse(sun.GetNode("CelestialBody").GetValue("flightGlobalIndex")); starSystemDefintion.SemiMajorAxis = double.Parse(sun.GetNode("Orbit").GetValue("semiMajorAxis")); try { starSystemDefintion.BodyDescription = sun.GetNode("CelestialBody").GetValue("BodyDescription"); } catch (Exception e) { } try { starSystemDefintion.Radius = double.Parse(sun.GetNode("CelestialBody").GetValue("Radius")); } catch (Exception e) { starSystemDefintion.Radius = 261600000; } try { starSystemDefintion.StarColor = (PlanetColor) EnumUtilities.Parse(typeof(PlanetColor), sun.GetNode("CelestialBody").GetValue("StarColor")); } catch (Exception e) { starSystemDefintion.StarColor = PlanetColor.Yellow; } try { starSystemDefintion.Mass = double.Parse(sun.GetNode("CelestialBody").GetValue("Mass")); } catch (Exception e) { starSystemDefintion.Mass = 1.7565670E28; } try { starSystemDefintion.ScienceMultiplier = float.Parse(sun.GetNode("CelestialBody").GetValue("ScienceMultiplier")); } catch (Exception e) { starSystemDefintion.ScienceMultiplier = 10f; } try { starSystemDefintion.Inclination = double.Parse(sun.GetNode("Orbit").GetValue("inclination")); } catch (Exception e) { starSystemDefintion.Inclination = 0; } try { starSystemDefintion.Eccentricity = double.Parse(sun.GetNode("Orbit").GetValue("eccentricity")); } catch (Exception e) { starSystemDefintion.Eccentricity = 0; } try { starSystemDefintion.LAN = double.Parse(sun.GetNode("Orbit").GetValue("LAN")); } catch (Exception e) { starSystemDefintion.LAN = 0; } try { starSystemDefintion.ArgumentOfPeriapsis = double.Parse(sun.GetNode("Orbit").GetValue("argumentOfPeriapsis")); } catch (Exception e) { starSystemDefintion.ArgumentOfPeriapsis = 0; } try { starSystemDefintion.MeanAnomalyAtEpoch = double.Parse(sun.GetNode("Orbit").GetValue("meanAnomalyAtEpoch")); } catch (Exception e) { starSystemDefintion.MeanAnomalyAtEpoch = 0; } try { starSystemDefintion.Epoch = double.Parse(sun.GetNode("Orbit").GetValue("epoch")); } catch (Exception e) { starSystemDefintion.Epoch = 0; } returnValue.Add(starSystemDefintion); } else { Debug.Log("Star Unable be create lack requirement fields: CelestialBody/name,CelestialBody/flightGlobalIndex,Orbit/semiMajorAxis"); continue; } } return(returnValue); }
List <StarSystemDefintion> getStars(ConfigNode[] stars_config) { List <StarSystemDefintion> returnValue = new List <StarSystemDefintion>(); //Grab star info foreach (var star in stars_config) { if (IsStarValid(star)) { var sun = star.GetNode("Sun"); StarSystemDefintion starSystemDefintion = new StarSystemDefintion(); starSystemDefintion.Name = sun.GetNode("CelestialBody").GetValue("name"); starSystemDefintion.FlightGlobalsIndex = int.Parse(sun.GetNode("CelestialBody").GetValue("flightGlobalIndex")); starSystemDefintion.orbit.SemiMajorAxis = double.Parse(sun.GetNode("Orbit").GetValue("semiMajorAxis")); try { starSystemDefintion.BodyDescription = sun.GetNode("CelestialBody").GetValue("BodyDescription"); } catch (Exception) { } try { starSystemDefintion.Radius = double.Parse(sun.GetNode("CelestialBody").GetValue("Radius")); } catch (Exception) { starSystemDefintion.Radius = 261600000; } try { string color = sun.GetNode("CelestialBody").GetValue("StarColor"); Debug.Log("Setting " + star.name + "'s color to " + color); starSystemDefintion.StarColor = (StarSystem.StarColors.ContainsKey(color)) ? StarSystem.StarColors[color] : null; } catch (Exception e) { Debug.Log("failed to set color " + e); starSystemDefintion.StarColor = null; } try { starSystemDefintion.Mass = double.Parse(sun.GetNode("CelestialBody").GetValue("Mass")); } catch (Exception) { starSystemDefintion.Mass = 1.7565670E28; } try { starSystemDefintion.ScienceMultiplier = float.Parse(sun.GetNode("CelestialBody").GetValue("ScienceMultiplier")); } catch (Exception) { starSystemDefintion.ScienceMultiplier = 10f; } if (sun.GetNode("Orbit") != null) { starSystemDefintion.orbit.loadConfig(sun.GetNode("Orbit")); } else { starSystemDefintion.orbit = null; } //Planets foreach (ConfigNode planet in star.GetNodes("Planet")) { PlanetDefinition planetDef = new PlanetDefinition(); planetDef.Name = planet.GetValue("name"); if (planetDef.Name != null) { if (planet.GetNode("Orbit") != null) { planetDef.orbit.loadConfig(planet.GetNode("Orbit")); } else { planetDef.orbit = null; Debug.Log(planetDef.Name + " in " + starSystemDefintion.Name + " is missing orbit information, using original"); } starSystemDefintion.orbitingBodies.Add(planetDef); } else { Debug.Log("A planet in " + starSystemDefintion.Name + " is missing it's name!"); } } returnValue.Add(starSystemDefintion); } else { Debug.Log("Star Unable be create lack requirement fields: CelestialBody/name,CelestialBody/flightGlobalIndex,Orbit/semiMajorAxis"); continue; } } return(returnValue); }