Esempio n. 1
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int data = Terrain.ExtractData(value);

            color *= SubsystemPalette.GetFabricColor(environmentData, GetColor(data));
            BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size, 0.0625f * size, size), ref matrix, color, color, environmentData);
        }
Esempio n. 2
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            int   data        = Terrain.ExtractData(value);
            Color fabricColor = SubsystemPalette.GetFabricColor(generator, GetColor(data));

            generator.GenerateCubeVertices(this, value, x, y, z, 0.0625f, 0.0625f, 0.0625f, 0.0625f, fabricColor, fabricColor, fabricColor, fabricColor, fabricColor, -1, geometry.OpaqueSubsetsByFace);
        }
Esempio n. 3
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int?  paintColor = GetPaintColor(value);
            Color color2     = paintColor.HasValue ? (color * SubsystemPalette.GetColor(environmentData, paintColor)) : (1.25f * WireColor * color);

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color2, 2f * size, ref matrix, environmentData);
        }
Esempio n. 4
0
        public override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
        {
            int   data        = Terrain.ExtractData(value);
            Color fabricColor = SubsystemPalette.GetFabricColor(subsystemTerrain, GetColor(data));

            return(new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, fabricColor, DefaultTextureSlot));
        }
Esempio n. 5
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int type = GetType(value);

            color = (type < 3 ? Colors[type] : GetColor((Materials)(type - 3))) * SubsystemPalette.GetColor(environmentData, GetPaintColor(value));
            BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData);
        }
Esempio n. 6
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            int   data           = Terrain.ExtractData(value);
            int   mountingFace   = GetMountingFace(data);
            int   lightIntensity = GetLightIntensity(data);
            int?  color          = GetColor(data);
            Color color2         = color.HasValue ? SubsystemPalette.GetColor(generator, color) : m_copperColor;

            if (mountingFace < m_bulbBlockMeshes.Length)
            {
                if (lightIntensity <= 0)
                {
                    generator.GenerateMeshVertices(this, x, y, z, m_bulbBlockMeshes[mountingFace], Color.White, null, geometry.SubsetAlphaTest);
                }
                else
                {
                    byte r = (byte)(195 + lightIntensity * 4);
                    byte g = (byte)(180 + lightIntensity * 5);
                    byte b = (byte)(165 + lightIntensity * 6);
                    generator.GenerateMeshVertices(this, x, y, z, m_bulbBlockMeshesLit[mountingFace], new Color(r, g, b), null, geometry.SubsetOpaque);
                }
                generator.GenerateMeshVertices(this, x, y, z, m_sidesBlockMeshes[mountingFace], color2, null, geometry.SubsetOpaque);
                generator.GenerateWireVertices(value, x, y, z, mountingFace, 0.875f, Vector2.Zero, geometry.SubsetOpaque);
            }
        }
Esempio n. 7
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int?  color2 = GetColor(Terrain.ExtractData(value));
            Color c      = color2.HasValue ? SubsystemPalette.GetColor(environmentData, color2) : m_copperColor;

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneSidesBlockMesh, color * c, 2f * size, ref matrix, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBulbBlockMesh, color, 2f * size, ref matrix, environmentData);
        }
Esempio n. 8
0
        public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
        {
            var item = GetItem(ref value);

            return(item != null
                                ? SubsystemPalette.GetName(subsystemTerrain, GetPaintColor(value), item.GetDisplayName(subsystemTerrain, value))
                                : base.GetDisplayName(subsystemTerrain, value));
        }
Esempio n. 9
0
        public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
        {
            int          data          = Terrain.ExtractData(value);
            ClothingData clothingData  = GetClothingData(data);
            int          clothingColor = GetClothingColor(data);
            string       displayName   = LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data), "DisplayName");

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = clothingData.DisplayName;
            }
            if (clothingColor != 0)
            {
                return(SubsystemPalette.GetName(subsystemTerrain, clothingColor, displayName));
            }
            return(displayName);
        }
Esempio n. 10
0
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            string[] additives = new string[4]
            {
                BlocksManager.Blocks[43].CraftingId,
                BlocksManager.Blocks[24].CraftingId,
                BlocksManager.Blocks[103].CraftingId,
                BlocksManager.Blocks[22].CraftingId
            };
            int color = 0;

            while (color < 16)
            {
                int num2;
                for (int additive = 0; additive < 4; additive = num2)
                {
                    int num = CombineColors(color, 1 << additive);
                    if (num != color)
                    {
                        CraftingRecipe craftingRecipe = new CraftingRecipe
                        {
                            Description       = $"ÖÆ×÷ {SubsystemPalette.GetName(null, num, null)} ÑÕÁÏ",
                            ResultValue       = Terrain.MakeBlockValue(129, 0, num),
                            ResultCount       = 1,
                            RequiredHeatLevel = 1f
                        };
                        craftingRecipe.Ingredients[0] = BlocksManager.Blocks[129].CraftingId + ":" + color.ToString(CultureInfo.InvariantCulture);
                        craftingRecipe.Ingredients[1] = additives[additive];
                        yield return(craftingRecipe);
                    }
                    num2 = additive + 1;
                }
                num2  = color + 1;
                color = num2;
            }
        }
Esempio n. 11
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometrySubsets geometry, int value, int x, int y, int z)
        {
            Color color = SubsystemPalette.GetColor(generator, GetPaintColor(value));

            generator.GenerateCubeVertices(this, value, x, y, z, Terrain.ExtractData(value) >> 10 != 0 ? color * Color.LightGray : color, geometry.OpaqueSubsetsByFace);
        }
Esempio n. 12
0
 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometrySubsets geometry, int value, int x, int y, int z)
 {
     generator.GenerateCubeVertices(this, value, x, y, z, new Color(255, 153, 18) * SubsystemPalette.GetColor(generator, GetPaintColor(value)), geometry.OpaqueSubsetsByFace);
 }
Esempio n. 13
0
 public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
 {
     return(SubsystemPalette.GetName(subsystemTerrain, GetPaintColor(value), Terrain.ExtractData(value) >> 10 != 0 ? Names[(Terrain.ExtractData(value) >> 10) - 1] : DefaultDisplayName));
 }
Esempio n. 14
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            int data  = Terrain.ExtractData(value);
            int face  = GetFace(data);
            int?color = GetColor(data);

            if (color.HasValue)
            {
                generator.GenerateMeshVertices(this, x, y, z, m_coloredBlockMeshes[face], SubsystemPalette.GetColor(generator, color), null, geometry.SubsetOpaque);
            }
            else
            {
                generator.GenerateMeshVertices(this, x, y, z, m_blockMeshes[face], Color.White, null, geometry.SubsetOpaque);
            }
            generator.GenerateWireVertices(value, x, y, z, GetFace(data), 0.375f, Vector2.Zero, geometry.SubsetOpaque);
        }
Esempio n. 15
0
        public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
        {
            int value2 = Terrain.ExtractData(value);

            return(SubsystemPalette.GetName(subsystemTerrain, value2, "µØ̺"));
        }
Esempio n. 16
0
        public static void GenerateWireVertices(BlockGeometryGenerator generator, int value, int x, int y, int z, int mountingFace, float centerBoxSize, Vector2 centerOffset, TerrainGeometrySubset subset)
        {
            var   terrain = generator.Terrain;
            Color color   = WireBlock.WireColor;
            int   num     = Terrain.ExtractContents(value);

            if (num == ElementBlock.Index)
            {
                int?color2 = PaintableItemBlock.GetColor(Terrain.ExtractData(value));
                if (color2.HasValue)
                {
                    color = SubsystemPalette.GetColor(generator, color2);
                }
            }
            float   num3         = LightingManager.LightIntensityByLightValue[Terrain.ExtractLight(value)];
            Vector3 v            = new Vector3(x + 0.5f, y + 0.5f, z + 0.5f) - 0.5f * CellFace.FaceToVector3(mountingFace);
            Vector3 vector       = CellFace.FaceToVector3(mountingFace);
            var     v2           = new Vector2(0.9376f, 0.0001f);
            var     v3           = new Vector2(0.03125f, 0.00550781237f);
            Point3  point        = CellFace.FaceToPoint3(mountingFace);
            int     cellContents = terrain.GetCellContents(x - point.X, y - point.Y, z - point.Z);
            bool    flag         = cellContents == 2 || cellContents == 7 || cellContents == 8 || cellContents == 6 || cellContents == 62 || cellContents == 72;
            Vector3 v4           = CellFace.FaceToVector3(SubsystemElectricity.GetConnectorFace(mountingFace, ElectricConnectorDirection.Top));
            Vector3 vector2      = CellFace.FaceToVector3(SubsystemElectricity.GetConnectorFace(mountingFace, ElectricConnectorDirection.Left)) * centerOffset.X + v4 * centerOffset.Y;
            int     num4         = 0;
            var     paths        = new DynamicArray <ElectricConnectionPath>();

            ElementBlock.Block.GetAllConnectedNeighbors(terrain, ElementBlock.Block.GetDevice(x, y, z, value), mountingFace, paths);
            foreach (ElectricConnectionPath tmpConnectionPath in paths)
            {
                if ((num4 & (1 << tmpConnectionPath.ConnectorFace)) == 0)
                {
                    ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(mountingFace, 0, tmpConnectionPath.ConnectorFace);
                    if (centerOffset != Vector2.Zero || connectorDirection != ElectricConnectorDirection.In)
                    {
                        num4 |= 1 << tmpConnectionPath.ConnectorFace;
                        Color color3 = color;
                        if (num != ElementBlock.Index)
                        {
                            int cellValue = terrain.GetCellValue(x + tmpConnectionPath.NeighborOffsetX, y + tmpConnectionPath.NeighborOffsetY, z + tmpConnectionPath.NeighborOffsetZ);
                            if (Terrain.ExtractContents(cellValue) == ElementBlock.Index)
                            {
                                int?color4 = PaintableItemBlock.GetColor(Terrain.ExtractData(cellValue));
                                if (color4.HasValue)
                                {
                                    color3 = SubsystemPalette.GetColor(generator, color4);
                                }
                            }
                        }
                        Vector3 vector3  = (connectorDirection != ElectricConnectorDirection.In) ? CellFace.FaceToVector3(tmpConnectionPath.ConnectorFace) : (-Vector3.Normalize(vector2));
                        var     vector4  = Vector3.Cross(vector, vector3);
                        float   s        = (centerBoxSize >= 0f) ? MathUtils.Max(0.03125f, centerBoxSize / 2f) : (centerBoxSize / 2f);
                        float   num5     = (connectorDirection == ElectricConnectorDirection.In) ? 0.03125f : 0.5f;
                        float   num6     = (connectorDirection == ElectricConnectorDirection.In) ? 0f : ((tmpConnectionPath.ConnectorFace == tmpConnectionPath.NeighborFace) ? (num5 + 0.03125f) : ((tmpConnectionPath.ConnectorFace != CellFace.OppositeFace(tmpConnectionPath.NeighborFace)) ? num5 : (num5 - 0.03125f)));
                        Vector3 vector5  = v - vector4 * 0.03125f + vector3 * s + vector2;
                        Vector3 vector6  = v - vector4 * 0.03125f + vector3 * num5;
                        Vector3 vector7  = v + vector4 * 0.03125f + vector3 * num5;
                        Vector3 vector8  = v + vector4 * 0.03125f + vector3 * s + vector2;
                        Vector3 vector9  = v + vector * 0.03125f + vector3 * (centerBoxSize / 2f) + vector2;
                        Vector3 vector10 = v + vector * 0.03125f + vector3 * num6;
                        if (flag && centerBoxSize == 0f)
                        {
                            Vector3 v5 = 0.25f * BlockGeometryGenerator.GetRandomWireOffset(0.5f * (vector5 + vector8), vector);
                            vector5 += v5;
                            vector8 += v5;
                            vector9 += v5;
                        }
                        Vector2 vector11 = v2 + v3 * new Vector2(MathUtils.Max(0.0625f, centerBoxSize), 0f);
                        Vector2 vector12 = v2 + v3 * new Vector2(num5 * 2f, 0f);
                        Vector2 vector13 = v2 + v3 * new Vector2(num5 * 2f, 1f);
                        Vector2 vector14 = v2 + v3 * new Vector2(MathUtils.Max(0.0625f, centerBoxSize), 1f);
                        Vector2 vector15 = v2 + v3 * new Vector2(centerBoxSize, 0.5f);
                        Vector2 vector16 = v2 + v3 * new Vector2(num6 * 2f, 0.5f);
                        float   num9     = 0.5f * (num3 + LightingManager.LightIntensityByLightValue[Terrain.ExtractLight(terrain.GetCellValue(x + tmpConnectionPath.NeighborOffsetX, y + tmpConnectionPath.NeighborOffsetY, z + tmpConnectionPath.NeighborOffsetZ))]);
                        float   num10    = LightingManager.CalculateLighting(-vector4);
                        float   num11    = LightingManager.CalculateLighting(vector4);
                        float   num12    = LightingManager.CalculateLighting(vector);
                        float   num13    = num10 * num3;
                        float   num14    = num10 * num9;
                        float   num15    = num11 * num9;
                        float   num16    = num11 * num3;
                        float   num17    = num12 * num3;
                        float   num18    = num12 * num9;
                        var     color5   = new Color((byte)(color3.R * num13), (byte)(color3.G * num13), (byte)(color3.B * num13));
                        var     color6   = new Color((byte)(color3.R * num14), (byte)(color3.G * num14), (byte)(color3.B * num14));
                        var     color7   = new Color((byte)(color3.R * num15), (byte)(color3.G * num15), (byte)(color3.B * num15));
                        var     color8   = new Color((byte)(color3.R * num16), (byte)(color3.G * num16), (byte)(color3.B * num16));
                        var     color9   = new Color((byte)(color3.R * num17), (byte)(color3.G * num17), (byte)(color3.B * num17));
                        var     color10  = new Color((byte)(color3.R * num18), (byte)(color3.G * num18), (byte)(color3.B * num18));
                        int     count    = subset.Vertices.Count;
                        subset.Vertices.Count += 6;
                        TerrainVertex[] array = subset.Vertices.Array;
                        BlockGeometryGenerator.SetupVertex(vector5.X, vector5.Y, vector5.Z, color5, vector11.X, vector11.Y, ref array[count]);
                        BlockGeometryGenerator.SetupVertex(vector6.X, vector6.Y, vector6.Z, color6, vector12.X, vector12.Y, ref array[count + 1]);
                        BlockGeometryGenerator.SetupVertex(vector7.X, vector7.Y, vector7.Z, color7, vector13.X, vector13.Y, ref array[count + 2]);
                        BlockGeometryGenerator.SetupVertex(vector8.X, vector8.Y, vector8.Z, color8, vector14.X, vector14.Y, ref array[count + 3]);
                        BlockGeometryGenerator.SetupVertex(vector9.X, vector9.Y, vector9.Z, color9, vector15.X, vector15.Y, ref array[count + 4]);
                        BlockGeometryGenerator.SetupVertex(vector10.X, vector10.Y, vector10.Z, color10, vector16.X, vector16.Y, ref array[count + 5]);
                        int count2 = subset.Indices.Count;
                        subset.Indices.Count += (connectorDirection == ElectricConnectorDirection.In) ? 15 : 12;
                        ushort[] array2 = subset.Indices.Array;
                        array2[count2]      = (ushort)count;
                        array2[count2 + 1]  = (ushort)(count + 5);
                        array2[count2 + 2]  = (ushort)(count + 1);
                        array2[count2 + 3]  = (ushort)(count + 5);
                        array2[count2 + 4]  = (ushort)count;
                        array2[count2 + 5]  = (ushort)(count + 4);
                        array2[count2 + 6]  = (ushort)(count + 4);
                        array2[count2 + 7]  = (ushort)(count + 2);
                        array2[count2 + 8]  = (ushort)(count + 5);
                        array2[count2 + 9]  = (ushort)(count + 2);
                        array2[count2 + 10] = (ushort)(count + 4);
                        array2[count2 + 11] = (ushort)(count + 3);
                        if (connectorDirection == ElectricConnectorDirection.In)
                        {
                            array2[count2 + 12] = (ushort)(count + 2);
                            array2[count2 + 13] = (ushort)(count + 1);
                            array2[count2 + 14] = (ushort)(count + 5);
                        }
                    }
                }
            }
            if (centerBoxSize == 0f && (num4 != 0 || (num == ElementBlock.Index && (Terrain.ExtractData(value) & 1023) == 5)))
            {
                for (int i = 0; i < 6; i++)
                {
                    if (i != mountingFace && i != CellFace.OppositeFace(mountingFace) && (num4 & (1 << i)) == 0)
                    {
                        Vector3 vector17 = CellFace.FaceToVector3(i);
                        var     v6       = Vector3.Cross(vector, vector17);
                        Vector3 vector18 = v - v6 * 0.03125f + vector17 * 0.03125f;
                        Vector3 vector19 = v + v6 * 0.03125f + vector17 * 0.03125f;
                        Vector3 vector20 = v + vector * 0.03125f;
                        if (flag)
                        {
                            Vector3 v7 = 0.25f * BlockGeometryGenerator.GetRandomWireOffset(0.5f * (vector18 + vector19), vector);
                            vector18 += v7;
                            vector19 += v7;
                            vector20 += v7;
                        }
                        Vector2 vector21 = v2 + v3 * new Vector2(0.0625f, 0f);
                        Vector2 vector22 = v2 + v3 * new Vector2(0.0625f, 1f);
                        Vector2 vector23 = v2 + v3 * new Vector2(0f, 0.5f);
                        float   num19    = LightingManager.CalculateLighting(vector17) * num3;
                        float   num20    = LightingManager.CalculateLighting(vector) * num3;
                        var     color11  = new Color((byte)(color.R * num19), (byte)(color.G * num19), (byte)(color.B * num19));
                        var     color12  = new Color((byte)(color.R * num20), (byte)(color.G * num20), (byte)(color.B * num20));
                        int     count3   = subset.Vertices.Count;
                        subset.Vertices.Count += 3;
                        var array3 = subset.Vertices.Array;
                        BlockGeometryGenerator.SetupVertex(vector18.X, vector18.Y, vector18.Z, color11, vector21.X, vector21.Y, ref array3[count3]);
                        BlockGeometryGenerator.SetupVertex(vector19.X, vector19.Y, vector19.Z, color11, vector22.X, vector22.Y, ref array3[count3 + 1]);
                        BlockGeometryGenerator.SetupVertex(vector20.X, vector20.Y, vector20.Z, color12, vector23.X, vector23.Y, ref array3[count3 + 2]);
                        int count4 = subset.Indices.Count;
                        subset.Indices.Count += 3;
                        ushort[] array4 = subset.Indices.Array;
                        array4[count4]     = (ushort)count3;
                        array4[count4 + 1] = (ushort)(count3 + 2);
                        array4[count4 + 2] = (ushort)(count3 + 1);
                    }
                }
            }
        }
Esempio n. 17
0
        public override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
        {
            int?color = GetColor(Terrain.ExtractData(value));

            if (color.HasValue)
            {
                return(new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, SubsystemPalette.GetColor(subsystemTerrain, color), m_coloredTextureSlot));
            }
            return(new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, Color.White, DefaultTextureSlot));
        }
Esempio n. 18
0
 public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
 {
     return(SubsystemPalette.GetName(subsystemTerrain, Utils.GetColor(value), DefaultDisplayName));
 }
Esempio n. 19
0
 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
 {
     BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color * SubsystemPalette.GetColor(environmentData, Utils.GetColor(value)), 2f * size, ref matrix, environmentData);
 }
Esempio n. 20
0
 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
 {
     color *= SubsystemPalette.GetColor(environmentData, GetPaintColor(value)) * new Color(255, 153, 18);
     BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData);
 }
Esempio n. 21
0
        public static CraftingRecipe GetAdHocCraftingRecipe(int index, SubsystemTerrain subsystemTerrain, string[] ingredients, float heatLevel)
        {
            if (heatLevel < 1f)
            {
                return(null);
            }
            int i = 0, num = 0;
            var array = new string[2];

            for (; i < ingredients.Length; i++)
            {
                if (!string.IsNullOrEmpty(ingredients[i]))
                {
                    if (num > 1)
                    {
                        return(null);
                    }
                    array[num] = ingredients[i];
                    num++;
                }
            }
            if (num != 2)
            {
                return(null);
            }
            num = 0;
            int num2 = 0;
            int num3 = 0;

            for (i = 0; i < array.Length; i++)
            {
                string item = array[i];
                CraftingRecipesManager.DecodeIngredient(item, out string craftingId, out int?data);
                int d = data ?? 0;
                if (craftingId == BlocksManager.Blocks[index].CraftingId)
                {
                    num3 = Terrain.MakeBlockValue(index, 0, d);
                }
                else if (craftingId == BlocksManager.Blocks[129].CraftingId)
                {
                    num = Terrain.MakeBlockValue(129, 0, d);
                }
                else if (craftingId == BlocksManager.Blocks[128].CraftingId)
                {
                    num2 = Terrain.MakeBlockValue(128, 0, d);
                }
            }
            if (num != 0 && num3 != 0)
            {
                int num4  = GetColor(Terrain.ExtractData(num3));
                int color = PaintBucketBlock.GetColor(Terrain.ExtractData(num));
                int num5  = PaintBucketBlock.CombineColors(num4, color);
                if (num5 != num4)
                {
                    return(new CraftingRecipe
                    {
                        ResultCount = 1,
                        ResultValue = Terrain.MakeBlockValue(index, 0, SetColor(Terrain.ExtractData(num3), num5)),
                        RemainsCount = 1,
                        RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(129, 0, color), BlocksManager.Blocks[129].GetDamage(num) + 1),
                        RequiredHeatLevel = 1f,
                        Description = "Dye tool " + SubsystemPalette.GetName(subsystemTerrain, color, null),
                        Ingredients = (string[])ingredients.Clone()
                    });
                }
            }
            if (num2 != 0 && num3 != 0)
            {
                if (GetColor(num3) != 0)
                {
                    return(new CraftingRecipe
                    {
                        ResultCount = 1,
                        ResultValue = Terrain.MakeBlockValue(index, 0, SetColor(Terrain.ExtractData(num3), 0)),
                        RemainsCount = 1,
                        RemainsValue = BlocksManager.DamageItem(128, BlocksManager.Blocks[128].GetDamage(num2) + 1),
                        RequiredHeatLevel = 1f,
                        Description = "Undye tool",
                        Ingredients = (string[])ingredients.Clone()
                    });
                }
            }
            return(null);
        }
Esempio n. 22
0
        public override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain terrain, string[] ingredients, float heatLevel, float playerLevel)
        {
            if (heatLevel < 1f)
            {
                return(null);
            }
            List <string> list = ingredients.Where((string i) => !string.IsNullOrEmpty(i)).ToList();

            if (list.Count == 2)
            {
                int num  = 0;
                int num2 = 0;
                int num3 = 0;
                foreach (string item in list)
                {
                    CraftingRecipesManager.DecodeIngredient(item, out string craftingId, out int?data);
                    if (craftingId == BlocksManager.Blocks[203].CraftingId)
                    {
                        num3 = Terrain.MakeBlockValue(203, 0, data.HasValue ? data.Value : 0);
                    }
                    else if (craftingId == BlocksManager.Blocks[129].CraftingId)
                    {
                        num = Terrain.MakeBlockValue(129, 0, data.HasValue ? data.Value : 0);
                    }
                    else if (craftingId == BlocksManager.Blocks[128].CraftingId)
                    {
                        num2 = Terrain.MakeBlockValue(128, 0, data.HasValue ? data.Value : 0);
                    }
                }
                if (num != 0 && num3 != 0)
                {
                    int   data2         = Terrain.ExtractData(num3);
                    int   clothingColor = GetClothingColor(data2);
                    int   clothingIndex = GetClothingIndex(data2);
                    bool  canBeDyed     = GetClothingData(data2).CanBeDyed;
                    int   damage        = BlocksManager.Blocks[203].GetDamage(num3);
                    int   color         = PaintBucketBlock.GetColor(Terrain.ExtractData(num));
                    int   damage2       = BlocksManager.Blocks[129].GetDamage(num);
                    Block block         = BlocksManager.Blocks[129];
                    Block block2        = BlocksManager.Blocks[203];
                    if (!canBeDyed)
                    {
                        return(null);
                    }
                    int num4 = PaintBucketBlock.CombineColors(clothingColor, color);
                    if (num4 != clothingColor)
                    {
                        return(new CraftingRecipe
                        {
                            ResultCount = 1,
                            ResultValue = block2.SetDamage(Terrain.MakeBlockValue(203, 0, SetClothingIndex(SetClothingColor(0, num4), clothingIndex)), damage),
                            RemainsCount = 1,
                            RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(129, 0, color), damage2 + MathUtils.Max(block.Durability / 4, 1)),
                            RequiredHeatLevel = 1f,
                            Description = $"{LanguageControl.Get("BlocksManager", "Dyed")} {SubsystemPalette.GetName(terrain, color, null)}",
                            Ingredients = (string[])ingredients.Clone()
                        });
                    }
                }
                if (num2 != 0 && num3 != 0)
                {
                    int   data3          = Terrain.ExtractData(num3);
                    int   clothingColor2 = GetClothingColor(data3);
                    int   clothingIndex2 = GetClothingIndex(data3);
                    bool  canBeDyed2     = GetClothingData(data3).CanBeDyed;
                    int   damage3        = BlocksManager.Blocks[203].GetDamage(num3);
                    int   damage4        = BlocksManager.Blocks[128].GetDamage(num2);
                    Block block3         = BlocksManager.Blocks[128];
                    Block block4         = BlocksManager.Blocks[203];
                    if (!canBeDyed2)
                    {
                        return(null);
                    }
                    if (clothingColor2 != 0)
                    {
                        return(new CraftingRecipe
                        {
                            ResultCount = 1,
                            ResultValue = block4.SetDamage(Terrain.MakeBlockValue(203, 0, SetClothingIndex(SetClothingColor(0, 0), clothingIndex2)), damage3),
                            RemainsCount = 1,
                            RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(128, 0, 0), damage4 + MathUtils.Max(block3.Durability / 4, 1)),
                            RequiredHeatLevel = 1f,
                            Description = LanguageControl.Get("BlocksManager", "Not Dyed") + " " + LanguageControl.Get("BlocksManager", "Clothes"),
                            Ingredients = (string[])ingredients.Clone()
                        });
                    }
                }
            }
            return(null);
        }
Esempio n. 23
0
 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometrySubsets geometry, int value, int x, int y, int z)
 {
     generator.GenerateCubeVertices(this, value, x, y, z, IsColored(Terrain.ExtractData(value) & 16383) ? SubsystemPalette.GetColor(generator, GetColor(Terrain.ExtractData(value))) : Color.White, geometry.OpaqueSubsetsByFace);
 }
Esempio n. 24
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            int data  = Terrain.ExtractData(value);
            int num   = GetIsTop(data) ? 1 : 0;
            int?color = GetColor(data);

            if (color.HasValue)
            {
                generator.GenerateShadedMeshVertices(this, x, y, z, m_coloredBlockMeshes[num], SubsystemPalette.GetColor(generator, color), null, null, geometry.SubsetOpaque);
            }
            else
            {
                generator.GenerateShadedMeshVertices(this, x, y, z, m_uncoloredBlockMeshes[num], Color.White, null, null, geometry.SubsetOpaque);
            }
        }
Esempio n. 25
0
        public override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain subsystemTerrain, string[] ingredients, float heatLevel, float playerLevel)
        {
            if (heatLevel < 1f)
            {
                return(null);
            }
            List <string> list = ingredients.Where((string i) => !string.IsNullOrEmpty(i)).ToList();

            if (list.Count == 2)
            {
                int num  = 0;
                int num2 = 0;
                int num3 = 0;
                foreach (string item in list)
                {
                    CraftingRecipesManager.DecodeIngredient(item, out string craftingId, out int?data);
                    if (craftingId == BlocksManager.Blocks[208].CraftingId)
                    {
                        num3 = Terrain.MakeBlockValue(208, 0, data.HasValue ? data.Value : 0);
                    }
                    else if (craftingId == BlocksManager.Blocks[129].CraftingId)
                    {
                        num = Terrain.MakeBlockValue(129, 0, data.HasValue ? data.Value : 0);
                    }
                    else if (craftingId == BlocksManager.Blocks[128].CraftingId)
                    {
                        num2 = Terrain.MakeBlockValue(128, 0, data.HasValue ? data.Value : 0);
                    }
                }
                if (num != 0 && num3 != 0)
                {
                    int   num4   = Terrain.ExtractData(num3);
                    int   color  = PaintBucketBlock.GetColor(Terrain.ExtractData(num));
                    int   damage = BlocksManager.Blocks[129].GetDamage(num);
                    Block block  = BlocksManager.Blocks[129];
                    int   num5   = PaintBucketBlock.CombineColors(num4, color);
                    if (num5 != num4)
                    {
                        return(new CraftingRecipe
                        {
                            ResultCount = 1,
                            ResultValue = Terrain.MakeBlockValue(208, 0, num5),
                            RemainsCount = 1,
                            RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(129, 0, color), damage + MathUtils.Max(block.Durability / 4, 1)),
                            RequiredHeatLevel = 1f,
                            Description = $"Dye carpet {SubsystemPalette.GetName(subsystemTerrain, color, null)}",
                            Ingredients = (string[])ingredients.Clone()
                        });
                    }
                }
                if (num2 != 0 && num3 != 0)
                {
                    int   num6    = Terrain.ExtractData(num3);
                    int   damage2 = BlocksManager.Blocks[128].GetDamage(num2);
                    Block block2  = BlocksManager.Blocks[128];
                    if (num6 != 0)
                    {
                        return(new CraftingRecipe
                        {
                            ResultCount = 1,
                            ResultValue = Terrain.MakeBlockValue(208, 0, 0),
                            RemainsCount = 1,
                            RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(128, 0, 0), damage2 + MathUtils.Max(block2.Durability / 4, 1)),
                            RequiredHeatLevel = 1f,
                            Description = "Undye carpet",
                            Ingredients = (string[])ingredients.Clone()
                        });
                    }
                }
            }
            return(null);
        }
Esempio n. 26
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int?color2 = GetColor(Terrain.ExtractData(value));

            if (color2.HasValue)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneColoredBlockMesh, color * SubsystemPalette.GetColor(environmentData, color2), 1.25f * size, ref matrix, environmentData);
            }
            else
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, 1.25f * size, ref matrix, environmentData);
            }
        }
Esempio n. 27
0
        public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
        {
            int?color = GetColor(Terrain.ExtractData(value));

            return(SubsystemPalette.GetName(subsystemTerrain, color, base.GetDisplayName(subsystemTerrain, value)));
        }
Esempio n. 28
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int?paintColor = PaintableItemBlock.GetColor(Terrain.ExtractData(value));

            BlocksManager.DrawMeshBlock(primitivesRenderer, ElementBlock.WireBlock.m_standaloneBlockMesh, (paintColor.HasValue ? SubsystemPalette.GetColor(environmentData, paintColor) : 1.25f * WireBlock.WireColor) * color, 2f * size, ref matrix, environmentData);
        }
Esempio n. 29
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int          data          = Terrain.ExtractData(value);
            int          clothingColor = GetClothingColor(data);
            ClothingData clothingData  = GetClothingData(data);
            Matrix       matrix2       = m_slotTransforms[(int)clothingData.Slot] * Matrix.CreateScale(size) * matrix;

            if (clothingData.IsOuter)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_outerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData);
            }
            else
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_innerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData);
            }
        }
Esempio n. 30
0
        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            int data    = Terrain.ExtractData(value);
            int variant = GetVariant(data);
            int?color   = GetColor(data);

            if (color.HasValue)
            {
                generator.GenerateMeshVertices(this, x, y, z, m_coloredBlockMeshes[variant], SubsystemPalette.GetColor(generator, color), null, m_useAlphaTest ? geometry.SubsetAlphaTest : geometry.SubsetOpaque);
            }
            else
            {
                generator.GenerateMeshVertices(this, x, y, z, m_blockMeshes[variant], m_unpaintedColor, null, m_useAlphaTest ? geometry.SubsetAlphaTest : geometry.SubsetOpaque);
            }
        }