예제 #1
0
        /// <summary>
        /// Отрисовывает горы на определенном тайле
        /// </summary>
        /// <param name="tileID">ID тайла</param>
        /// <param name="subMeshes">Список подслоев</param>
        public void RenderSingleHill(int tileID, List <LayerSubMesh> subMeshes)
        {
            WorldGrid  grid       = Find.WorldGrid;
            int        tilesCount = grid.TilesCount;
            Tile       tile       = grid[tileID];
            Material   material   = WorldMaterials.SmallHills;
            FloatRange floatRange = BasePosOffsetRange_SmallHills;

            switch (tile.hilliness)
            {
            case Hilliness.SmallHills:
                material   = WorldMaterials.SmallHills;
                floatRange = BasePosOffsetRange_SmallHills;
                break;

            case Hilliness.LargeHills:
                material   = WorldMaterials.LargeHills;
                floatRange = BasePosOffsetRange_LargeHills;
                break;

            case Hilliness.Mountainous:
                material   = WorldMaterials.Mountains;
                floatRange = BasePosOffsetRange_Mountains;
                break;

            case Hilliness.Impassable:
                material   = WorldMaterials.ImpassableMountains;
                floatRange = BasePosOffsetRange_ImpassableMountains;
                break;
            }

            LayerSubMesh subMesh        = GetSubMesh(material, subMeshes);
            Vector3      tileCenter     = grid.GetTileCenter(tileID);
            Vector3      posForTangents = tileCenter;
            float        magnitude      = tileCenter.magnitude;

            tileCenter = (tileCenter + Rand.UnitVector3 * floatRange.RandomInRange * grid.averageTileSize).normalized * magnitude;
            WorldRendererUtility.PrintQuadTangentialToPlanet(tileCenter, posForTangents, BaseSizeRange.RandomInRange * grid.averageTileSize, 0.005f, subMesh, counterClockwise: false, randomizeRotation: true, printUVs: false);
            IntVec2 texturesInAtlas  = TexturesInAtlas;
            int     indexX           = Rand.Range(0, texturesInAtlas.x);
            IntVec2 texturesInAtlas2 = TexturesInAtlas;
            int     indexY           = Rand.Range(0, texturesInAtlas2.z);
            IntVec2 texturesInAtlas3 = TexturesInAtlas;
            int     x = texturesInAtlas3.x;
            IntVec2 texturesInAtlas4 = TexturesInAtlas;

            WorldRendererUtility.PrintTextureAtlasUVs(indexX, indexY, x, texturesInAtlas4.z, subMesh);

            FinalizeMesh(MeshParts.All, subMeshes);
        }
예제 #2
0
        private static readonly IntVec2 TexturesInAtlas = new IntVec2(2, 2); // two by two, meaning four variants for each worldmaterial.
        public override IEnumerable Regenerate()
        {
            foreach (object obj in base.Regenerate())             // I'll be honest, I don't know what this does.
            {
                yield return(obj);
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid       worldGrid             = Find.WorldGrid;
            List <BiomeDef> allDefsListForReading = DefDatabase <BiomeDef> .AllDefsListForReading;

            foreach (BiomeDef biomeDef in allDefsListForReading.Where(x => x.HasModExtension <BiomesKitControls>()))
            {
                for (int tileID = 0; tileID < Find.WorldGrid.TilesCount; tileID++)
                {
                    Tile tile = Find.WorldGrid[tileID];
                    BiomesKitControls biomesKit = biomeDef.GetModExtension <BiomesKitControls>();
                    if (tile.biome != biomeDef)
                    {
                        continue;
                    }
                    if (biomesKit.materialPath == "World/MapGraphics/Default")
                    {
                        continue;
                    }
                    Material     material = MaterialPool.MatFrom(biomesKit.materialPath, ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                    LayerSubMesh subMesh  = GetSubMesh(material);
                    Vector3      vector   = worldGrid.GetTileCenter(tileID);
                    WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, worldGrid.averageTileSize, 0.01f, subMesh, false, true, false);
                    WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMesh);
                }
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
        }
예제 #3
0
        private static readonly IntVec2 TexturesInAtlas = new IntVec2(2, 2); // two by two, meaning four variants for each worldmaterial.
        public override IEnumerable Regenerate()
        {
            foreach (object obj in base.Regenerate())
            {
                yield return(obj);
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid worldGrid = Find.WorldGrid;

            for (int tileID = 0; tileID < Find.WorldGrid.TilesCount; tileID++)
            {
                Tile tile = Find.WorldGrid[tileID];
                if (tile.biome.HasModExtension <BiomesKitControls>())
                {
                    Dictionary <Tile, Hilliness> backupHilliness = LateBiomeWorker.backupHilliness;
                    BiomesKitControls            biomesKit       = tile.biome.GetModExtension <BiomesKitControls>();
                    Vector3 vector = worldGrid.GetTileCenter(tileID);
                    if (biomesKit.hillMaterialPath != "World/MapGraphics/Default")
                    {
                        tile.hilliness = backupHilliness[tile];
                        Material hill;
                        if (tile.hilliness == Hilliness.SmallHills)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/SmallHills", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.LargeHills)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/LargeHills", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.Mountainous)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/Mountains", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.Impassable)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/Impassable", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                    }
                    if (biomesKit.materialMaxHilliness != Hilliness.Undefined)
                    {
                        if (tile.hilliness > biomesKit.materialMaxHilliness || tile.hilliness < biomesKit.materialMinHilliness)
                        {
                            continue;
                        }
                    }
                    bool roadPresent = true;
                    if (tile.Roads == null || tile.Roads.Count == 0)
                    {
                        roadPresent = false;
                    }
                    bool riverPresent = true;
                    if (tile.Rivers == null || tile.Rivers.Count == 0)
                    {
                        riverPresent = false;
                    }
                    if (biomesKit.forestMaterialPath != "World/MapGraphics/Default")
                    {
                        if (!riverPresent && !roadPresent)
                        {
                            Material forestMaterial;
                            if (tile.temperature < biomesKit.forestSnowyBelow)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Snowy", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else if (tile.rainfall < biomesKit.forestSparseBelow)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Sparse", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else if (tile.rainfall > biomesKit.forestDenseAbove)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Dense", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            LayerSubMesh subMeshForest = GetSubMesh(forestMaterial);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * biomesKit.materialSizeMultiplier), 0.01f, subMeshForest, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshForest);
                        }
                    }
                    if (biomesKit.materialPath != "World/MapGraphics/Default")
                    {
                        Material     material = MaterialPool.MatFrom(biomesKit.materialPath, ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                        LayerSubMesh subMesh  = GetSubMesh(material);
                        WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * biomesKit.materialSizeMultiplier), 0.01f, subMesh, false, biomesKit.materialRandomRotation, false);
                        WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMesh);
                    }
                }
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
        }