Beispiel #1
0
 private void Update()
 {
     //Wait for ModuleManager, thanks Ippo
     if (!hasStarted && MMPatchLoader.Instance.IsReady())
     {
         Debug.Log("Ksp Solar System Start");
         hasStarted = true;
         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
         {
             //kill the mod for bad config
             Debug.Log("faild Config for the Mod ,stoped working");
             kspSystemDefinition = null;
         }
     }
 }
Beispiel #2
0
        public KspSystemDefinition GetConfigData()
        {
            KspSystemDefinition kspSystemDefinition;

            if (system_config == null)
            {
                return(null);
            }
            else
            {
                if (!system_config.HasData && !system_config_valid)
                {
                    return(null);
                }
                else
                {
                    ConfigNode     kspNode = system_config.GetNode("KSPSystem");
                    RootDefinition rootDefinition;
                    double         sun_solar_mass;
                    SunType        sun_solar_type;
                    try
                    {
                        sun_solar_mass = double.Parse(kspNode.GetNode("Root").GetValue("SolarMasses"));
                    }
                    catch
                    {
                        sun_solar_mass = 7700;
                    }
                    try
                    {
                        sun_solar_type = ((SunType)int.Parse(kspNode.GetNode("Root").GetValue("Type")));
                    }
                    catch
                    {
                        sun_solar_type = SunType.Blackhole;
                    }
                    rootDefinition = new RootDefinition(sun_solar_mass, sun_solar_type);
                    try
                    {
                        kspSystemDefinition = new KspSystemDefinition(rootDefinition,
                                                                      double.Parse(kspNode.GetNode("Kerbol").GetValue("semiMajorAxis")));
                    }
                    catch
                    {
                        kspSystemDefinition = new KspSystemDefinition(rootDefinition, 4500000000000);
                    }
                    kspSystemDefinition.Stars = getStars(kspNode.GetNode("StarSystems").GetNodes("StarSystem"));
                }
            }
            return(kspSystemDefinition);
        }
Beispiel #3
0
 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;
     }
 }
Beispiel #4
0
        public KspSystemDefinition GetConfigData()
        {
            KspSystemDefinition kspSystemDefinition;

            if (system_config == null)
            {
                return(null);
            }
            else
            {
                if (!system_config.HasData && !system_config_valid)
                {
                    return(null);
                }
                else
                {
                    UrlDir.UrlConfig[] kspNodes = GameDatabase.Instance.GetConfigs("KSPSystem");
                    if (kspNodes.Count() > 1)//TODO: Do something about this...
                    {
                        Debug.Log("There shouldn't be more than 1 KSPSystem config! Use ModuleManager to patch the existing config!");
                        return(null);
                    }
                    ConfigNode kspNode = kspNodes[0].config;
                    try
                    {
                        foreach (ConfigNode color in kspNode.GetNode("StarColors").GetNodes("StarColor"))
                        {
                            if (color.GetValue("name") != null)
                            {
                                StarColor sc = new StarColor();
                                sc.givesOffLight = (color.GetValue("GivesOffLight") ?? "true") == "true";
                                Vector4 lightColor = ConfigNode.ParseVector4(color.GetValue("LightColor") ?? "0,0,0,0");
                                sc.lightColor = new Color(lightColor.x, lightColor.y, lightColor.z, lightColor.w);
                                Vector4 emitColor0 = ConfigNode.ParseVector4(color.GetValue("EmitColor0") ?? "0,0,0,0");
                                sc.emitColor0 = new Color(emitColor0.x, emitColor0.y, emitColor0.z, emitColor0.w);
                                Vector4 emitColor1 = ConfigNode.ParseVector4(color.GetValue("EmitColor1") ?? "0,0,0,0");
                                sc.emitColor1 = new Color(emitColor1.x, emitColor1.y, emitColor1.z, emitColor1.w);
                                Vector4 sunspotColor = ConfigNode.ParseVector4(color.GetValue("SunspotColor") ?? "0,0,0,0");
                                sc.sunSpotColor = new Color(sunspotColor.x, sunspotColor.y, sunspotColor.z, sunspotColor.w);
                                Vector4 rimColor = ConfigNode.ParseVector4(color.GetValue("RimColor") ?? "0,0,0,0");
                                sc.rimColor      = new Color(rimColor.x, rimColor.y, rimColor.z, rimColor.w);
                                sc.coronaTexture = GameDatabase.Instance.GetTexture(color.GetValue("CoronaTexture") ?? "", false);
                                StarSystem.StarColors.Add(color.GetValue("name"), sc);
                                Debug.Log("Added star color " + color.GetValue("name"));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Error loading star colors: " + e);
                    }
                    RootDefinition rootDefinition;
                    double         sun_solar_mass;
                    try
                    {
                        sun_solar_mass = double.Parse(kspNode.GetNode("Root").GetValue("SolarMasses"));
                    }
                    catch
                    {
                        sun_solar_mass = 7700;
                    }
                    string rootName        = kspNode.GetNode("Root").GetValue("name") ?? "Root";
                    string rootDescription = kspNode.GetNode("Root").GetValue("BodyDescription") ?? "";
                    string rootColor       = kspNode.GetNode("Root").GetValue("StarColor") ?? "";
                    Debug.Log("Setting the root's color to " + rootColor);
                    StarColor blackHoleColor = (StarSystem.StarColors.ContainsKey(rootColor)) ? StarSystem.StarColors[rootColor] : null;
                    rootDefinition            = new RootDefinition(sun_solar_mass, blackHoleColor, rootName, rootDescription);
                    kspSystemDefinition       = new KspSystemDefinition(rootDefinition);
                    kspSystemDefinition.Stars = getStars(kspNode.GetNode("StarSystems").GetNodes("StarSystem"));
                }
            }
            return(kspSystemDefinition);
        }