Exemple #1
0
        public void Close()
        {
            if (m_providerForRules == this)
            {
                m_providerForRules = null;
            }

            // Clear to speed up collection

            m_blendingTileset    = null;
            m_subsurfaceMaterial = null;
            m_generator          = null;
            m_biomeMap           = null;
            m_biomes             = null;
            m_materials          = null;
            m_planetShape        = null;
            m_ores = null;

            m_materialMap  = null;
            m_oreMap       = null;
            m_biomeMap     = null;
            m_occlusionMap = null;

            Closed = true;
        }
Exemple #2
0
 public void Close()
 {
     this.m_blendingTileset    = null;
     this.m_subsurfaceMaterial = null;
     this.m_generator          = null;
     this.m_biomeMap           = null;
     this.m_biomes             = null;
     this.m_materials          = null;
     this.m_planetShape        = null;
     this.m_ores        = null;
     this.m_materialMap = null;
     this.m_oreMap      = null;
     this.m_biomeMap    = null;
     this.Maps          = null;
     this.Closed        = true;
 }
Exemple #3
0
 public MyPlanetMaterialProvider(MyPlanetGeneratorDefinition generatorDef, MyPlanetShapeProvider planetShape, MyCubemap[] maps)
 {
     this.m_materials = new Dictionary <byte, PlanetMaterial>(generatorDef.SurfaceMaterialTable.Length);
     for (int i = 0; i < generatorDef.SurfaceMaterialTable.Length; i++)
     {
         byte num2 = generatorDef.SurfaceMaterialTable[i].Value;
         this.m_materials[num2] = new PlanetMaterial(generatorDef.SurfaceMaterialTable[i], generatorDef.MinimumSurfaceLayerDepth);
     }
     this.m_defaultMaterial    = new PlanetMaterial(generatorDef.DefaultSurfaceMaterial, generatorDef.MinimumSurfaceLayerDepth);
     this.m_subsurfaceMaterial = (generatorDef.DefaultSubSurfaceMaterial == null) ? this.m_defaultMaterial : new PlanetMaterial(generatorDef.DefaultSubSurfaceMaterial, generatorDef.MinimumSurfaceLayerDepth);
     this.m_planetShape        = planetShape;
     this.Maps          = maps;
     this.m_materialMap = maps[0];
     this.m_biomeMap    = maps[1];
     this.m_oreMap      = maps[2];
     if (this.m_materialMap != null)
     {
         this.m_mapResolutionMinusOne = this.m_materialMap.Resolution - 1;
     }
     this.m_generator      = generatorDef;
     this.m_invHeightRange = 1f / (this.m_planetShape.MaxHillHeight - this.m_planetShape.MinHillHeight);
     this.m_biomePixelSize = ((float)((planetShape.MaxHillHeight + planetShape.Radius) * 3.1415926535897931)) / ((this.m_mapResolutionMinusOne + 1) * 2f);
     this.m_hashCode       = generatorDef.FolderName.GetHashCode();
     if ((this.m_generator.MaterialGroups != null) && (this.m_generator.MaterialGroups.Length != 0))
     {
         this.m_biomes = new Dictionary <byte, PlanetBiome>();
         foreach (MyPlanetMaterialGroup group in this.m_generator.MaterialGroups)
         {
             this.m_biomes[group.Value] = new PlanetBiome(group, this.m_generator.MinimumSurfaceLayerDepth);
         }
     }
     if (MyHeightMapLoadingSystem.Static != null)
     {
         this.m_blendingTileset = MyHeightMapLoadingSystem.Static.GetTerrainBlendTexture(this.m_generator.MaterialBlending);
     }
     this.m_ores = new Dictionary <byte, List <PlanetOre> >();
     foreach (MyPlanetOreMapping mapping in this.m_generator.OreMappings)
     {
         MyVoxelMaterialDefinition material = GetMaterial(mapping.Type);
         if (material != null)
         {
             PlanetOre item = new PlanetOre {
                 Depth          = mapping.Depth,
                 Start          = mapping.Start,
                 Value          = mapping.Value,
                 Material       = material,
                 ColorInfluence = mapping.ColorInfluence
             };
             if (mapping.ColorShift != null)
             {
                 item.TargetColor = new Vector3?(mapping.ColorShift.Value.ColorToHSV());
             }
             if (!this.m_ores.ContainsKey(mapping.Value))
             {
                 List <PlanetOre> list1 = new List <PlanetOre>();
                 list1.Add(item);
                 List <PlanetOre> list = list1;
                 this.m_ores.Add(mapping.Value, list);
             }
             this.m_ores[mapping.Value].Add(item);
         }
     }
     this.Closed = false;
 }
Exemple #4
0
        public MyPlanetMaterialProvider(MyPlanetGeneratorDefinition generatorDef, MyPlanetShapeProvider planetShape)
        {
            m_materials = new Dictionary <byte, PlanetMaterial>(generatorDef.SurfaceMaterialTable.Length);

            for (int i = 0; i < generatorDef.SurfaceMaterialTable.Length; ++i)
            {
                byte materialValue = (byte)generatorDef.SurfaceMaterialTable[i].Value;

                m_materials[materialValue] = new PlanetMaterial(generatorDef.SurfaceMaterialTable[i]);
            }

            m_defaultMaterial = new PlanetMaterial(generatorDef.DefaultSurfaceMaterial);

            if (generatorDef.DefaultSubSurfaceMaterial != null)
            {
                m_subsurfaceMaterial = new PlanetMaterial(generatorDef.DefaultSubSurfaceMaterial);
            }
            else
            {
                m_subsurfaceMaterial = m_defaultMaterial;
            }

            m_planetShape = planetShape;

            MyCubemap[] maps;
            MyHeightMapLoadingSystem.Static.GetPlanetMaps(generatorDef.FolderName, generatorDef.Context, generatorDef.PlanetMaps, out maps);


            m_materialMap  = maps[0];
            m_biomeMap     = maps[1];
            m_oreMap       = maps[2];
            m_occlusionMap = maps[3];

            if (m_biomeMap != null)
            {
                m_mapResolutionMinusOne = m_biomeMap.Resolution - 1;
            }

            m_generator = generatorDef;

            m_invHeightRange = 1 / (m_planetShape.MaxHillHeight - m_planetShape.MinHillHeight);

            m_biomePixelSize = (float)((planetShape.MaxHillHeight + planetShape.Radius) * Math.PI) / ((float)(m_mapResolutionMinusOne + 1) * 2);

            m_hashCode = generatorDef.FolderName.GetHashCode();

            // Material groups

            if (m_generator.MaterialGroups != null && m_generator.MaterialGroups.Length > 0)
            {
                m_biomes = new Dictionary <byte, PlanetBiome>();

                foreach (var group in m_generator.MaterialGroups)
                {
                    m_biomes.Add(group.Value, new PlanetBiome(group));
                }
            }

            m_blendingTileset = MyHeightMapLoadingSystem.Static.GetTerrainBlendTexture(m_generator.MaterialBlending);

            m_ores = new Dictionary <byte, PlanetOre>();

            foreach (var mapping in m_generator.OreMappings)
            {
                var mat = GetMaterial(mapping.Type);
                if (mat != null)
                {
                    if (m_ores.ContainsKey(mapping.Value))
                    {
                        string message = String.Format("Value {0} is already mapped to another ore.", mapping.Value);
                        Debug.Fail(message);
                        MyLog.Default.WriteLine(message);
                    }
                    else
                    {
                        m_ores[mapping.Value] = new PlanetOre()
                        {
                            Depth    = mapping.Depth,
                            Start    = mapping.Start,
                            Value    = mapping.Value,
                            Material = mat
                        };
                    }
                }
            }

            Closed = false;
        }