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

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBucketBlockMesh, color, 2f * size, ref matrix, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standalonePaintBlockMesh, color * SubsystemPalette.GetColor(environmentData, color2), 2f * size, ref matrix, environmentData);
        }
Esempio n. 2
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            float num = 8f;

            if (environmentData != null && environmentData.SubsystemTerrain != null)
            {
                Vector3 translation = environmentData.InWorldMatrix.Translation;
                int     num2        = Terrain.ToCell(translation.X);
                int     num3        = Terrain.ToCell(translation.Z);
                float   f           = translation.X - (float)num2;
                float   f2          = translation.Z - (float)num3;
                float   x           = environmentData.SubsystemTerrain.Terrain.GetSeasonalHumidity(num2, num3);
                float   x2          = environmentData.SubsystemTerrain.Terrain.GetSeasonalHumidity(num2, num3 + 1);
                float   x3          = environmentData.SubsystemTerrain.Terrain.GetSeasonalHumidity(num2 + 1, num3);
                float   x4          = environmentData.SubsystemTerrain.Terrain.GetSeasonalHumidity(num2 + 1, num3 + 1);
                float   x5          = MathUtils.Lerp(x, x2, f2);
                float   x6          = MathUtils.Lerp(x3, x4, f2);
                num = MathUtils.Lerp(x5, x6, f);
            }
            float  radians = MathUtils.Lerp(1.5f, -1.5f, num / 15f);
            Matrix matrix2 = Matrix.CreateScale(7f * size) * Matrix.CreateTranslation(0f, -0.1f, 0f) * matrix;
            Matrix matrix3 = m_invPointerMatrix * Matrix.CreateRotationX(radians) * m_pointerMatrix * matrix2;

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_caseMesh, color, 1f, ref matrix2, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_pointerMesh, color, 1f, ref matrix3, environmentData);
        }
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 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. 5
0
    public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
    {
        Type type = GetType(value);

        switch (type)
        {
        case Type.RottenMeat:
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, 2f * size, ref matrix, environmentData);
            return;

        case Type.Oil:
            color = new Color(30, 30, 30);
            BlocksManager.DrawCubeBlock(primitivesRenderer, Terrain.ReplaceContents(value, 18), new Vector3(size), ref matrix, color, color, environmentData);
            return;

        case Type.OilBucket:
            BlocksManager.DrawMeshBlock(primitivesRenderer, StandaloneBlockMesh, color, 2f * size, ref matrix, environmentData);
            return;

        default:
            color = Colors[(int)type - 1];
            BlocksManager.DrawCubeBlock(primitivesRenderer, Terrain.ReplaceContents(value, 18), new Vector3(size), ref matrix, color, color, environmentData);
            return;
        }
    }
Esempio n. 6
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int   bulletType = (int)GetBulletType(Terrain.ExtractData(value));
            float size2      = (bulletType >= 0 && bulletType < m_sizes.Length) ? (size * m_sizes[bulletType]) : size;

            BlocksManager.DrawFlatBlock(primitivesRenderer, value, size2, ref matrix, null, color, isEmissive: false, environmentData);
        }
Esempio n. 7
0
        public static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            environmentData = (environmentData ?? m_defaultEnvironmentData);
            Texture2D texture = (environmentData.SubsystemTerrain != null) ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture;

            DrawMeshBlock(primitivesRenderer, blockMesh, texture, color, size, ref matrix, environmentData);
        }
Esempio n. 8
0
        public void Updated(int value, int count)
        {
            RenderTarget2D renderTarget = Display.RenderTarget;

            Display.RenderTarget = m_renderTarget;
            Display.Clear(Color.Transparent);
            try
            {
                string numstr  = count.ToString();
                int    usedw   = numstr.Length * 16;
                int    padding = (256 - usedw) / 2;
                //base x 128 base y 384 efont 16 all w 256
                //base x 4 y 12
                FontBatch2D fontBatch = primitivesRenderer2D.FontBatch(ILibrary.m_font, 1, DepthStencilState.None, null, BlendState.Opaque, SamplerState.PointClamp);
                fontBatch.QueueText($"{numstr}", new Vector2(128 + padding, 384), 0f, Color.White, TextAnchor.HorizontalCenter, new Vector2(4, 4), Vector2.Zero);                //不是纹理坐标
                PrimitivesRenderer3D mprimitivesRenderer3D = new PrimitivesRenderer3D();
                int   id    = Terrain.ExtractContents(value);
                Block block = BlocksManager.Blocks[id];
                DrawBlockEnvironmentData blockEnvironmentData = new DrawBlockEnvironmentData();
                Matrix m2 = Matrix.CreateLookAt(block.GetIconViewOffset(value, blockEnvironmentData), Vector3.Zero, Vector3.UnitY);
                m2 *= Matrix.CreateOrthographic(3.6f, 3.6f, -10f - 1f * 1f, 10f - 1f * 1f);
                m2 *= Matrix.CreateTranslation(0, 0.2f, 0);
                Matrix matrix = Matrix.Identity;
                blockEnvironmentData.ViewProjectionMatrix = m2;
                block.DrawBlock(mprimitivesRenderer3D, value, Color.White, 0.8f, ref matrix, blockEnvironmentData);
                mprimitivesRenderer3D.Flush(matrix);
                primitivesRenderer2D.Flush();
                Display.RenderTarget = renderTarget;
            }
            catch (Exception e) {
                Log.Information("error display" + e.ToString());
            }
        }
Esempio n. 9
0
        /*public override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain subsystemTerrain, string[] ingredients, float heatLevel)
         * {
         *      var recipe = Utils.GetAdHocCraftingRecipe(Index, subsystemTerrain, ingredients, heatLevel);
         *      if (recipe != null)
         *              for (int i = 0; i < ingredients.Length; i++)
         *                      if (!string.IsNullOrEmpty(ingredients[i]))
         *                      {
         *                              CraftingRecipesManager.DecodeIngredient(ingredients[i], out string craftingId, out int? data);
         *                              if (string.Equals(craftingId, CraftingId))
         *                                      recipe.ResultValue = Terrain.ReplaceData(Index, (Terrain.ExtractData(recipe.ResultValue) & 15) << 13 | (data ?? 0) & 15);
         *                      }
         *      return recipe;
         * }*/
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            var type = GetType(value);

            ItemBlock.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, ItemBlock.Texture,
                                    (type == DrillType.DiamondDrill ? Color.Cyan : type == DrillType.SteelTubularis ? color = Color.Gray : color) * SubsystemPalette.GetColor(environmentData, Terrain.ExtractData(value) >> 13 & 15), false, environmentData);
        }
Esempio n. 10
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            float num = 8f;

            if (environmentData != null && environmentData.SubsystemTerrain != null)
            {
                Vector3 translation = environmentData.InWorldMatrix.Translation;
                int     num2        = Terrain.ToCell(translation.X);
                int     num3        = Terrain.ToCell(translation.Z);
                float   f           = translation.X - (float)num2;
                float   f2          = translation.Z - (float)num3;
                float   x           = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2, num3);
                float   x2          = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2, num3 + 1);
                float   x3          = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2 + 1, num3);
                float   x4          = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2 + 1, num3 + 1);
                float   x5          = MathUtils.Lerp(x, x2, f2);
                float   x6          = MathUtils.Lerp(x3, x4, f2);
                num = MathUtils.Lerp(x5, x6, f);
            }
            float  y       = MathUtils.Lerp(1f, 4f, num / 15f);
            Matrix matrix2 = Matrix.CreateScale(3f * size) * Matrix.CreateTranslation(0f, -0.15f, 0f) * matrix;
            Matrix matrix3 = Matrix.CreateTranslation(0f, 0f - m_fluidBottomPosition, 0f) * Matrix.CreateScale(1f, y, 1f) * Matrix.CreateTranslation(0f, m_fluidBottomPosition, 0f) * matrix2;

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_caseMesh, color, 1f, ref matrix2, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_fluidMesh, color, 1f, ref matrix3, environmentData);
        }
Esempio n. 11
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. 12
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int     data    = Terrain.ExtractData(value);
            EggType eggType = GetEggType(data);

            BlocksManager.DrawMeshBlock(primitivesRenderer, eggType.BlockMesh, color, eggType.Scale * size, ref matrix, environmentData);
        }
Esempio n. 13
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            switch (Terrain.ExtractData(value))
            {
            case 0:
                color *= new Color(160, 150, 125);
                break;

            case 1:
                color *= new Color(192, 160, 160);
                break;

            case 2:
                color *= new Color(192, 160, 192);
                break;

            case 3:
                color *= new Color(192, 192, 192);
                break;

            case 4:
                color *= new Color(60, 138, 76);
                break;

            case 6:
                color *= new Color(255, 255, 255);
                break;

            case 7:
                color *= new Color(240, 225, 190);
                break;
            }
            BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color, isEmissive: false, environmentData);
        }
Esempio n. 14
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            if (environmentData.SubsystemTerrain == null)
            {
                return;
            }
            int             designIndex = GetDesignIndex(Terrain.ExtractData(value));
            FurnitureDesign design      = environmentData.SubsystemTerrain.SubsystemFurnitureBlockBehavior.GetDesign(designIndex);

            if (design == null)
            {
                return;
            }
            Vector3 v = default(Vector3);

            v.X = -0.5f * (float)(design.Box.Left + design.Box.Right) / (float)design.Resolution;
            v.Y = -0.5f * (float)(design.Box.Top + design.Box.Bottom) / (float)design.Resolution;
            v.Z = -0.5f * (float)(design.Box.Near + design.Box.Far) / (float)design.Resolution;
            Matrix            matrix2  = Matrix.CreateTranslation(v * size) * matrix;
            FurnitureGeometry geometry = design.Geometry;

            for (int i = 0; i < 6; i++)
            {
                float s      = LightingManager.LightIntensityByLightValueAndFace[environmentData.Light + 16 * CellFace.OppositeFace(i)];
                Color color2 = Color.MultiplyColorOnly(color, s);
                if (geometry.SubsetOpaqueByFace[i] != null)
                {
                    BlocksManager.DrawMeshBlock(primitivesRenderer, geometry.SubsetOpaqueByFace[i], color2, size, ref matrix2, environmentData);
                }
                if (geometry.SubsetAlphaTestByFace[i] != null)
                {
                    BlocksManager.DrawMeshBlock(primitivesRenderer, geometry.SubsetAlphaTestByFace[i], color2, size, ref matrix2, environmentData);
                }
            }
        }
Esempio n. 15
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. 16
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int num = Terrain.ExtractData(value);

            if (num < m_blockMeshes.Length)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[num], color, size, ref matrix, environmentData);
            }
        }
Esempio n. 17
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int mode = (int)GetMode(Terrain.ExtractData(value));

            if (mode < m_standaloneBlockMeshes.Length && m_standaloneBlockMeshes[mode] != null)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[mode], color, 1f * size, ref matrix, environmentData);
            }
        }
Esempio n. 18
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int arrowType = (int)GetArrowType(Terrain.ExtractData(value));

            if (arrowType >= 0 && arrowType < m_standaloneBlockMeshes.Count)
            {
                BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[arrowType], color, 2f * size, ref matrix, environmentData);
            }
        }
Esempio n. 19
0
        public static void DrawFlatBlock(PrimitivesRenderer3D primitivesRenderer, int value, float size, ref Matrix matrix, Texture2D texture, Color color, bool isEmissive, DrawBlockEnvironmentData environmentData)
        {
            environmentData = (environmentData ?? m_defaultEnvironmentData);
            if (!isEmissive)
            {
                float s = LightingManager.LightIntensityByLightValue[environmentData.Light];
                color = Color.MultiplyColorOnly(color, s);
            }
            Vector3 translation = matrix.Translation;
            Vector3 vector;
            Vector3 v;

            if (environmentData.BillboardDirection.HasValue)
            {
                vector = Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, Vector3.UnitY));
                v      = -Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, vector));
            }
            else
            {
                vector = matrix.Right;
                v      = matrix.Up;
            }
            Vector3 v2 = translation + 0.85f * size * (-vector - v);
            Vector3 v3 = translation + 0.85f * size * (vector - v);
            Vector3 v4 = translation + 0.85f * size * (-vector + v);
            Vector3 v5 = translation + 0.85f * size * (vector + v);

            if (environmentData.ViewProjectionMatrix.HasValue)
            {
                Matrix m = environmentData.ViewProjectionMatrix.Value;
                Vector3.Transform(ref v2, ref m, out v2);
                Vector3.Transform(ref v3, ref m, out v3);
                Vector3.Transform(ref v4, ref m, out v4);
                Vector3.Transform(ref v5, ref m, out v5);
            }
            int     num   = Terrain.ExtractContents(value);
            Block   block = Blocks[num];
            Vector4 vector2;

            if (texture != null)
            {
                vector2 = new Vector4(0f, 0f, 1f, 1f);
            }
            else
            {
                texture = ((environmentData.SubsystemTerrain != null) ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture);
                vector2 = m_slotTexCoords[block.GetFaceTextureSlot(-1, value)];
            }
            TexturedBatch3D texturedBatch3D = primitivesRenderer.TexturedBatch(texture, useAlphaTest: true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp);

            texturedBatch3D.QueueQuad(v2, v4, v5, v3, new Vector2(vector2.X, vector2.W), new Vector2(vector2.X, vector2.Y), new Vector2(vector2.Z, vector2.Y), new Vector2(vector2.Z, vector2.W), color);
            if (!environmentData.BillboardDirection.HasValue)
            {
                texturedBatch3D.QueueQuad(v2, v3, v5, v4, new Vector2(vector2.X, vector2.W), new Vector2(vector2.Z, vector2.W), new Vector2(vector2.Z, vector2.Y), new Vector2(vector2.X, vector2.Y), color);
            }
        }
Esempio n. 20
0
 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
 {
     if (GetHammerState(Terrain.ExtractData(value)))
     {
         BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshLoaded, color, 2f * size, ref matrix, environmentData);
     }
     else
     {
         BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshUnloaded, color, 2f * size, ref matrix, environmentData);
     }
 }
Esempio n. 21
0
 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
 {
     if (GetIsWild(Terrain.ExtractData(value)))
     {
         color *= BlockColorsMap.GrassColorsMap.Lookup(environmentData.Temperature, environmentData.Humidity);
         BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color, isEmissive: false, environmentData);
     }
     else
     {
         BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color, isEmissive: false, environmentData);
     }
 }
Esempio n. 22
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            if ((Terrain.ExtractData(value) >> 10) != 0)
            {
                base.DrawBlock(primitivesRenderer, value, color, size, ref matrix, environmentData);
                return;
            }
            int   bulletType = (int)GetBulletType(Terrain.ExtractData(value));
            float size2      = (bulletType >= 0 && bulletType < m_sizes.Length) ? (size * m_sizes[bulletType]) : size;

            ItemBlock.DrawFlatBlock(primitivesRenderer, value, size2, ref matrix, ItemBlock.Texture, color, false, environmentData);
        }
Esempio n. 23
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int   data       = Terrain.ExtractData(value);
            int   color2     = GetColor(data);
            Shape shape      = GetShape(data);
            int   altitude   = GetAltitude(data);
            bool  flickering = GetFlickering(data);

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_headBlockMeshes[(int)shape * 8 + color2], color, 2f * size, ref matrix, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_bodyBlockMeshes[altitude], color, 2f * size, ref matrix, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_finsBlockMeshes[flickering ? 1 : 0], color, 2f * size, ref matrix, environmentData);
        }
Esempio n. 24
0
        public static List <int> normalpos  = new List <int>(); //位置面修正

        public static void DrawCubeBlock(PrimitivesRenderer3D primitivesRenderer, int value, Vector3 size, ref Matrix matrix, Color color, Color topColor, DrawBlockEnvironmentData environmentData)
        {
            TexturedBatch3D texturedBatch3D = primitivesRenderer.TexturedBatch(texture, useAlphaTest: true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp);
            float           s = LightingManager.LightIntensityByLightValue[environmentData.Light];//光强

            color    = Color.MultiplyColorOnly(color, s);
            topColor = Color.MultiplyColorOnly(topColor, s);
            Vector3 translation = matrix.Translation;
            Vector3 vector      = matrix.Right * size.X;
            Vector3 v           = matrix.Up * size.Y;
            Vector3 v2          = matrix.Forward * size.Z;
            Vector3 v3          = translation + 0.5f * (-vector - v - v2);
            Vector3 v4          = translation + 0.5f * (vector - v - v2);
            Vector3 v5          = translation + 0.5f * (-vector + v - v2);
            Vector3 v6          = translation + 0.5f * (vector + v - v2);
            Vector3 v7          = translation + 0.5f * (-vector - v + v2);
            Vector3 v8          = translation + 0.5f * (vector - v + v2);
            Vector3 v9          = translation + 0.5f * (-vector + v + v2);
            Vector3 v10         = translation + 0.5f * (vector + v + v2);

            if (environmentData.ViewProjectionMatrix.HasValue)
            {
                Matrix m = environmentData.ViewProjectionMatrix.Value;
                Vector3.Transform(ref v3, ref m, out v3);
                Vector3.Transform(ref v4, ref m, out v4);
                Vector3.Transform(ref v5, ref m, out v5);
                Vector3.Transform(ref v6, ref m, out v6);
                Vector3.Transform(ref v7, ref m, out v7);
                Vector3.Transform(ref v8, ref m, out v8);
                Vector3.Transform(ref v9, ref m, out v9);
                Vector3.Transform(ref v10, ref m, out v10);
            }
            Block   block   = BlocksManager.Blocks[Terrain.ExtractContents(value)];
            Vector4 vector2 = m_slotTexCoords[block.GetFaceTextureSlot(0, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Forward)), p1: v3, p2: v5, p3: v6, p4: v4, texCoord1: new Vector2(vector2.X, vector2.W), texCoord2: new Vector2(vector2.X, vector2.Y), texCoord3: new Vector2(vector2.Z, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.W));
            Vector4 vector3 = m_slotTexCoords[block.GetFaceTextureSlot(2, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Forward)), p1: v7, p2: v8, p3: v10, p4: v9, texCoord1: new Vector2(vector3.Z, vector3.W), texCoord2: new Vector2(vector3.X, vector3.W), texCoord3: new Vector2(vector3.X, vector3.Y), texCoord4: new Vector2(vector3.Z, vector3.Y));
            Vector4 vector4 = m_slotTexCoords[block.GetFaceTextureSlot(5, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Up)), p1: v3, p2: v4, p3: v8, p4: v7, texCoord1: new Vector2(vector4.X, vector4.Y), texCoord2: new Vector2(vector4.Z, vector4.Y), texCoord3: new Vector2(vector4.Z, vector4.W), texCoord4: new Vector2(vector4.X, vector4.W));
            Vector4 vector5 = m_slotTexCoords[block.GetFaceTextureSlot(4, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(topColor, LightingManager.CalculateLighting(matrix.Up)), p1: v5, p2: v9, p3: v10, p4: v6, texCoord1: new Vector2(vector5.X, vector5.W), texCoord2: new Vector2(vector5.X, vector5.Y), texCoord3: new Vector2(vector5.Z, vector5.Y), texCoord4: new Vector2(vector5.Z, vector5.W));
            Vector4 vector6 = m_slotTexCoords[block.GetFaceTextureSlot(1, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Right)), p1: v3, p2: v7, p3: v9, p4: v5, texCoord1: new Vector2(vector6.Z, vector6.W), texCoord2: new Vector2(vector6.X, vector6.W), texCoord3: new Vector2(vector6.X, vector6.Y), texCoord4: new Vector2(vector6.Z, vector6.Y));
            Vector4 vector7 = m_slotTexCoords[block.GetFaceTextureSlot(3, value)];

            texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Right)), p1: v4, p2: v6, p3: v10, p4: v8, texCoord1: new Vector2(vector7.X, vector7.W), texCoord2: new Vector2(vector7.X, vector7.Y), texCoord3: new Vector2(vector7.Z, vector7.Y), texCoord4: new Vector2(vector7.Z, vector7.W));
        }
Esempio n. 25
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. 26
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            int data = Terrain.ExtractData(value);
            int draw = GetDraw(data);

            ArrowBlock.ArrowType?arrowType = GetArrowType(data);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[draw], color, 2f * size, ref matrix, environmentData);
            if (arrowType.HasValue)
            {
                Matrix matrix2 = Matrix.CreateRotationX(-(float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0.2f * size, -0.09f * size) * matrix;
                int    value2  = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value));
                BlocksManager.Blocks[192].DrawBlock(primitivesRenderer, value2, color, size, ref matrix2, environmentData);
            }
        }
Esempio n. 27
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);
            }
        }
        public void Draw(Camera camera, int drawOrder)
        {
            this.cam = camera;
            if (Point1.HasValue && Point2.HasValue && WorldEditMenu.IsChecked) // Выделение зоны между точками 1 и 2
            {
                int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int endX   = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int endY   = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                int endZ   = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                PrimitivesRenderer3D PrimitivesRenderer3D = new PrimitivesRenderer3D();
                Vector3     pointStart  = new Vector3(startX, startY, startZ);
                Vector3     pointEnd    = new Vector3(endX + 1, endY + 1, endZ + 1);
                BoundingBox boundingBox = new BoundingBox(pointStart, pointEnd);
                PrimitivesRenderer3D.FlatBatch(-1, DepthStencilState.None, (RasterizerState)null, (BlendState)null).QueueBoundingBox(boundingBox, Color.Green);
                PrimitivesRenderer3D.Flush(cam.ViewProjectionMatrix, true);
            }

            if (Point3.HasValue && WorldEditMenu.IsChecked) // Выделение зоны вставки
            {
                int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int endX   = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int endY   = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                int endZ   = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                startX += Point3.Value.CellFace.Point.X - Point1.Value.CellFace.Point.X;
                startY += Point3.Value.CellFace.Point.Y - Point1.Value.CellFace.Point.Y;
                startZ += Point3.Value.CellFace.Point.Z - Point1.Value.CellFace.Point.Z;
                endX   += Point3.Value.CellFace.Point.X - Point1.Value.CellFace.Point.X;
                endY   += Point3.Value.CellFace.Point.Y - Point1.Value.CellFace.Point.Y;
                endZ   += Point3.Value.CellFace.Point.Z - Point1.Value.CellFace.Point.Z;

                PrimitivesRenderer3D primitivesRenderer3D = new PrimitivesRenderer3D();
                Vector3     pointStart  = new Vector3(startX, startY, startZ);
                Vector3     pointEnd    = new Vector3(endX + 1, endY + 1, endZ + 1);
                BoundingBox boundingBox = new BoundingBox(pointStart, pointEnd);
                primitivesRenderer3D.FlatBatch(-1, DepthStencilState.None, (RasterizerState)null, (BlendState)null).QueueBoundingBox(boundingBox, Color.Red);
                primitivesRenderer3D.Flush(cam.ViewProjectionMatrix, true);
            }
            PrimitivesRenderer3D.Flush(camera.ViewProjectionMatrix, true, int.MaxValue);
            PrimitivesRenderer2D.Flush(true);
        }
Esempio n. 29
0
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            float radians = 0f;

            if (environmentData != null && environmentData.SubsystemTerrain != null)
            {
                Vector3 forward     = environmentData.InWorldMatrix.Forward;
                Vector3 translation = environmentData.InWorldMatrix.Translation;
                Vector3 v           = environmentData.SubsystemTerrain.Project.FindSubsystem <SubsystemMagnetBlockBehavior>(throwOnError: true).FindNearestCompassTarget(translation);
                Vector3 vector      = translation - v;
                radians = Vector2.Angle(v2: new Vector2(forward.X, forward.Z), v1: new Vector2(vector.X, vector.Z));
            }
            Matrix matrix2 = matrix;
            Matrix matrix3 = Matrix.CreateRotationY(radians) * matrix;

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_caseMesh, color, size * 6f, ref matrix2, environmentData);
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_pointerMesh, color, size * 6f, ref matrix3, environmentData);
        }
Esempio n. 30
0
 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
 {
     BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, size, ref matrix, environmentData);
 }
Esempio n. 31
0
        internal static void WorldEditModApi()
        {
            if (!(ScreensManager.GetScreenName(ScreensManager.CurrentScreen) == "Game")) // Выходим, если мы не в игре
            {
                return;
            }

            // Показазывеем контейнер с кнопками, если активирована кнопка WorldEditMenu
            ScreensManager.CurrentScreen.ScreenWidget.FindWidget<StackPanelWidget>("WorldEditMenuContainerTop", true).IsVisible = ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsChecked;
            ScreensManager.CurrentScreen.ScreenWidget.FindWidget<StackPanelWidget>("WorldEditMenuContainerBottom", true).IsVisible = ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsChecked;

            // Смена режима управления
            if (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsTapped)
            {
               if (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsChecked)
                {
                    OldLookControlMode = (int) SettingsManager.LookControlMode;
                    SettingsManager.LookControlMode = LookControlMode.SplitTouch;
                }
                else
                {
                    SettingsManager.LookControlMode = (LookControlMode) OldLookControlMode;
                }
            }

            if ((Engine.Input.Keyboard.IsKeyDown(Engine.Input.Key.F1)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F1", true).IsTapped)) // Выделение 1 точки
            {
                ComponentMiner componentMiner = Subsystems.Player.ComponentPlayer.ComponentMiner;
                Point1 = componentMiner.PickTerrainForDigging(Subsystems.Drawing.ViewPosition, Subsystems.Drawing.ViewDirection);

                if (Point1.HasValue)
                {
                    SCModApi.Gui.DisplayMessage("Set position 1 on: " + Point1.Value.CellFace.X + ", " + Point1.Value.CellFace.Y + ", " + Point1.Value.CellFace.Z, false);
                    SelectedBlock = World.GetBlock(Point1.Value.CellFace.X, Point1.Value.CellFace.Y, Point1.Value.CellFace.Z);
                    return;
                }
            }

            if ((Engine.Input.Keyboard.IsKeyDown(Engine.Input.Key.F2)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F2", true).IsTapped)) // Выделение 2 точки
            {
                ComponentMiner componentMiner = Subsystems.Player.ComponentPlayer.ComponentMiner;
                Point2 = componentMiner.PickTerrainForDigging(Subsystems.Drawing.ViewPosition, Subsystems.Drawing.ViewDirection);
                if (Point2.HasValue)
                {
                    SCModApi.Gui.DisplayMessage("Set position 2 on: " + Point1.Value.CellFace.X + ", " + Point1.Value.CellFace.Y + ", " + Point1.Value.CellFace.Z, false);
                    ReplaceableBlock = Subsystems.Terrain.TerrainData.GetCellValue(Point2.Value.CellFace.X, Point2.Value.CellFace.Y, Point2.Value.CellFace.Z);
                    return;
                }
            }

            if ((Engine.Input.Keyboard.IsKeyDown(Engine.Input.Key.F3)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F3", true).IsTapped)) // Выделение 3 точки
            {
                ComponentMiner componentMiner = Subsystems.Player.ComponentPlayer.ComponentMiner;
                Point3 = componentMiner.PickTerrainForDigging(Subsystems.Drawing.ViewPosition, Subsystems.Drawing.ViewDirection);
                if (Point3.HasValue)
                {
                    SCModApi.Gui.DisplayMessage("Set position 3 on: " + Point1.Value.CellFace.X + ", " + Point1.Value.CellFace.Y + ", " + Point1.Value.CellFace.Z, false);
                    return;
                }
            }

            if (Point1.HasValue && Point2.HasValue && ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsChecked) // Выделение зоны между точками 1 и 2
            {
                int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                PrimitivesRenderer3D PrimitivesRenderer3D = new PrimitivesRenderer3D();
                Vector3 pointStart = new Vector3(startX, startY, startZ);
                Vector3 pointEnd = new Vector3(endX + 1, endY + 1, endZ + 1);
                BoundingBox boundingBox = new BoundingBox(pointStart, pointEnd);
                PrimitivesRenderer3D.FlatBatch(-1, DepthStencilState.None, (RasterizerState)null, (BlendState)null).QueueBoundingBox(boundingBox, Color.Green);
                PrimitivesRenderer3D.Flush(Subsystems.Drawing.ViewProjectionMatrix, true);
            }

            if (Point3.HasValue && ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("WorldEditMenu", true).IsChecked) // Выделение зоны вставки
            {

                int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                startX += Point3.Value.CellFace.Point.X - Point1.Value.CellFace.Point.X;
                startY += Point3.Value.CellFace.Point.Y - Point1.Value.CellFace.Point.Y;
                startZ += Point3.Value.CellFace.Point.Z - Point1.Value.CellFace.Point.Z;
                endX += Point3.Value.CellFace.Point.X - Point1.Value.CellFace.Point.X;
                endY += Point3.Value.CellFace.Point.Y - Point1.Value.CellFace.Point.Y;
                endZ += Point3.Value.CellFace.Point.Z - Point1.Value.CellFace.Point.Z;

                PrimitivesRenderer3D primitivesRenderer3D = new PrimitivesRenderer3D();
                Vector3 pointStart = new Vector3(startX, startY, startZ);
                Vector3 pointEnd = new Vector3(endX + 1, endY + 1, endZ + 1);
                BoundingBox boundingBox = new BoundingBox(pointStart, pointEnd);
                primitivesRenderer3D.FlatBatch(-1, DepthStencilState.None, (RasterizerState)null, (BlendState)null).QueueBoundingBox(boundingBox, Color.Red);
                primitivesRenderer3D.Flush(Subsystems.Drawing.ViewProjectionMatrix, true);
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F5)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F5", true).IsTapped)) // Копирование выделенной зоны
            {
                if (Point1 == null)
                {
                    Gui.DisplayMessage("You have not selected point 1", false);
                }
                else if (Point2 == null)
                {
                    Gui.DisplayMessage("You have not selected point 2", false);
                }
                else if (Point3 == null)
                {
                    Gui.DisplayMessage("You have not selected point 3", false);
                }
                else
                {
                    int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                    int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                    for (int y = 0; y <= endY - startY; y++)
                    {
                        for (int z = 0; z <= endZ - startZ; z++)
                        {
                            for (int x = 0; x <= endX - startX; x++)
                            {
                                int targetX, targetY, targetZ;
                                int PlaceX, PlaceY, PlaceZ;
                                if (Point1.Value.CellFace.Point.X > Point2.Value.CellFace.Point.X)
                                {
                                    targetX = Point1.Value.CellFace.Point.X - x;
                                    PlaceX = Point3.Value.CellFace.Point.X - x;
                                }
                                else
                                {
                                    targetX = Point1.Value.CellFace.Point.X + x;
                                    PlaceX = Point3.Value.CellFace.Point.X + x;
                                }

                                if (Point1.Value.CellFace.Point.Y > Point2.Value.CellFace.Point.Y)
                                {
                                    targetY = Point1.Value.CellFace.Point.Y - y;
                                    PlaceY = Point3.Value.CellFace.Point.Y - y;
                                }
                                else
                                {
                                    targetY = Point1.Value.CellFace.Point.Y + y;
                                    PlaceY = Point3.Value.CellFace.Point.Y + y;
                                }

                                if (Point1.Value.CellFace.Point.Z > Point2.Value.CellFace.Point.Z)
                                {
                                    targetZ = Point1.Value.CellFace.Point.Z - z;
                                    PlaceZ = Point3.Value.CellFace.Point.Z - z;
                                }
                                else
                                {
                                    targetZ = Point1.Value.CellFace.Point.Z + z;
                                    PlaceZ = Point3.Value.CellFace.Point.Z + z;
                                }

                                int block = World.GetBlock(targetX, targetY, targetZ);
                                // 15360 - Air
                                if (block != 15360) World.SetBlock(PlaceX, PlaceY, PlaceZ, block);
                            }
                        }
                    }
                }
                return;
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F6)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F6", true).IsTapped)) // Заполнение зоны
            {
                if (Point1 == null)
                {
                    Gui.DisplayMessage("You have not selected point 1", false);
                }
                else if (Point2 == null)
                {
                    Gui.DisplayMessage("You have not selected point 2", false);
                }
                else
                {
                    int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                    int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                    for (int x = startX; x <= endX; x++)
                    {
                        for (int y = startY; y <= endY; y++)
                        {
                            for (int z = startZ; z <= endZ; z++)
                            {
                                World.SetBlock(x, y, z, SelectedBlock);
                            }
                        }
                    }
                }
                return;
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F7)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F7", true).IsTapped)) // Замена зоны
            {
                if (Point1 == null)
                {
                    Gui.DisplayMessage("You have not selected point 1", false);
                }
                else if (Point2 == null)
                {
                    Gui.DisplayMessage("You have not selected point 2", false);
                }
                else
                {
                    int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                    int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                    for (int x = startX; x <= endX; x++)
                    {
                        for (int y = startY; y <= endY; y++)
                        {
                            for (int z = startZ; z <= endZ; z++)
                            {
                                if (World.GetBlock(x, y, z) == ReplaceableBlock) World.SetBlock(x, y, z, SelectedBlock);
                            }
                        }
                    }
                }
                return;
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F8)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F8", true).IsTapped)) // Очистка зоны
            {
                if (Point1 == null)
                {
                    Gui.DisplayMessage("You have not selected point 1", false);
                }
                else if (Point2 == null)
                {
                    Gui.DisplayMessage("You have not selected point 2", false);
                }
                else
                {
                    int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                    int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                    for (int x = startX; x <= endX; x++)
                    {
                        for (int y = startY; y <= endY; y++)
                        {
                            for (int z = startZ; z <= endZ; z++)
                            {
                                World.SetBlock(x, y, z, 0);
                            }
                        }
                    }
                }
                return;
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F9)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F9", true).IsTapped)) // Копирование зоны в память
            {
                if (Point1 == null)
                {
                    Gui.DisplayMessage("You have not selected point 1", false);
                }
                else if (Point2 == null)
                {
                    Gui.DisplayMessage("You have not selected point 2", false);
                }
                else
                {
                    int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X);
                    int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y);
                    int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);
                    int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z);

                    blockCount = 0;
                    BlockList.Clear();

                    for (int x = 0; x <= endX - startX; x++)
                    {
                        for (int y = 0; y <= endY - startY; y++)
                        {
                            for (int z = 0; z <= endZ - startZ; z++)
                            {
                                BlockMem blmem = new BlockMem();
                                int X, Y, Z;
                                if (Point1.Value.CellFace.Point.X > Point2.Value.CellFace.Point.X)
                                {
                                    blmem.x = - x;
                                    X = Point1.Value.CellFace.Point.X - x;
                                }
                                else
                                {
                                    blmem.x = x;
                                    X = Point1.Value.CellFace.Point.X + x;
                                }

                                if (Point1.Value.CellFace.Point.Y > Point2.Value.CellFace.Point.Y)
                                {
                                    blmem.y = - y;
                                    Y = Point1.Value.CellFace.Point.Y - y;
                                }
                                else
                                {
                                    blmem.y = y;
                                    Y = Point1.Value.CellFace.Point.Y + y;
                                }

                                if (Point1.Value.CellFace.Point.Z > Point2.Value.CellFace.Point.Z)
                                {
                                    blmem.z = - z;
                                    Z = Point1.Value.CellFace.Point.Z - z;
                                }
                                else
                                {
                                    blmem.z = z;
                                    Z = Point1.Value.CellFace.Point.Z + z;
                                }

                                blmem.id = World.GetBlock(X, Y, Z);
                                BlockList.Add(blmem);
                                blockCount++;
                            }
                        }
                    }
                }
                Gui.DisplayMessage("Copied " + blockCount + " blocks", false);
                return;
            }

            if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F10)) || (ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>("F10", true).IsTapped))  // Вставка зоны из памяти
            {
                if (Point3 == null) Gui.DisplayMessage("You have not selected point 3", false);
                else
                {
                    for (var i = 0; i < blockCount; i++)
                    {
                        var xPos = Point3.Value.CellFace.X + BlockList[i].x;
                        var yPos = Point3.Value.CellFace.Y + BlockList[i].y;
                        var zPos = Point3.Value.CellFace.Z + BlockList[i].z;

                        World.SetBlock(xPos, yPos, zPos, BlockList[i].id);
                    }
                    Gui.DisplayMessage("Pasted " + blockCount + " blocks", false);
                }
            }
        }