예제 #1
0
 public override void Update()
 {
     base.Update();
     if (this.OKButton.IsClicked)
     {
         Task.Run(() =>
         {
             int num               = 0;
             ChunkData chunkData   = new ChunkData(this.creatorAPI);
             creatorAPI.revokeData = new ChunkData(this.creatorAPI);
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.TwoPointLineGeneration2(creatorAPI.Position[0], creatorAPI.Position[1]))
             {
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
 }
예제 #2
0
 public override void Update()
 {
     if (slider.IsSliding)
     {
         slider.Value = (int)slider.Value;
     }
     this.slider.Text = "大小:" + (int)slider.Value;
     if (this.OKButton.IsClicked)
     {
         Point3 Start = creatorAPI.Position[0];
         Point3 End   = creatorAPI.Position[1];
         CreatorMain.Math.StartEnd(ref Start, ref End);
         try
         {
             List <int> BlockIDs = new List <int>();
             foreach (string BlockIDString in TextBox.Text.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries))
             {
                 BlockIDs.Add(int.Parse(BlockIDString));
             }
             Task.Run(delegate
             {
                 ChunkData chunkData   = new ChunkData(this.creatorAPI);
                 creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                 int num = 0;
                 for (int x = End.X; x <= Start.X; x++)
                 {
                     for (int y = End.Y; y <= Start.Y; y++)
                     {
                         for (int z = End.Z; z <= Start.Z; z++)
                         {
                             if (!creatorAPI.launch)
                             {
                                 return;
                             }
                             int mx      = (x - End.X) / (int)slider.Value;
                             int my      = (y - End.Y) / (int)slider.Value;
                             int mz      = (z - End.Z) / (int)slider.Value;
                             int blockID = BlockIDs[(mx + my + mz) % (int)BlockIDs.Count];
                             creatorAPI.CreateBlock(x, y, z, blockID, chunkData);
                             num++;
                         }
                     }
                 }
                 chunkData.Render();
                 this.player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
             });
         }
         catch
         {
             this.player.ComponentGui.DisplaySmallMessage("操作失败", true, true);
         }
         DialogsManager.HideDialog(this);
     }
     if (this.cancelButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
예제 #3
0
 public override void Update()
 {
     base.Update();
     this.delayLabel.Text = $"大小{(int)this.Radius.Value}块";
     this.upDataButton();
     if (this.SoildButton.IsClicked)
     {
         Task.Run(() =>
         {
             ChunkData chunkData   = new ChunkData(this.creatorAPI);
             creatorAPI.revokeData = new ChunkData(this.creatorAPI);
             int num = 0;
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Prism(creatorAPI.Position[0], (int)Radius.Value, this.creatorType))
             {
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
     if (this.HollowButton.IsClicked)
     {
         Task.Run(() =>
         {
             ChunkData chunkData   = new ChunkData(this.creatorAPI);
             creatorAPI.revokeData = new ChunkData(this.creatorAPI);
             int num = 0;
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Prism(creatorAPI.Position[0], (int)Radius.Value, this.creatorType, true))
             {
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
 }
예제 #4
0
 public override void upClickButton(int id)
 {
     if (this.SoildButton.IsClicked)
     {
         Task.Run(() =>
         {
             int num               = 0;
             ChunkData chunkData   = new ChunkData(this.creatorAPI);
             creatorAPI.revokeData = new ChunkData(this.creatorAPI);
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Circle(creatorAPI.Position[0], (int)Height.Value, (int)Radius.Value, this.creatorType))
             {
                 creatorAPI.CreateBlock(point3, id, chunkData);
                 num++;
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
     if (this.HollowButton.IsClicked)
     {
         Task.Run(() =>
         {
             int num               = 0;
             ChunkData chunkData   = new ChunkData(this.creatorAPI);
             creatorAPI.revokeData = new ChunkData(this.creatorAPI);
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Circle(creatorAPI.Position[0], (int)Height.Value, (int)Radius.Value, this.creatorType, true))
             {
                 creatorAPI.CreateBlock(point3, id, chunkData);
                 num++;
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
 }
예제 #5
0
        /// <summary>
        /// 一键生成
        /// </summary>
        /// <param name="creatorAPI"></param>
        /// <param name="path"></param>
        /// <param name="position"></param>
        public static void GenerationData(CreatorAPI creatorAPI, string path, Point3 position)
        {
            ChunkData chunkData = new ChunkData(creatorAPI);

            creatorAPI.revokeData = new ChunkData(creatorAPI);
            ComponentPlayer    player       = creatorAPI.componentMiner.ComponentPlayer;
            Stream             fileStream   = new FileStream(path, FileMode.Open).CreateStream();
            EngineBinaryReader binaryReader = new EngineBinaryReader(fileStream, false);
            int count = 0;
            int MinX  = binaryReader.ReadInt32();
            int MinY  = binaryReader.ReadInt32();
            int MInZ  = binaryReader.ReadInt32();
            int MaxX  = binaryReader.ReadInt32();
            int MaxY  = binaryReader.ReadInt32();
            int MaxZ  = binaryReader.ReadInt32();

            for (int PositionX = MinX; PositionX <= MaxX; PositionX++)
            {
                for (int PositionY = MinY; PositionY <= MaxY; PositionY++)
                {
                    for (int PositionZ = MInZ; PositionZ <= MaxZ; PositionZ++)
                    {
                        if (!creatorAPI.launch)
                        {
                            return;
                        }
                        int id = binaryReader.ReadInt32();
                        if (!creatorAPI.AirIdentify && Terrain.ExtractContents(id) == 0)
                        {
                            continue;
                        }
                        creatorAPI.CreateBlock(position.X + PositionX, position.Y + PositionY, position.Z + PositionZ, id, chunkData);
                        count++;
                    }
                }
            }
            binaryReader.Dispose();
            fileStream.Dispose();
            chunkData.Render();
            creatorAPI.componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage($"操作成功,共{count}个方块", true, true);
        }
예제 #6
0
        public override void Update()
        {
            if (this.cancelButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            if (this.roughReplaceButton.IsClicked)
            {
                Regex regex = new Regex("^[0-9]+$");
                if (Blockid2.Text == "")
                {
                    Blockid2.Text = "0";
                }
                Match match  = regex.Match(this.Blockid.Text);
                Match match2 = regex.Match(this.Blockid2.Text);
                if (match.Success && match2.Success)
                {
                    Point3 Start = creatorAPI.Position[0];
                    Point3 End   = creatorAPI.Position[1];
                    CreatorMain.Math.StartEnd(ref Start, ref End);
                    Task.Run(() =>
                    {
                        int num               = 0;
                        ChunkData chunkData   = new ChunkData(this.creatorAPI);
                        creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                        for (int x = 0; x <= Start.X - End.X; x++)
                        {
                            for (int y = 0; y <= Start.Y - End.Y; y++)
                            {
                                for (int z = 0; z <= Start.Z - End.Z; z++)
                                {
                                    int id = this.subsystemTerrain.Terrain.GetCellValueFast(End.X + x, End.Y + y, End.Z + z);
                                    if (!creatorAPI.AirIdentify && Terrain.ExtractContents(id) == 0)
                                    {
                                        continue;
                                    }
                                    if (id == int.Parse(this.Blockid.Text) || Terrain.ExtractContents(id) == int.Parse(this.Blockid.Text))
                                    {
                                        if (!creatorAPI.launch)
                                        {
                                            return;
                                        }
                                        creatorAPI.CreateBlock(End.X + x, End.Y + y, End.Z + z, int.Parse(this.Blockid2.Text), chunkData);
                                        num++;
                                    }
                                }
                            }
                        }
                        chunkData.Render();
                        this.player.ComponentGui.DisplaySmallMessage($"操作成功,共替换{num}个方块", true, true);
                    });
                }
                else
                {
                    this.player.ComponentGui.DisplaySmallMessage("操作失败", true, true);
                }
                DialogsManager.HideDialog(this);
            }



            if (this.replaceButton.IsClicked || this.retainReplaceButton.IsClicked)
            {
                bool  type  = replaceButton.IsClicked;
                Regex regex = new Regex("^[0-9]+$");
                if (Blockid2.Text == "")
                {
                    Blockid2.Text = "0";
                }
                Match match  = regex.Match(this.Blockid.Text);
                Match match2 = regex.Match(this.Blockid2.Text);
                if (match.Success && match2.Success)
                {
                    Point3 Start = creatorAPI.Position[0];
                    Point3 End   = creatorAPI.Position[1];
                    CreatorMain.Math.StartEnd(ref Start, ref End);
                    Task.Run(() =>
                    {
                        ChunkData chunkData   = new ChunkData(this.creatorAPI);
                        creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                        int num = 0;
                        for (int x = 0; x <= Start.X - End.X; x++)
                        {
                            for (int y = 0; y <= Start.Y - End.Y; y++)
                            {
                                for (int z = 0; z <= Start.Z - End.Z; z++)
                                {
                                    int id = this.subsystemTerrain.Terrain.GetCellValueFast(End.X + x, End.Y + y, End.Z + z);
                                    if (!creatorAPI.AirIdentify && Terrain.ExtractContents(id) == 0)
                                    {
                                        continue;
                                    }
                                    if (type)
                                    {
                                        if (id == int.Parse(this.Blockid.Text))
                                        {
                                            if (!creatorAPI.launch)
                                            {
                                                return;
                                            }
                                            creatorAPI.CreateBlock(End.X + x, End.Y + y, End.Z + z, int.Parse(this.Blockid2.Text), chunkData);
                                            num++;
                                        }
                                    }
                                    else
                                    {
                                        if (id != int.Parse(this.Blockid.Text))
                                        {
                                            if (!creatorAPI.launch)
                                            {
                                                return;
                                            }
                                            creatorAPI.CreateBlock(End.X + x, End.Y + y, End.Z + z, int.Parse(this.Blockid2.Text), chunkData);
                                            num++;
                                        }
                                    }
                                }
                            }
                        }
                        chunkData.Render();
                        this.player.ComponentGui.DisplaySmallMessage($"操作成功,共替换{num}个方块", true, true);
                    });
                }
                else
                {
                    this.player.ComponentGui.DisplaySmallMessage("操作失败", true, true);
                }
                DialogsManager.HideDialog(this);
            }
        }
예제 #7
0
        public override void Update()
        {
            base.Update();
            AdvancedButton.Color           = advanced ? Color.Yellow : Color.White;
            DoublePositionButton.Color     = DoublePosition ? Color.Yellow : Color.White;
            AdvancedGenerate.IsVisible     = advanced;
            DoublePositionButton.IsVisible = advanced;
            this.XdelayLabel.Text          = advanced ? $"X半径大小{(int)this.XRadius.Value}块" : $"半径大小{(int)this.XRadius.Value}块";
            this.YdelayLabel.Text          = $"Y半径大小{(int)this.YRadius.Value}块";
            this.ZdelayLabel.Text          = $"Z半径大小{(int)this.ZRadius.Value}块";
            int id = this.blockIconWidget.Value;

            if (DoublePositionButton.IsClicked)
            {
                DoublePosition = !DoublePosition;
            }
            if (AdvancedButton.IsClicked)
            {
                advanced = !advanced;
            }
            if (SoildButton.IsClicked)
            {
                if (advanced)
                {
                    if (!DoublePosition)
                    {
                        Task.Run(() =>
                        {
                            ChunkData chunkData   = new ChunkData(this.creatorAPI);
                            creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                            int num = 0;
                            foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(creatorAPI.Position[0]), (int)XRadius.Value, (int)YRadius.Value, (int)ZRadius.Value))
                            {
                                if (!creatorAPI.launch)
                                {
                                    return;
                                }
                                creatorAPI.CreateBlock(point3, id, chunkData);
                                num++;
                            }
                            chunkData.Render();
                            player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                        });
                    }
                    else
                    {
                        if (creatorAPI.Position[1].Y != -1)
                        {
                            Point3 Start = creatorAPI.Position[0];
                            Point3 End   = creatorAPI.Position[1];
                            CreatorMain.Math.StartEnd(ref Start, ref End);
                            float x = Math.Abs((float)Start.X - End.X) / 2f;
                            float y = Math.Abs((float)Start.Y - End.Y) / 2f;
                            float z = Math.Abs((float)Start.Z - End.Z) / 2f;
                            Task.Run(() =>
                            {
                                ChunkData chunkData   = new ChunkData(this.creatorAPI);
                                creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                                int num = 0;
                                foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(End.X + x, End.Y + y, End.Z + z), (int)x, (int)y, (int)z))
                                {
                                    if (!creatorAPI.launch)
                                    {
                                        return;
                                    }
                                    creatorAPI.CreateBlock(point3, id, chunkData);
                                    num++;
                                }
                                chunkData.Render();
                                player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                            });
                        }
                    }
                }
                else
                {
                    Task.Run(() =>
                    {
                        ChunkData chunkData   = new ChunkData(this.creatorAPI);
                        creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                        int num = 0;
                        foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(creatorAPI.Position[0]), (int)XRadius.Value, (int)XRadius.Value, (int)XRadius.Value))
                        {
                            if (!creatorAPI.launch)
                            {
                                return;
                            }
                            creatorAPI.CreateBlock(point3, id, chunkData);
                            num++;
                        }
                        chunkData.Render();
                        player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                    });
                }
                DialogsManager.HideDialog(this);
            }

            if (HollowButton.IsClicked)
            {
                if (advanced)
                {
                    if (!DoublePosition)
                    {
                        Task.Run(() =>
                        {
                            int num               = 0;
                            ChunkData chunkData   = new ChunkData(this.creatorAPI);
                            creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                            foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(creatorAPI.Position[0]), (int)XRadius.Value, (int)YRadius.Value, (int)ZRadius.Value, true))
                            {
                                if (!creatorAPI.launch)
                                {
                                    return;
                                }
                                creatorAPI.CreateBlock(point3, id, chunkData);
                                num++;
                            }
                            chunkData.Render();
                            player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                        });
                    }
                    else
                    {
                        if (creatorAPI.Position[1].Y != -1)
                        {
                            Point3 Start = creatorAPI.Position[0];
                            Point3 End   = creatorAPI.Position[1];
                            CreatorMain.Math.StartEnd(ref Start, ref End);
                            float x = Math.Abs((float)Start.X - End.X) / 2f;
                            float y = Math.Abs((float)Start.Y - End.Y) / 2f;
                            float z = Math.Abs((float)Start.Z - End.Z) / 2f;
                            Task.Run(() =>
                            {
                                ChunkData chunkData   = new ChunkData(this.creatorAPI);
                                creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                                int num = 0;
                                foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(End.X + x, End.Y + y, End.Z + z), (int)x, (int)y, (int)z, true))
                                {
                                    if (!creatorAPI.launch)
                                    {
                                        return;
                                    }
                                    creatorAPI.CreateBlock(point3, id, chunkData);
                                    num++;
                                }
                                chunkData.Render();
                                player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                            });
                        }
                    }
                }
                else
                {
                    Task.Run(() =>
                    {
                        ChunkData chunkData   = new ChunkData(this.creatorAPI);
                        creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                        int num = 0;
                        foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Sphere(new Vector3(creatorAPI.Position[0]), (int)XRadius.Value, (int)XRadius.Value, (int)XRadius.Value, true))
                        {
                            if (!creatorAPI.launch)
                            {
                                return;
                            }
                            creatorAPI.CreateBlock(point3, id, chunkData);
                            num++;
                        }
                        chunkData.Render();
                        player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
                    });
                }
                DialogsManager.HideDialog(this);
            }
        }
예제 #8
0
        public override void Update()
        {
            this.num_1.Text = $"参数1 :{(int)num1.Value}";
            this.num_2.Text = $"参数2 :{(int)num2.Value}";
            this.num_3.Text = $"参数3 :{(int)num3.Value}";
            if (this.restting.IsClicked)
            {
                this.num1.Value   = 0f;
                this.num2.Value   = 0f;
                this.num3.Value   = 100f;
                this.TextBox.Text = "3:2:8";
            }
            if (this.cancelButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            if (this.OK.IsClicked)
            {
                int      BlockID_1;
                int?     BlockID_2 = null, BlockID_3 = null;
                string[] texts = TextBox.Text.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                if (texts.Length == 2)
                {
                    if (!int.TryParse(texts[0], out BlockID_1))
                    {
                        BlockID_1 = 0;
                    }
                    int id;
                    if (int.TryParse(texts[1], out id))
                    {
                        BlockID_2 = id;
                    }
                }
                else if (texts.Length >= 3)
                {
                    if (!int.TryParse(texts[0], out BlockID_1))
                    {
                        BlockID_1 = 0;
                    }
                    int id;
                    if (int.TryParse(texts[1], out id))
                    {
                        BlockID_2 = id;
                    }
                    if (int.TryParse(texts[2], out id))
                    {
                        BlockID_3 = id;
                    }
                }
                else
                {
                    if (!int.TryParse(TextBox.Text, out BlockID_1))
                    {
                        BlockID_1 = 0;
                    }
                }
                Vector3 vector = new Vector3
                {
                    X = num1.Value,
                    Y = num2.Value,
                    Z = num3.Value
                };

                Point3 Start = creatorAPI.Position[0];
                Point3 End   = creatorAPI.Position[1];
                CreatorMain.Math.StartEnd(ref Start, ref End);
                float X_Radius = (Start.X - End.X) / 2f;
                float Z_Radius = (Start.Z - End.Z) / 2f;
                float Radius   = X_Radius > Z_Radius ? X_Radius : Z_Radius;
                float radius   = X_Radius > Z_Radius ? Z_Radius : X_Radius;
                Radius = Math.Abs(Math.Abs(Radius) - 2f + vector.X);
                if (BlockID_2 == null)
                {
                    BlockID_2 = BlockID_1;
                }
                if (BlockID_3 == null)
                {
                    BlockID_3 = BlockID_2;
                }
                Task.Run(() =>
                {
                    ChunkData chunkData   = new ChunkData(this.creatorAPI);
                    creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                    Game.Random random    = new Game.Random();
                    double pi             = Math.PI * 0.5f;
                    int number            = 0;
                    float num             = 1.25f + (vector.Y / 99f);
                    float rand            = random.UniformFloat(18f, 25f + (vector.Z / 10f));
                    for (int x = (int)-X_Radius; x <= (int)X_Radius; x++)
                    {
                        for (int z = (int)-Z_Radius; z <= Z_Radius; z++)
                        {
                            var a  = (Math.Cos(pi * x / Radius) * Math.Cos(pi * z / radius)) * (Start.Y - End.Y);
                            var b  = (Math.Sin(pi * x * num / radius + 2f) * Math.Cos(pi * z * num / Radius + 7f)) * (Start.Y - End.Y) * 0.35f;
                            var c  = (Math.Sin(pi * x * num * 2f / Radius + 2f * rand) * Math.Sin(pi * z * num * 2f / radius + 8f * rand)) * (Start.Y - End.Y) * 0.2f;
                            var e  = (Math.Sin(pi * x * num * 3.5f / radius + 2f * rand * 1.5f) * Math.Sin(pi * z * num * 3.5f / Radius + 12f * rand * 1.5f)) * (Start.Y - End.Y) * 0.15f;
                            var ls = a - b + c - e;
                            if (ls > 0f)
                            {
                                for (var i = 0; i <= ls; i++)
                                {
                                    Point3 point3 = new Point3((Start.X + End.X) / 2 + x, End.Y + (int)ls - i, (Start.Z + End.Z) / 2 + z);
                                    if (i > 5)
                                    {
                                        creatorAPI.CreateBlock(point3, BlockID_1, chunkData);
                                    }
                                    else if (i > 0)
                                    {
                                        creatorAPI.CreateBlock(point3, (int)BlockID_2, chunkData);
                                    }
                                    else if (i == 0)
                                    {
                                        creatorAPI.CreateBlock(point3, (int)BlockID_3, chunkData);
                                    }
                                    number++;
                                    if (!creatorAPI.launch)
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    chunkData.Render();
                    this.player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{number}个方块", true, true);
                });
                DialogsManager.HideDialog(this);
            }
        }
예제 #9
0
 public override void Update()
 {
     base.Update();
     if (this.SoildButton.IsClicked)
     {
         Task.Run(() =>
         {
             ChunkData chunkData   = new ChunkData(creatorAPI);
             creatorAPI.revokeData = new ChunkData(creatorAPI);
             int num = 0;
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Rectangular(creatorAPI.Position[0], creatorAPI.Position[1]))
             {
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
     if (this.HollowButton.IsClicked)
     {
         Task.Run(() =>
         {
             ChunkData chunkData   = new ChunkData(creatorAPI);
             creatorAPI.revokeData = new ChunkData(creatorAPI);
             int num = 0;
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Rectangular(creatorAPI.Position[0], creatorAPI.Position[1], true))
             {
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
     if (this.FrameworkButton.IsClicked)
     {
         Task.Run(() =>
         {
             ChunkData chunkData   = new ChunkData(creatorAPI);
             creatorAPI.revokeData = new ChunkData(creatorAPI);
             int num = 0;
             foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.Rectangular(creatorAPI.Position[0], creatorAPI.Position[1], false))
             {
                 if (!creatorAPI.launch)
                 {
                     return;
                 }
                 creatorAPI.CreateBlock(point3, this.blockIconWidget.Value, chunkData);
                 num++;
             }
             chunkData.Render();
             player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
         });
         DialogsManager.HideDialog(this);
     }
 }
예제 #10
0
        /// <summary>
        /// 粘贴
        /// </summary>
        /// <param name="creatorAPI"></param>
        /// <param name="path"></param>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        /// <param name="type"></param>
        public static void PasetData(CreatorAPI creatorAPI, string path, Point3 Start, Point3 End)
        {
            ChunkData chunkData = new ChunkData(creatorAPI);

            creatorAPI.revokeData = new ChunkData(creatorAPI);
            ComponentPlayer    player       = creatorAPI.componentMiner.ComponentPlayer;
            Stream             fileStream   = new FileStream(path, FileMode.Open).CreateStream();
            EngineBinaryReader binaryReader = new EngineBinaryReader(fileStream, false);
            int count = 0;
            int MaxX  = binaryReader.ReadInt32();
            int MaxY  = binaryReader.ReadInt32();
            int MaxZ  = binaryReader.ReadInt32();

            for (int PositionX = 0; PositionX <= MaxX; PositionX++)
            {
                for (int PositionY = 0; PositionY <= MaxY; PositionY++)
                {
                    for (int PositionZ = 0; PositionZ <= MaxZ; PositionZ++)
                    {
                        if (!creatorAPI.launch)
                        {
                            return;
                        }
                        int x, y, z;
                        int id = binaryReader.ReadInt32();
                        if (!creatorAPI.AirIdentify && Terrain.ExtractContents(id) == 0)
                        {
                            continue;
                        }
                        y = Start.Y + PositionY;
                        if (Start.X <= End.X && Start.Z <= End.Z)
                        {
                            x = Start.X + PositionX;
                            z = Start.Z + PositionZ;
                            if (creatorAPI.pasteLimit && (End.X < x || End.Z < z))
                            {
                                continue;
                            }
                            creatorAPI.CreateBlock(x, y, z, id, chunkData);
                        }
                        else if (Start.X >= End.X && Start.Z <= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X - MaxX + PositionX;
                                z = Start.Z + PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > x + Start.X - End.X || End.Z < z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X - PositionZ;
                                int _z = Start.Z + PositionX;
                                if (creatorAPI.pasteLimit && (Start.X > _x + Start.X - End.X || End.Z < _z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        else if (Start.X >= End.X && Start.Z >= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X - MaxX + PositionX;
                                z = Start.Z - MaxZ + PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > x + Start.X - End.X || Start.Z > z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X - PositionX;
                                int _z = Start.Z - PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > _x + Start.X - End.X || Start.Z > _z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        else if (Start.X <= End.X && Start.Z >= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X + PositionX;
                                z = Start.Z - MaxZ + PositionZ;
                                if (creatorAPI.pasteLimit && (End.X < x || Start.Z > z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X + PositionZ;
                                int _z = Start.Z - PositionX;
                                if (creatorAPI.pasteLimit && (End.X < _x || Start.Z > _z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        count++;
                    }
                }
            }
            binaryReader.Dispose();
            fileStream.Dispose();
            chunkData.Render();
            creatorAPI.componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage($"粘贴成功,共{count}个方块", true, true);
        }
예제 #11
0
        public static void SpecialPasetData(CreatorAPI creatorAPI, string path, Point3 Start, Point3 End)
        {
            ChunkData chunkData = new ChunkData(creatorAPI);

            creatorAPI.revokeData = new ChunkData(creatorAPI);
            Stream stream = File.OpenRead(path);

            CreatorMain.Math.StartEnd(ref Start, ref End);
            StreamReader streamReader = new StreamReader(stream);
            string       text         = streamReader.ReadToEnd();

            streamReader.Dispose();
            stream.Dispose();
            string[] data  = text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            string[] data2 = data[0].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string[] data3 = data2[0].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            int      MaxX  = int.Parse(data3[0]);
            int      MaxY  = int.Parse(data3[1]);
            int      MaxZ  = int.Parse(data3[2]);
            int      num   = 0;

            for (int x = 0; x <= MaxX; x++)
            {
                for (int y = 0; y <= MaxY; y++)
                {
                    for (int z = 0; z <= MaxZ; z++)
                    {
                        creatorAPI.CreateBlock(End.X + x, End.Y + y, End.Z + z, int.Parse(data2[num + 1]), chunkData);
                        num++;
                    }
                }
            }
            chunkData.Render();
            string[] data4 = data[1].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 1; i < data4.Length; i++)
            {
                string[]         data5            = data4[i].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                string[]         data6            = data5[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                DatabaseObject   databaseObject   = GameManager.Project.GameDatabase.Database.FindDatabaseObject(data5[0], GameManager.Project.GameDatabase.EntityTemplateType, true);
                ValuesDictionary valuesDictionary = new ValuesDictionary();
                valuesDictionary.PopulateFromDatabaseObject(databaseObject);
                valuesDictionary.GetValue <ValuesDictionary>("BlockEntity").SetValue <Point3>("Coordinates", new Point3(int.Parse(data6[0]) + End.X, int.Parse(data6[1]) + End.Y, int.Parse(data6[2]) + End.Z));
                Entity entity = GameManager.Project.CreateEntity(valuesDictionary);
                ComponentInventoryBase inventoryBase = entity.FindComponent <ComponentInventoryBase>();
                if (inventoryBase != null)
                {
                    for (int j = 2, s = 0; j < data5.Length; j++, s++)
                    {
                        string[] data7 = data5[j].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        inventoryBase.AddSlotItems(s, int.Parse(data7[0]), int.Parse(data7[1]));
                    }
                }
                GameManager.Project.AddEntity(entity);
            }
            string[] data8 = data[2].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 1; i < data8.Length; i++)
            {
                string[] data9  = data8[i].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                string[] data10 = data9[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                Entity   entity = DatabaseManager.CreateEntity(GameManager.Project, data9[0], true);
                entity.FindComponent <ComponentBody>(true).Position       = new Vector3(float.Parse(data10[0]) + End.X, float.Parse(data10[1]) + End.Y, float.Parse(data10[2]) + End.Z);
                entity.FindComponent <ComponentBody>(true).Rotation       = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.2f);
                entity.FindComponent <ComponentSpawn>(true).SpawnDuration = 0.25f;
                ComponentInventoryBase inventoryBase = entity.FindComponent <ComponentInventoryBase>();
                if (inventoryBase != null)
                {
                    for (int j = 2, s = 0; j < data9.Length; j++, s++)
                    {
                        string[] data11 = data9[j].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        inventoryBase.AddSlotItems(s, int.Parse(data11[0]), int.Parse(data11[1]));
                    }
                }
                GameManager.Project.AddEntity(entity);
            }
            creatorAPI.componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage($"粘贴成功,共{num}个方块", true, true);
        }
예제 #12
0
        public void FillingBlock(bool limit = false)
        {
            Point3 Start = creatorAPI.Position[0];
            Point3 End   = creatorAPI.Position[1];

            CreatorMain.Math.StartEnd(ref Start, ref End);
            int bort;

            if (this.creatorType == CreatorMain.CreatorType.X)
            {
                bort    = Start.X;
                Start.X = Start.Y;
                Start.Y = bort;
                bort    = End.X;
                End.X   = End.Y;
                End.Y   = bort;
            }
            else if (this.creatorType == CreatorMain.CreatorType.Z)
            {
                bort    = Start.Z;
                Start.Z = Start.Y;
                Start.Y = bort;
                bort    = End.Z;
                End.Z   = End.Y;
                End.Y   = bort;
            }
            Task.Run(delegate
            {
                int num               = 0;
                ChunkData chunkData   = new ChunkData(this.creatorAPI);
                creatorAPI.revokeData = new ChunkData(this.creatorAPI);
                for (int x = End.X; x <= Start.X; x++)
                {
                    for (int z = End.Z; z <= Start.Z; z++)
                    {
                        bool b = false;
                        bool c = false;
                        for (int y = End.Y; y <= Start.Y; y++)
                        {
                            if (!creatorAPI.launch)
                            {
                                return;
                            }
                            int _y;
                            if (this.creatorType != CreatorMain.CreatorType.Y)
                            {
                                if (!typeBool)
                                {
                                    _y = Start.Y + End.Y - y;
                                }
                                else
                                {
                                    _y = y;
                                }
                            }
                            else
                            {
                                if (!this.typeBool)
                                {
                                    _y = y;
                                }
                                else
                                {
                                    _y = Start.Y + End.Y - y;
                                }
                            }
                            int id;
                            if (this.creatorType == CreatorMain.CreatorType.X)
                            {
                                id = this.subsystemTerrain.Terrain.GetCellValueFast(_y, x, z);
                            }
                            else if (this.creatorType == CreatorMain.CreatorType.Y)
                            {
                                id = this.subsystemTerrain.Terrain.GetCellValueFast(x, _y, z);
                            }
                            else
                            {
                                id = this.subsystemTerrain.Terrain.GetCellValueFast(x, z, _y);
                            }
                            int blockID = Terrain.ExtractContents(id);
                            if (c && limit && blockID != 0)
                            {
                                break;
                            }
                            if (!b && blockID != 0)
                            {
                                b = true;
                            }
                            else if (b && blockID == 0)
                            {
                                c = true;
                                if (this.creatorType == CreatorMain.CreatorType.X)
                                {
                                    this.creatorAPI.CreateBlock(_y, x, z, this.blockIconWidget.Value, chunkData);
                                    num++;
                                }
                                else if (this.creatorType == CreatorMain.CreatorType.Y)
                                {
                                    this.creatorAPI.CreateBlock(x, _y, z, this.blockIconWidget.Value, chunkData);
                                    num++;
                                }
                                else
                                {
                                    this.creatorAPI.CreateBlock(x, z, _y, this.blockIconWidget.Value, chunkData);
                                    num++;
                                }
                            }
                        }
                    }
                }
                chunkData.Render();
                this.player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
            });
        }