Exemplo n.º 1
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer Player)
        {
/*            Run();*/
            if (Player.ComponentGui.ModalPanelWidget is CreatorWidget)
            {
                Player.ComponentGui.ModalPanelWidget = null;
            }
            else
            {
                CreatorAPI creatorAPI;
                if (!dictionaryPlayers.TryGetValue(Player, out creatorAPI))
                {
                    listPlayer.Add(Player);
                    creatorAPI = new CreatorAPI(Player.ComponentMiner);
                    dictionaryPlayers.Add(Player, creatorAPI);
                }
                if (CreatorMain.canUse)
                {
                    Player.ComponentGui.ModalPanelWidget = new CreatorWidget(creatorAPI);
                }
                else
                {
                    DialogsManager.ShowDialog(Player.View.GameWidget, new PasswordDialog(Player));
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建一键生成文件
        /// </summary>
        /// <param name="creatorAPI"></param>
        /// <param name="directory"></param>
        /// <param name="path"></param>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        /// <param name="position"></param>
        public static void CreateOnekey(CreatorAPI creatorAPI, string directory, string path, Point3 Start, Point3 End, Point3 position)
        {
            int count = 0;

            CreatorMain.Math.StartEnd(ref Start, ref End);
            FileStream         fileStream   = new FileStream(directory + "/" + path, FileMode.Create);
            EngineBinaryWriter binaryWriter = new EngineBinaryWriter(fileStream, true);

            binaryWriter.Write(End.X - position.X);
            binaryWriter.Write(End.Y - position.Y);
            binaryWriter.Write(End.Z - position.Z);
            binaryWriter.Write(Start.X - position.X);
            binaryWriter.Write(Start.Y - position.Y);
            binaryWriter.Write(Start.Z - position.Z);
            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++)
                    {
                        binaryWriter.Write(GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellValueFast(x, y, z));
                        count++;
                    }
                }
            }
            binaryWriter.Dispose();
            fileStream.Dispose();
            creatorAPI.componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage($"创建一键生成成功,共{count}个方块", true, true);
        }
Exemplo n.º 3
0
 public CylindricalDialog(CreatorAPI creatorAPI) : base(creatorAPI)
 {
     this.Children.Find <LabelWidget>("名称", true).Text = "圆柱";
     this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = true;
     this.ZRadius            = this.Children.Find <SliderWidget>("滑条3", true);
     this.zRadiusLabelWidget = this.Children.Find <LabelWidget>("滑条3数据", true);
 }
Exemplo n.º 4
0
        public SetModeDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/模式设置");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.CreativeButton    = Children.Find <ButtonWidget>("创造模式", true);
            this.ChallengingButton = Children.Find <ButtonWidget>("挑战模式", true);
            this.HarmlessButton    = Children.Find <ButtonWidget>("无害模式", true);
            this.AdventureButton   = Children.Find <ButtonWidget>("闯关模式", true);
            this.CruelButton       = Children.Find <ButtonWidget>("残酷模式", true);
            this.cancelButton      = Children.Find <ButtonWidget>("取消", true);
            gameInfo = player.Project.FindSubsystem <SubsystemGameInfo>(true);
            if (gameInfo.WorldSettings.GameMode == GameMode.Creative)
            {
                CreativeButton.IsEnabled = false;
            }
            else if (gameInfo.WorldSettings.GameMode == GameMode.Challenging)
            {
                ChallengingButton.IsEnabled = false;
            }
            else if (gameInfo.WorldSettings.GameMode == GameMode.Harmless)
            {
                HarmlessButton.IsEnabled = false;
            }
            else if (gameInfo.WorldSettings.GameMode == GameMode.Adventure)
            {
                AdventureButton.IsEnabled = false;
            }
            else if (gameInfo.WorldSettings.GameMode == GameMode.Cruel)
            {
                CruelButton.IsEnabled = false;
            }
        }
Exemplo n.º 5
0
 public SpiralDialog(CreatorAPI creatorAPI) : base(creatorAPI)
 {
     this.Children.Find <LabelWidget>("名称", true).Text = "螺旋";
     this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = true;
     this.Number                 = this.Children.Find <SliderWidget>("滑条3", true);
     this.numberLabelWidget      = this.Children.Find <LabelWidget>("滑条3数据", true);
     this.SoildButton.Text       = "确定";
     this.HollowButton.IsVisible = false;
 }
Exemplo n.º 6
0
        public FillingDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/填充界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            base.setShaftXYZ();
            Y_Shaft.Text        = "正Y轴";
            this.pillingButton  = this.Children.Find <ButtonWidget>("填充", true);
            this.pilling2Button = this.Children.Find <ButtonWidget>("填充2", true);
        }
Exemplo n.º 7
0
        public TwoPointLineDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/通用界面3");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            this.Children.Find <LabelWidget>("名称", true).Text = "2点连线";
            this.OKButton = this.Children.Find <ButtonWidget>("确定", true);
        }
Exemplo n.º 8
0
        public PavageDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/平铺界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.OKButton     = Children.Find <ButtonWidget>("确定", true);
            this.cancelButton = Children.Find <ButtonWidget>("取消", true);
            this.TextBox      = Children.Find <TextBoxWidget>("方块ID", true);
            this.slider       = Children.Find <SliderWidget>("滑条1", true);
        }
Exemplo n.º 9
0
        public RectangularDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/矩形界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            this.SoildButton     = this.Children.Find <ButtonWidget>("实心", true);
            this.HollowButton    = this.Children.Find <ButtonWidget>("空心", true);
            this.FrameworkButton = this.Children.Find <ButtonWidget>("框架", true);
        }
Exemplo n.º 10
0
        public TransferDialog(CreatorAPI creatorAPI)
        {
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/传送设置");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.cancelButton = Children.Find <ButtonWidget>("取消", true);
            this.Transfer     = Children.Find <ButtonWidget>("传送", true);
            this.X            = Children.Find <TextBoxWidget>("X", true);
            this.Y            = Children.Find <TextBoxWidget>("Y", true);
            this.Z            = Children.Find <TextBoxWidget>("Z", true);
        }
Exemplo n.º 11
0
        public ReplaceDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/替换界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.cancelButton        = Children.Find <ButtonWidget>("取消", true);
            this.replaceButton       = Children.Find <ButtonWidget>("替换", true);
            this.retainReplaceButton = Children.Find <ButtonWidget>("保留替换");
            this.roughReplaceButton  = Children.Find <ButtonWidget>("粗糙替换");
            this.Blockid             = Children.Find <TextBoxWidget>("方块ID", true);
            this.Blockid2            = Children.Find <TextBoxWidget>("方块ID2", true);
        }
Exemplo n.º 12
0
        public EditWorldDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/编辑世界");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.worldSettings                    = player.Project.FindSubsystem <SubsystemGameInfo>(true).WorldSettings;
            this.OKButton                         = Children.Find <ButtonWidget>("确定");
            this.UpdataWorldButton                = Children.Find <ButtonWidget>("重载");
            this.UpdataButton                     = Children.Find <ButtonWidget>("刷新");
            this.paletteButton                    = this.Children.Find <ButtonWidget>("Palette", true);
            this.blocksTextureIcon                = this.Children.Find <RectangleWidget>("BlocksTextureIcon", true);
            this.blocksTextureLabel               = this.Children.Find <LabelWidget>("BlocksTextureLabel", true);
            this.blocksTextureDetails             = this.Children.Find <LabelWidget>("BlocksTextureDetails", true);
            this.blocksTextureButton              = this.Children.Find <ButtonWidget>("BlocksTextureButton", true);
            this.supernaturalCreaturesButton      = this.Children.Find <ButtonWidget>("SupernaturalCreatures", true);
            this.environmentBehaviorButton        = this.Children.Find <ButtonWidget>("EnvironmentBehavior", true);
            this.timeOfDayButton                  = this.Children.Find <ButtonWidget>("TimeOfDay", true);
            this.weatherEffectsButton             = this.Children.Find <ButtonWidget>("WeatherEffects", true);
            this.adventureRespawnButton           = this.Children.Find <ButtonWidget>("AdventureRespawn", true);
            this.adventureSurvivalMechanicsButton = this.Children.Find <ButtonWidget>("AdventureSurvivalMechanics", true);
            this.terrainGenerationLabel           = this.Children.Find <LabelWidget>("TerrainGenerationLabel", true);
            this.terrainGenerationButton          = this.Children.Find <ButtonWidget>("TerrainGeneration", true);
            this.seaLevelOffsetSlider             = this.Children.Find <SliderWidget>("SeaLevelOffset", true);
            this.temperatureOffsetSlider          = this.Children.Find <SliderWidget>("TemperatureOffset", true);
            this.humidityOffsetSlider             = this.Children.Find <SliderWidget>("HumidityOffset", true);
            this.biomeSizeSlider                  = this.Children.Find <SliderWidget>("BiomeSize", true);
            this.islandTerrainPanel               = this.Children.Find <Widget>("IslandTerrainPanel", true);
            this.islandSizeNS                     = this.Children.Find <SliderWidget>("IslandSizeNS", true);
            this.islandSizeEW                     = this.Children.Find <SliderWidget>("IslandSizeEW", true);
            this.flatTerrainPanel                 = this.Children.Find <Widget>("FlatTerrainPanel", true);
            this.continentTerrainPanel            = this.Children.Find <Widget>("ContinentTerrainPanel", true);
            this.flatTerrainLevelSlider           = this.Children.Find <SliderWidget>("FlatTerrainLevel", true);
            this.flatTerrainBlock                 = this.Children.Find <BlockIconWidget>("FlatTerrainBlock", true);
            this.flatTerrainBlockLabel            = this.Children.Find <LabelWidget>("FlatTerrainBlockLabel", true);
            this.flatTerrainBlockButton           = this.Children.Find <ButtonWidget>("FlatTerrainBlockButton", true);
            this.flatTerrainMagmaOceanCheckbox    = this.Children.Find <CheckboxWidget>("MagmaOcean", true);

            this.islandSizeEW.MinValue       = 0f;
            this.islandSizeEW.MaxValue       = (float)(this.islandSizes.Length - 1);
            this.islandSizeEW.Granularity    = 1f;
            this.islandSizeNS.MinValue       = 0f;
            this.islandSizeNS.MaxValue       = (float)(this.islandSizes.Length - 1);
            this.islandSizeNS.Granularity    = 1f;
            this.biomeSizeSlider.MinValue    = 0f;
            this.biomeSizeSlider.MaxValue    = (float)(this.biomeSizes.Length - 1);
            this.biomeSizeSlider.Granularity = 1f;
        }
Exemplo n.º 13
0
        public EditRegionDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = creatorAPI.componentMiner.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/编辑区域");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.SliderData        = this.Children.Find <LabelWidget>("滑条数据", true);
            this.TemperatureSlider = this.Children.Find <SliderWidget>("滑条1", true);
            this.HumiditySlider    = this.Children.Find <SliderWidget>("滑条2", true);
            this.TopHeightSlider   = this.Children.Find <SliderWidget>("滑条3", true);
            this.OKButton          = this.Children.Find <ButtonWidget>("确定", true);
            this.cancelButton      = this.Children.Find <ButtonWidget>("取消");
        }
Exemplo n.º 14
0
        public LevelSetDialog(CreatorAPI creatorAPI)
        {
            this.player = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/等级设置");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.Radius       = Children.Find <SliderWidget>("等级", true);
            this.plusButton   = Children.Find <ButtonWidget>("增加按钮", true);
            this.minusButton  = Children.Find <ButtonWidget>("减少按钮", true);
            this.delayLabel   = Children.Find <LabelWidget>("滑条", true);
            this.OK           = Children.Find <ButtonWidget>("确定", true);
            this.Cancel       = Children.Find <ButtonWidget>("取消", true);
            this.Radius.Value = player.PlayerData.Level;
            this.UpdateControls();
        }
Exemplo n.º 15
0
        public PyramidDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/棱体棱锥界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            this.Children.Find <StackPanelWidget>("XYZ", true).IsVisible = false;
            this.Children.Find <LabelWidget>("名称", true).Text            = "棱锥";
            this.Radius       = this.Children.Find <SliderWidget>("滑条", true);
            this.delayLabel   = this.Children.Find <LabelWidget>("滑条数据", true);
            this.SoildButton  = this.Children.Find <ButtonWidget>("实心", true);
            this.HollowButton = this.Children.Find <ButtonWidget>("空心", true);
        }
Exemplo n.º 16
0
        public PillarsDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/柱子界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            base.setShaftXYZ();
            Y_Shaft.Text = "正Y轴";
            this.Children.Find <LabelWidget>("名称", true).Text = "柱子";
            this.Radius           = this.Children.Find <SliderWidget>("滑条1", true);
            this.radiusDelayLabel = this.Children.Find <LabelWidget>("滑条1数据", true);
            this.Height           = this.Children.Find <SliderWidget>("滑条2", true);
            this.heightDelayLabel = this.Children.Find <LabelWidget>("滑条2数据", true);
            this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = false;
            this.SoildButton  = this.Children.Find <ButtonWidget>("实心", true);
            this.HollowButton = this.Children.Find <ButtonWidget>("空心", true);
        }
Exemplo n.º 17
0
        public ModDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Widget/模组界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.OK = Children.Find <ButtonWidget>("确定", true);
            this.ExportOnekeyButton    = Children.Find <ButtonWidget>("导出一键", true);
            this.ImportButton          = Children.Find <ButtonWidget>("导入配置", true);
            this.ExportCopyButton      = Children.Find <ButtonWidget>("导出复制", true);
            this.ExportOldCopyButton   = Children.Find <ButtonWidget>("导出旧复制", true);
            this.ExportOldOnekeyButton = Children.Find <ButtonWidget>("导出旧一键", true);
            this.DerivedSpecialButton  = Children.Find <ButtonWidget>("导出特殊", true);
            this.DeleteButton          = Children.Find <ButtonWidget>("删除", true);
            this.ListView = Children.Find <ListPanelWidget>("ListView", true);
            UpList();
        }
Exemplo n.º 18
0
        public override bool OnUse(Vector3 start, Vector3 direction, ComponentMiner componentMiner)
        {
            TerrainRaycastResult?terrainRaycastResult = componentMiner.PickTerrainForDigging(start, direction);
            ComponentPlayer      Player = componentMiner.ComponentPlayer;

            if (terrainRaycastResult.HasValue)
            {
                CreatorAPI creatorAPI;
                if (!dictionaryPlayers.TryGetValue(Player, out creatorAPI))
                {
                    listPlayer.Add(Player);
                    creatorAPI = new CreatorAPI(componentMiner);
                    dictionaryPlayers.Add(Player, creatorAPI);
                }
                creatorAPI.OnUse((TerrainRaycastResult)terrainRaycastResult);
            }
            return(base.OnUse(start, direction, componentMiner));
        }
Exemplo n.º 19
0
        public OnekeyGenerationDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/一键界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.CreateButton   = Children.Find <ButtonWidget>("创建", true);
            this.OnAndOffButton = Children.Find <ButtonWidget>("开启", true);
            this.DerivedButton  = Children.Find <ButtonWidget>("导出", true);
            this.ImportButton   = Children.Find <ButtonWidget>("导入", true);
            this.DeleteButton   = Children.Find <ButtonWidget>("删除", true);
            this.OKButton       = Children.Find <ButtonWidget>("确定", true);
            this.ListView       = Children.Find <ListPanelWidget>("ListView", true);
            this.TypeButton     = Children.Find <ButtonWidget>("类型", true);
            UpList();
        }
Exemplo n.º 20
0
        public SphereDialog(CreatorAPI creatorAPI) : base(creatorAPI)
        {
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/球体界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            base.GeneralSet();
            this.XRadius              = this.Children.Find <SliderWidget>("X半径滑条", true);
            this.YRadius              = this.Children.Find <SliderWidget>("Y半径滑条", true);
            this.ZRadius              = this.Children.Find <SliderWidget>("Z半径滑条", true);
            this.XdelayLabel          = this.Children.Find <LabelWidget>("X半径", true);
            this.YdelayLabel          = this.Children.Find <LabelWidget>("Y半径", true);
            this.ZdelayLabel          = this.Children.Find <LabelWidget>("Z半径", true);
            this.SoildButton          = this.Children.Find <ButtonWidget>("实心", true);
            this.HollowButton         = this.Children.Find <ButtonWidget>("空心", true);
            this.AdvancedButton       = this.Children.Find <ButtonWidget>("高级");
            this.AdvancedGenerate     = this.Children.Find <Widget>("高级生成");
            this.DoublePositionButton = this.Children.Find <ButtonWidget>("2点模式");
        }
Exemplo n.º 21
0
        public SetDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI       = creatorAPI;
            this.player           = creatorAPI.componentMiner.ComponentPlayer;
            this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/设置界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.OK                  = Children.Find <ButtonWidget>("确定", true);
            this.generatingMod       = Children.Find <ButtonWidget>("生成模式", true);
            this.resettingButton     = Children.Find <ButtonWidget>("重置", true);
            this.generatingSet       = Children.Find <ButtonWidget>("生成开关", true);
            this.SetPositionMode     = Children.Find <ButtonWidget>("设点模式");
            this.unLimited           = Children.Find <ButtonWidget>("超距生成");
            this.AirIdentifyButton   = Children.Find <ButtonWidget>("空气识别");
            this.RevokeButton        = Children.Find <ButtonWidget>("撤回开关");
            this.professionButton    = Children.Find <ButtonWidget>("专业模式");
            this.setMainWidgetButton = this.Children.Find <ButtonWidget>("旧主界面");
        }
Exemplo n.º 22
0
        public MountainDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/山脉界面");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.OK           = Children.Find <ButtonWidget>("确定", true);
            this.cancelButton = Children.Find <ButtonWidget>("取消", true);
            this.num_1        = Children.Find <LabelWidget>("滑条1数据", true);
            this.num_2        = Children.Find <LabelWidget>("滑条2数据", true);
            this.num_3        = Children.Find <LabelWidget>("滑条3数据", true);
            this.TextBox      = Children.Find <TextBoxWidget>("方块ID", true);
            this.num1         = Children.Find <SliderWidget>("滑条1", true);
            this.num2         = Children.Find <SliderWidget>("滑条2", true);
            this.num3         = Children.Find <SliderWidget>("滑条3", true);
            num3.Value        = 100f;
            this.restting     = Children.Find <ButtonWidget>("重置", true);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
        public CopyPasteDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/复制粘贴");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.CopyButton         = Children.Find <ButtonWidget>("复制", true);
            this.DerivedButton      = Children.Find <ButtonWidget>("导出", true);
            this.ImportButton       = Children.Find <ButtonWidget>("导入", true);
            this.DeleteButton       = Children.Find <ButtonWidget>("删除", true);
            this.cancelButton       = Children.Find <ButtonWidget>("取消", true);
            this.PasteButton        = Children.Find <ButtonWidget>("粘贴", true);
            this.MirrorButton       = Children.Find <ButtonWidget>("镜像", true);
            this.LimitButton        = Children.Find <ButtonWidget>("限制", true);
            this.DirectionSetButton = Children.Find <ButtonWidget>("旋转", true);
            this.specialCopyButton  = Children.Find <ButtonWidget>("特殊复制", true);
            this.specialPasteButton = Children.Find <ButtonWidget>("特殊粘贴", true);
            if (creatorAPI.pasteLimit)
            {
                LimitButton.Color = Color.Yellow;
            }
            else
            {
                LimitButton.Color = Color.Red;
            }
            if (creatorAPI.pasteRotate)
            {
                DirectionSetButton.Color = Color.Yellow;
            }
            else
            {
                DirectionSetButton.Color = Color.Red;
            }
            this.ListView = Children.Find <ListPanelWidget>("ListView", true);
            UpList();
        }
Exemplo n.º 25
0
 public CircleDialog(CreatorAPI creatorAPI) : base(creatorAPI)
 {
     this.Children.Find <LabelWidget>("名称", true).Text = "圆环";
     Y_Shaft.Text = "Y轴";
 }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
 public InterfaceDialog(CreatorAPI creatorAPI)
 {
     this.creatorAPI       = creatorAPI;
     this.player           = creatorAPI.componentMiner.ComponentPlayer;
     this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
 }
Exemplo n.º 29
0
        public static bool Touch(CreatorAPI creatorAPI, Point3 position)
        {
            ComponentPlayer player    = creatorAPI.componentMiner.ComponentPlayer;
            int             cellValue = GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellValue(position.X, position.Y, position.Z);



/*            if (creatorAPI.twoPointsOfAttachment && creatorAPI.numberPoint == CreatorAPI.NumberPoint.Two)
 *          {
 *              Task.Run(delegate
 *              {
 *                  ChunkData chunkData = new ChunkData(creatorAPI);
 *                  creatorAPI.revokeData = new ChunkData(creatorAPI);
 *                  int num = 0;
 *                  foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.TwoPointLineGeneration2(creatorAPI.Position[0], creatorAPI.Position[1]))
 *                  {
 *                      creatorAPI.CreateBlock(point3, cellValue,chunkData);
 *                      num++;
 *                  }
 *                  chunkData.Render();
 *                  player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
 *              });
 *          }
 */

            if (creatorAPI.oneKeyGeneration)
            {
                if (creatorAPI.onekeyType == CreatorAPI.OnekeyType.Build)
                {
                    if (File.Exists(CreatorMain.OneKeyFile))
                    {
                        Task.Run(delegate
                        {
                            OnekeyGeneration.GenerationData(creatorAPI, CreatorMain.OneKeyFile, position);
                        });
                    }
                    else
                    {
                        player.ComponentGui.DisplaySmallMessage($"未发现一键生成缓存文件,目录:{CreatorMain.OneKeyFile}\n请变更一键生成类型或关闭该功能", true, true);
                    }
                }
                else
                {
                }
                return(false);
            }

            if (creatorAPI.ClearBlock)
            {
                Task.Run(delegate
                {
                    creatorAPI.revokeData = new ChunkData(creatorAPI);
                    int num = 0;
                    List <Point3> clearBlockList = new List <Point3>();
                    List <Point3> addList        = new List <Point3>();
                    clearBlockList.Add(position);
                    while (true)
                    {
                        if (clearBlockList.Count <= 0)
                        {
                            break;
                        }
                        foreach (Point3 point3 in clearBlockList)
                        {
                            if (!creatorAPI.launch)
                            {
                                return;
                            }
                            if (creatorAPI.revokeData != null && creatorAPI.revokeData.GetChunk(point3.X, point3.Z) == null)
                            {
                                creatorAPI.revokeData.CreateChunk(point3.X, point3.Z, true);
                            }
                            creatorAPI.SetBlock(point3.X, point3.Y, point3.Z, 0);
                            num++;
                            for (int x = -1; x <= 1; x++)
                            {
                                for (int y = -1; y <= 1; y++)
                                {
                                    for (int z = -1; z <= 1; z++)
                                    {
                                        if (point3.Y + y > 127)
                                        {
                                            continue;
                                        }
                                        int blockID = GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellContentsFast(point3.X + x, point3.Y + y, point3.Z + z);
                                        if (blockID == 0 || blockID == 1)
                                        {
                                            continue;
                                        }
                                        if (MathUtils.Abs(x) + MathUtils.Abs(y) + MathUtils.Abs(z) > 1)
                                        {
                                            continue;
                                        }
                                        Point3 p = new Point3(point3.X + x, point3.Y + y, point3.Z + z);
                                        if (!clearBlockList.Contains(p) && !addList.Contains(p))
                                        {
                                            addList.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                        clearBlockList = addList;
                        addList        = new List <Point3>();
                    }
                    player.ComponentGui.DisplaySmallMessage($"操作成功,共清除{num}个方块", true, true);
                });
                return(false);
            }
            return(true);
        }
Exemplo n.º 30
0
 public PrismColumnDialog(CreatorAPI creatorAPI) : base(creatorAPI)
 {
     this.Children.Find <LabelWidget>("名称", true).Text = "棱柱";
 }