Пример #1
0
                public HeightColorMapNoise()
                {
                    // Create the base mod
                    GameObject modObject = new GameObject("HeightColorMapNoise");

                    modObject.transform.parent = Utility.Deactivator;
                    _mod     = modObject.AddComponent <PQSMod_HeightColorMapNoise>();
                    base.mod = _mod;
                }
Пример #2
0
 public HeightColorMapNoise(PQSMod template)
 {
     _mod = template as PQSMod_HeightColorMapNoise;
     _mod.transform.parent = Utility.Deactivator;
     base.mod = _mod;
 }
Пример #3
0
 public HeightColorMapNoise()
 {
     // Create the base mod
     GameObject modObject = new GameObject("HeightColorMapNoise");
     modObject.transform.parent = Utility.Deactivator;
     _mod = modObject.AddComponent<PQSMod_HeightColorMapNoise>();
     base.mod = _mod;
 }
Пример #4
0
 public LandClassLoaderNoise(PQSMod_HeightColorMapNoise.LandClass c)
 {
     this.landClassNoise = c;
 }
            /// <summary>
            /// Writes a PQS to a new config node
            /// </summary>
            public static void WritePQSToConfigNode(PQS pqsVersion, ref ConfigNode body, bool ocean)
            {
                ConfigNode pqs = null;

                if (!ocean)
                {
                    CelestialBody cb        = pqsVersion.GetComponentInParent <CelestialBody>();
                    PQSLoader     pqsLoader = new PQSLoader(cb);
                    pqs = WriteObjectToConfigNode("PQS", ref body, pqsLoader);
                    WriteObjectToConfigNode("Material", ref pqs, pqsLoader.surfaceMaterial);
                    WriteObjectToConfigNode("FallbackMaterial", ref pqs, pqsLoader.fallbackMaterial);
                    if (pqsLoader.physicsMaterial.Value != null)
                    {
                        WriteObjectToConfigNode("PhysicsMaterial", ref pqs, pqsLoader.physicsMaterial);
                    }
                }
                else
                {
                    CelestialBody cb          = pqsVersion.parentSphere.GetComponentInParent <CelestialBody>();
                    OceanLoader   oceanLoader = new OceanLoader(cb);
                    pqs = WriteObjectToConfigNode("Ocean", ref body, oceanLoader);
                    pqs.AddValue("ocean", pqsVersion.parentSphere.mapOcean && cb.ocean);
                    pqs.AddValue("oceanColor", pqsVersion.parentSphere.mapOceanColor);
                    pqs.AddValue("oceanHeight", pqsVersion.parentSphere.mapOceanHeight);
                    pqs.AddValue("density", cb.oceanDensity);
                    WriteObjectToConfigNode("Material", ref pqs, oceanLoader.surfaceMaterial);
                    WriteObjectToConfigNode("FallbackMaterial", ref pqs, oceanLoader.fallbackMaterial);
                    WriteObjectToConfigNode("Fog", ref pqs, new FogLoader(Part.GetComponentUpwards <CelestialBody>(pqsVersion.gameObject)));
                    if (pqsVersion.gameObject.GetComponent <HazardousOcean>() != null)
                    {
                        pqsVersion.gameObject.GetComponent <HazardousOcean>().heatCurve.Save(pqs.AddNode("HazardousOcean"));
                    }
                }

                // Mods
                IEnumerable <PQSMod> mods = pqsVersion.GetComponentsInChildren <PQSMod>(true).Where(m => (ocean || m.sphere == pqsVersion) && !(m is PQSCity) && !(m is PQSCity2));

                // Get all loaded types
                IEnumerable <Type> types = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetTypes());

                if (mods.Count() != 0)
                {
                    ConfigNode modsNode = pqs.AddNode("Mods");
                    foreach (PQSMod Mod in mods)
                    {
                        // Fix PQSMods
                        PQSMod mod = Mod;

                        Type loaderType = types.FirstOrDefault(t => t.Name == Mod.GetType().Name.Replace("PQSMod_", "").Replace("PQS", ""));

                        // No loader
                        if (loaderType == null)
                        {
                            continue;
                        }

                        // Create the loader
                        object loader = Activator.CreateInstance(loaderType);

                        // Reflection, because C# being silly... :/
                        PropertyInfo info = loaderType.GetProperty("mod");
                        if (info == null)
                        {
                            continue;
                        }
                        info.SetValue(loader, mod, null);

                        // Load
                        ConfigNode           modNode      = WriteObjectToConfigNode(loaderType.Name, ref modsNode, loader);
                        IEnumerable <PQSMod> existingMods = pqsVersion.GetComponentsInChildren <PQSMod>(true).Where(m => m.GetType() == mod.GetType() && m.sphere == pqsVersion && m.name == mod.name);
                        modNode.AddValue("index", existingMods.ToList().IndexOf(mod));

                        // Submods
                        PQSMod_HeightColorMap hcm = mod as PQSMod_HeightColorMap;
                        if (hcm?.landClasses != null)
                        {
                            ConfigNode landClasses = modNode.AddNode("LandClasses");
                            foreach (PQSMod_HeightColorMap.LandClass landClass in hcm.landClasses)
                            {
                                WriteObjectToConfigNode("Class", ref landClasses, new HeightColorMap.LandClassLoader(landClass));
                            }
                        }
                        PQSMod_HeightColorMap2 hcm2 = mod as PQSMod_HeightColorMap2;
                        if (hcm2?.landClasses != null)
                        {
                            ConfigNode landClasses = modNode.AddNode("LandClasses");
                            foreach (PQSMod_HeightColorMap2.LandClass landClass in hcm2.landClasses)
                            {
                                WriteObjectToConfigNode("Class", ref landClasses, new HeightColorMap2.LandClassLoader(landClass));
                            }
                        }
                        PQSMod_HeightColorMapNoise hcmNoise = mod as PQSMod_HeightColorMapNoise;
                        if (hcmNoise?.landClasses != null)
                        {
                            ConfigNode landClasses = modNode.AddNode("LandClasses");
                            foreach (PQSMod_HeightColorMapNoise.LandClass landClass in hcmNoise.landClasses)
                            {
                                WriteObjectToConfigNode("Class", ref landClasses, new HeightColorMapNoise.LandClassLoader(landClass));
                            }
                        }
                        if (mod is PQSLandControl)
                        {
                            PQSLandControl lc = mod as PQSLandControl;
                            if (lc.altitudeSimplex != null)
                            {
                                KopernicusSimplexWrapper lcaltsimpwrap = new KopernicusSimplexWrapper(lc.altitudeBlend, lc.altitudeOctaves, lc.altitudePersistance, lc.altitudeFrequency);
                                lcaltsimpwrap.seed = lc.altitudeSeed;
                                WriteObjectToConfigNode("altitudeSimplex", ref modNode, new VertexPlanet.SimplexLoader(lcaltsimpwrap));
                            }
                            if (lc.latitudeSimplex != null)
                            {
                                KopernicusSimplexWrapper lclatsimpwrap = new KopernicusSimplexWrapper(lc.latitudeBlend, lc.latitudeOctaves, lc.latitudePersistance, lc.latitudeFrequency);
                                lclatsimpwrap.seed = lc.latitudeSeed;
                                WriteObjectToConfigNode("latitudeSimplex", ref modNode, new VertexPlanet.SimplexLoader(lclatsimpwrap));
                            }
                            if (lc.longitudeSimplex != null)
                            {
                                KopernicusSimplexWrapper lclongsimpwrap = new KopernicusSimplexWrapper(lc.longitudeBlend, lc.longitudeOctaves, lc.longitudePersistance, lc.longitudeFrequency);
                                lclongsimpwrap.seed = lc.longitudeSeed;
                                WriteObjectToConfigNode("longitudeSimplex", ref modNode, new VertexPlanet.SimplexLoader(lclongsimpwrap));
                            }
                            if (lc.landClasses != null)
                            {
                                ConfigNode landClasses = modNode.AddNode("landClasses");
                                foreach (PQSLandControl.LandClass landClass in lc.landClasses)
                                {
                                    ConfigNode lcNode = WriteObjectToConfigNode("Class", ref landClasses, new LandControl.LandClassLoader(landClass));
                                    WriteObjectToConfigNode("altitudeRange", ref lcNode, new LandControl.LerpRangeLoader(landClass.altitudeRange));
                                    KopernicusSimplexWrapper lccovsimpwrap = new KopernicusSimplexWrapper(landClass.coverageBlend, landClass.coverageOctaves, landClass.coveragePersistance, landClass.coverageFrequency);
                                    lccovsimpwrap.seed = landClass.coverageSeed;
                                    WriteObjectToConfigNode("coverageSimplex", ref lcNode, new VertexPlanet.SimplexLoader(lccovsimpwrap));
                                    WriteObjectToConfigNode("latitudeDoubleRange", ref lcNode, new LandControl.LerpRangeLoader(landClass.latitudeDoubleRange));
                                    WriteObjectToConfigNode("latitudeRange", ref lcNode, new LandControl.LerpRangeLoader(landClass.latitudeRange));
                                    WriteObjectToConfigNode("longitudeRange", ref lcNode, new LandControl.LerpRangeLoader(landClass.longitudeRange));
                                    KopernicusSimplexWrapper lcnoisesimpwrap = new KopernicusSimplexWrapper(landClass.noiseBlend, landClass.noiseOctaves, landClass.noisePersistance, landClass.noiseFrequency);
                                    lcnoisesimpwrap.seed = landClass.noiseSeed;
                                    WriteObjectToConfigNode("noiseSimplex", ref lcNode, new VertexPlanet.SimplexLoader(lcnoisesimpwrap));
                                    if (landClass.scatter != null)
                                    {
                                        ConfigNode amount = lcNode.AddNode("scatters");
                                        foreach (PQSLandControl.LandClassScatterAmount scatterAmount in landClass.scatter)
                                        {
                                            WriteObjectToConfigNode("Scatter", ref amount, new LandControl.LandClassScatterAmountLoader(scatterAmount));
                                        }
                                    }
                                }
                            }
                            if (lc.scatters != null)
                            {
                                ConfigNode scatters = modNode.AddNode("scatters");
                                foreach (PQSLandControl.LandClassScatter scatter in lc.scatters)
                                {
                                    LandControl.LandClassScatterLoader classLoader = new LandControl.LandClassScatterLoader(scatter);
                                    if (scatter.material.shader == new NormalDiffuse().shader)
                                    {
                                        classLoader.customMaterial = new NormalDiffuseLoader(scatter.material);
                                    }
                                    else if (scatter.material.shader == new NormalBumped().shader)
                                    {
                                        classLoader.customMaterial = new NormalBumpedLoader(scatter.material);
                                    }
                                    else if (scatter.material.shader == new NormalDiffuseDetail().shader)
                                    {
                                        classLoader.customMaterial = new NormalDiffuseDetailLoader(scatter.material);
                                    }
                                    else if (scatter.material.shader == new DiffuseWrapLoader().shader)
                                    {
                                        classLoader.customMaterial = new DiffuseWrapLoader(scatter.material);
                                    }
                                    else if (scatter.material.shader == new AlphaTestDiffuse().shader)
                                    {
                                        classLoader.customMaterial = new AlphaTestDiffuseLoader(scatter.material);
                                    }
                                    else if (scatter.material.shader == new AerialTransCutout().shader)
                                    {
                                        classLoader.customMaterial = new AerialTransCutoutLoader(scatter.material);
                                    }
                                    ConfigNode scatterNode = WriteObjectToConfigNode("Scatter", ref scatters, classLoader);
                                    WriteObjectToConfigNode("Material", ref scatterNode, classLoader.customMaterial);
                                    scatterNode.AddNode("Experiment");
                                }
                            }
                        }
                        if (mod is PQSMod_VertexPlanet)
                        {
                            PQSMod_VertexPlanet vp = mod as PQSMod_VertexPlanet;
                            WriteObjectToConfigNode("ContinentalSimplex", ref modNode, new PQSMod_VertexPlanet.SimplexWrapper(vp.continental));
                            WriteObjectToConfigNode("RuggednessSimplex", ref modNode, new PQSMod_VertexPlanet.SimplexWrapper(vp.continentalRuggedness));
                            WriteObjectToConfigNode("SharpnessNoise", ref modNode, new PQSMod_VertexPlanet.NoiseModWrapper(vp.continentalSharpness));
                            WriteObjectToConfigNode("SharpnessSimplexMap", ref modNode, new PQSMod_VertexPlanet.SimplexWrapper(vp.continentalSharpnessMap));
                            WriteObjectToConfigNode("TerrainTypeSimplex", ref modNode, new PQSMod_VertexPlanet.SimplexWrapper(vp.terrainType));
                            if (vp.landClasses != null)
                            {
                                ConfigNode landClasses = modNode.AddNode("LandClasses");
                                foreach (PQSMod_VertexPlanet.LandClass landClass in vp.landClasses)
                                {
                                    ConfigNode classNode = WriteObjectToConfigNode("Class", ref landClasses, new VertexPlanet.LandClassLoader(landClass));
                                    WriteObjectToConfigNode("SimplexNoiseMap", ref classNode, new PQSMod_VertexPlanet.SimplexWrapper(landClass.colorNoiseMap));
                                }
                            }
                        }
                        if (!(mod is PQSMod_OceanFX))
                        {
                            continue;
                        }
                        List <Texture2DParser> wm        = (loader as OceanFX).watermain;
                        ConfigNode             watermain = modNode.AddNode("Watermain");
                        foreach (Texture2DParser texture in wm)
                        {
                            watermain.AddValue("waterTex-" + wm.ToList().IndexOf(texture), texture.Value.name);
                        }
                    }
                }
            }