Esempio n. 1
0
        /// <summary>
        /// Writes out all the data of the instance To a ConfigNode (+ the Facilities)
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="cfgNode"></param>
        internal static void WriteInstanceConfig(StaticInstance instance, ConfigNode cfgNode)
        {
            foreach (var instanceSetting in ConfigUtil.instanceFields)
            {
                if (instanceSetting.Value.GetValue(instance) == null)
                {
                    continue;
                }
                if (instanceSetting.Key == "FacilityType")
                {
                    continue;
                }
                if (instanceSetting.Key == "GrasColor" && (Color)instanceSetting.Value.GetValue(instance) == Color.clear)
                {
                    continue;
                }

                ConfigUtil.Write2CfgNode(instance, instanceSetting.Value, cfgNode);
            }

            if (instance.hasFacilities)
            {
                for (int i = 0; i < instance.myFacilities.Count; i++)
                {
                    ConfigNode facNode = cfgNode.AddNode("Facility");
                    instance.myFacilities[i].WriteConfig(facNode);
                }
            }

            if (instance.hasLauchSites)
            {
                ConfigNode lsNode = cfgNode.AddNode("LaunchSite");
                LaunchSiteParser.WriteConfig(instance.launchSite, lsNode);
            }
        }
Esempio n. 2
0
        internal void ParseLSConfig(StaticInstance instance, ConfigNode cfgNode)
        {
            staticInstance = instance;
            body = staticInstance.CelestialBody;

            if (cfgNode != null)
            {
                LaunchSiteParser.ParseConfig(this, cfgNode);
            }




            if (!string.IsNullOrEmpty(LaunchSiteLogo))
            {
                logo = UIMain.MakeSprite(LaunchSiteLogo);

                if (logo == null)
                {
                    logo = UIMain.MakeSprite(staticInstance.model.path + "/" + LaunchSiteLogo);
                }
            }
            // use default logo
            if (logo == null)
            {
                logo = UIMain.MakeSprite("KerbalKonstructs/Assets/DefaultSiteLogo");
            }

            if (!string.IsNullOrEmpty(LaunchSiteIcon))
            {

                icon = UIMain.MakeSprite(LaunchSiteIcon);
                if (icon == null)
                {
                    icon = UIMain.MakeSprite(staticInstance.model.path + "/" + LaunchSiteIcon);
                }
            }

            refLon = (float)Math.Round(KKMath.GetLongitudeInDeg(staticInstance.RadialPosition), 2);
            refLat = (float)Math.Round(KKMath.GetLatitudeInDeg(staticInstance.RadialPosition), 2);

            refAlt = (float)staticInstance.CelestialBody.GetAltitude(staticInstance.position);

        }
Esempio n. 3
0
        internal void ParseLSConfig(StaticInstance instance, ConfigNode cfgNode)
        {
            if (cfgNode != null)
            {
                LaunchSiteParser.ParseConfig(this, cfgNode);
            }

            lsGameObject = instance.gameObject;
            // this is might be slow
            staticInstance = instance;
            body           = staticInstance.CelestialBody;

            if (!string.IsNullOrEmpty(LaunchSiteLogo))
            {
                logo = GameDatabase.Instance.GetTexture(LaunchSiteLogo, false);

                if (logo == null)
                {
                    logo = GameDatabase.Instance.GetTexture(staticInstance.model.path + "/" + LaunchSiteLogo, false);
                }
            }
            // use default logo
            if (logo == null)
            {
                logo = GameDatabase.Instance.GetTexture("KerbalKonstructs/Assets/DefaultSiteLogo", false);
            }

            if (!string.IsNullOrEmpty(LaunchSiteIcon))
            {
                icon = GameDatabase.Instance.GetTexture(LaunchSiteIcon, false);

                if (icon == null)
                {
                    icon = GameDatabase.Instance.GetTexture(staticInstance.model.path + "/" + LaunchSiteIcon, false);
                }
            }

            refLon = (float)Math.Round(KKMath.GetLongitudeInDeg(staticInstance.RadialPosition), 2);
            refLat = (float)Math.Round(KKMath.GetLatitudeInDeg(staticInstance.RadialPosition), 2);

            refAlt = staticInstance.RadiusOffset;
            AttachSelector();
        }
        /// <summary>
        /// Writes out all the data of the instance To a ConfigNode (+ the Facilities)
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="cfgNode"></param>
        internal static void WriteInstanceConfig(StaticInstance instance, ConfigNode cfgNode)
        {
            foreach (var instanceSetting in ConfigUtil.instanceFields)
            {
                if (instanceSetting.Value.GetValue(instance) == null)
                {
                    continue;
                }
                if (instanceSetting.Key == "FacilityType")
                {
                    continue;
                }

                // No Longer save Legacy Values
                if (instanceSetting.Key == "RadialPosition" || instanceSetting.Key == "RadiusOffset" || instanceSetting.Key == "RotationAngle" || instanceSetting.Key == "RefLatitude" || instanceSetting.Key == "RefLongitude" || instanceSetting.Key == "IsRelativeToTerrain")
                {
                    continue;
                }

                if (instanceSetting.Key == "GrasColor" && (Color)instanceSetting.Value.GetValue(instance) == Color.clear)
                {
                    continue;
                }

                ConfigUtil.Write2CfgNode(instance, instanceSetting.Value, cfgNode);
            }

            if (instance.hasFacilities)
            {
                for (int i = 0; i < instance.myFacilities.Count; i++)
                {
                    ConfigNode facNode = cfgNode.AddNode("Facility");
                    instance.myFacilities[i].WriteConfig(facNode);
                }
            }

            if (instance.hasLauchSites)
            {
                ConfigNode lsNode = cfgNode.AddNode("LaunchSite");
                LaunchSiteParser.WriteConfig(instance.launchSite, lsNode);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Writes out all the data of the instance To a ConfigNode (+ the Facilities)
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="cfgNode"></param>
        internal static void WriteInstanceConfig(StaticInstance instance, ConfigNode cfgNode)
        {
            foreach (var instanceSetting in ConfigUtil.instanceFields)
            {
                if (instanceSetting.Value.GetValue(instance) == null)
                {
                    continue;
                }
                if (instanceSetting.Key == "FacilityType")
                {
                    continue;
                }

                // Remove legacy GrassColor values
                //if ((instanceSetting.Key == "GrasColor") || (instanceSetting.Key == "GrasTexture"))
                //{
                //    continue;
                //}

                // No Longer save Legacy Values
                if (instanceSetting.Key == "RadialPosition" || instanceSetting.Key == "RadiusOffset" || instanceSetting.Key == "RotationAngle" || instanceSetting.Key == "RefLatitude" || instanceSetting.Key == "RefLongitude" || instanceSetting.Key == "IsRelativeToTerrain")
                {
                    continue;
                }

                ConfigUtil.Write2CfgNode(instance, instanceSetting.Value, cfgNode);
            }

            if (instance.hasFacilities)
            {
                for (int i = 0; i < instance.myFacilities.Count; i++)
                {
                    ConfigNode facNode = cfgNode.AddNode("Facility");
                    instance.myFacilities[i].WriteConfig(facNode);
                }
            }

            if (instance.hasLauchSites)
            {
                ConfigNode lsNode = cfgNode.AddNode("LaunchSite");
                LaunchSiteParser.WriteConfig(instance.launchSite, lsNode);
            }

            // save unsaved grassSettings before we write everything to the instance node
            if (instance.isSpawned)
            {
                GrassColor2[] grassArray = instance.mesh.GetComponents <GrassColor2>();
                if (grassArray.Length > 0)
                {
                    instance.grassColor2Configs.Clear();
                    foreach (GrassColor2 grassColor in grassArray)
                    {
                        instance.grassColor2Configs.Add(grassColor.GiveConfig());
                    }
                }
            }
            foreach (ConfigNode grassNode in instance.grassColor2Configs)
            {
                cfgNode.AddNode("GrassColor2", grassNode);
            }
        }