Beispiel #1
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = GetSubMesh(MatBases.FogOfWar);

            if (subMesh.mesh.vertexCount == 0)
            {
                SectionLayerGeometryMaker_Solid.MakeBaseGeometry(section, subMesh, AltitudeLayer.FogOfWar);
            }
            subMesh.Clear(MeshParts.Colors);
            bool[]      fogGrid     = base.Map.fogGrid.fogGrid;
            CellRect    cellRect    = section.CellRect;
            int         num         = base.Map.Size.z - 1;
            int         num2        = base.Map.Size.x - 1;
            bool        flag        = false;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    if (fogGrid[cellIndices.CellToIndex(i, j)])
                    {
                        for (int k = 0; k < 9; k++)
                        {
                            vertsCovered[k] = true;
                        }
                    }
                    else
                    {
                        for (int l = 0; l < 9; l++)
                        {
                            vertsCovered[l] = false;
                        }
                        if (j < num && fogGrid[cellIndices.CellToIndex(i, j + 1)])
                        {
                            vertsCovered[2] = true;
                            vertsCovered[3] = true;
                            vertsCovered[4] = true;
                        }
                        if (j > 0 && fogGrid[cellIndices.CellToIndex(i, j - 1)])
                        {
                            vertsCovered[6] = true;
                            vertsCovered[7] = true;
                            vertsCovered[0] = true;
                        }
                        if (i < num2 && fogGrid[cellIndices.CellToIndex(i + 1, j)])
                        {
                            vertsCovered[4] = true;
                            vertsCovered[5] = true;
                            vertsCovered[6] = true;
                        }
                        if (i > 0 && fogGrid[cellIndices.CellToIndex(i - 1, j)])
                        {
                            vertsCovered[0] = true;
                            vertsCovered[1] = true;
                            vertsCovered[2] = true;
                        }
                        if (j > 0 && i > 0 && fogGrid[cellIndices.CellToIndex(i - 1, j - 1)])
                        {
                            vertsCovered[0] = true;
                        }
                        if (j < num && i > 0 && fogGrid[cellIndices.CellToIndex(i - 1, j + 1)])
                        {
                            vertsCovered[2] = true;
                        }
                        if (j < num && i < num2 && fogGrid[cellIndices.CellToIndex(i + 1, j + 1)])
                        {
                            vertsCovered[4] = true;
                        }
                        if (j > 0 && i < num2 && fogGrid[cellIndices.CellToIndex(i + 1, j - 1)])
                        {
                            vertsCovered[6] = true;
                        }
                    }
                    for (int m = 0; m < 9; m++)
                    {
                        byte a;
                        if (vertsCovered[m])
                        {
                            a    = byte.MaxValue;
                            flag = true;
                        }
                        else
                        {
                            a = 0;
                        }
                        subMesh.colors.Add(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, a));
                    }
                }
            }
            if (flag)
            {
                subMesh.disabled = false;
                subMesh.FinalizeMesh(MeshParts.Colors);
            }
            else
            {
                subMesh.disabled = true;
            }
        }
        public override void Regenerate()
        {
            LayerSubMesh subMesh = GetSubMesh(MatBases.Snow);

            if (subMesh.mesh.vertexCount == 0)
            {
                SectionLayerGeometryMaker_Solid.MakeBaseGeometry(section, subMesh, AltitudeLayer.Terrain);
            }
            subMesh.Clear(MeshParts.Colors);
            float[]     depthGridDirect_Unsafe = base.Map.snowGrid.DepthGridDirect_Unsafe;
            CellRect    cellRect    = section.CellRect;
            int         num         = base.Map.Size.z - 1;
            int         num2        = base.Map.Size.x - 1;
            bool        flag        = false;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    float num3 = depthGridDirect_Unsafe[cellIndices.CellToIndex(i, j)];
                    int   num4 = cellIndices.CellToIndex(i, j - 1);
                    float num5 = ((j > 0) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i - 1, j - 1);
                    float num6 = ((j > 0 && i > 0) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i - 1, j);
                    float num7 = ((i > 0) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i - 1, j + 1);
                    float num8 = ((j < num && i > 0) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i, j + 1);
                    float num9 = ((j < num) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i + 1, j + 1);
                    float num10 = ((j < num && i < num2) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i + 1, j);
                    float num11 = ((i < num2) ? depthGridDirect_Unsafe[num4] : num3);
                    num4 = cellIndices.CellToIndex(i + 1, j - 1);
                    float num12 = ((j > 0 && i < num2) ? depthGridDirect_Unsafe[num4] : num3);
                    vertDepth[0] = (num5 + num6 + num7 + num3) / 4f;
                    vertDepth[1] = (num7 + num3) / 2f;
                    vertDepth[2] = (num7 + num8 + num9 + num3) / 4f;
                    vertDepth[3] = (num9 + num3) / 2f;
                    vertDepth[4] = (num9 + num10 + num11 + num3) / 4f;
                    vertDepth[5] = (num11 + num3) / 2f;
                    vertDepth[6] = (num11 + num12 + num5 + num3) / 4f;
                    vertDepth[7] = (num5 + num3) / 2f;
                    vertDepth[8] = num3;
                    for (int k = 0; k < 9; k++)
                    {
                        if (vertDepth[k] > 0.01f)
                        {
                            flag = true;
                        }
                        subMesh.colors.Add(SnowDepthColor(vertDepth[k]));
                    }
                }
            }
            if (flag)
            {
                subMesh.disabled = false;
                subMesh.FinalizeMesh(MeshParts.Colors);
            }
            else
            {
                subMesh.disabled = true;
            }
        }
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.Snow);

            if (subMesh.mesh.vertexCount == 0)
            {
                SectionLayerGeometryMaker_Solid.MakeBaseGeometry(base.section, subMesh, AltitudeLayer.Terrain);
            }
            subMesh.Clear(MeshParts.Colors);
            float[]     depthGridDirect_Unsafe = base.Map.snowGrid.DepthGridDirect_Unsafe;
            CellRect    cellRect    = base.section.CellRect;
            IntVec3     size        = base.Map.Size;
            int         num         = size.z - 1;
            IntVec3     size2       = base.Map.Size;
            int         num2        = size2.x - 1;
            bool        flag        = false;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    float num3 = depthGridDirect_Unsafe[cellIndices.CellToIndex(i, j)];
                    int   num4 = cellIndices.CellToIndex(i, j - 1);
                    float num5 = (j <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j - 1);
                    float num6 = (j <= 0 || i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j);
                    float num7 = (i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j + 1);
                    float num8 = (j >= num || i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i, j + 1);
                    float num9 = (j >= num) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j + 1);
                    float num10 = (j >= num || i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j);
                    float num11 = (i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j - 1);
                    float num12 = (j <= 0 || i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    this.vertDepth[0] = (float)((num5 + num6 + num7 + num3) / 4.0);
                    this.vertDepth[1] = (float)((num7 + num3) / 2.0);
                    this.vertDepth[2] = (float)((num7 + num8 + num9 + num3) / 4.0);
                    this.vertDepth[3] = (float)((num9 + num3) / 2.0);
                    this.vertDepth[4] = (float)((num9 + num10 + num11 + num3) / 4.0);
                    this.vertDepth[5] = (float)((num11 + num3) / 2.0);
                    this.vertDepth[6] = (float)((num11 + num12 + num5 + num3) / 4.0);
                    this.vertDepth[7] = (float)((num5 + num3) / 2.0);
                    this.vertDepth[8] = num3;
                    for (int k = 0; k < 9; k++)
                    {
                        if (this.vertDepth[k] > 0.0099999997764825821)
                        {
                            flag = true;
                        }
                        subMesh.colors.Add(SectionLayer_Snow.SnowDepthColor(this.vertDepth[k]));
                    }
                }
            }
            if (flag)
            {
                subMesh.disabled = false;
                subMesh.FinalizeMesh(MeshParts.Colors);
            }
            else
            {
                subMesh.disabled = true;
            }
        }