Exemplo n.º 1
0
        public override void Update()
        {
            if (this.UpdataButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
                SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>();
                foreach (TerrainChunk terrainChunk in subsystemTerrain.Terrain.AllocatedChunks)
                {
                    foreach (SubsystemBlockBehavior subsystemBlockBehavior in GameManager.Project.FindSubsystem <SubsystemBlockBehaviors>().BlockBehaviors)
                    {
                        subsystemBlockBehavior.OnChunkDiscarding(terrainChunk);
                    }
                    int chunkX = terrainChunk.Coords.X;
                    int chunkY = terrainChunk.Coords.Y;
                    subsystemTerrain.Dispose();
                    subsystemTerrain.Load(new ValuesDictionary());
                    player.ComponentGui.DisplaySmallMessage("刷新完成!", true, false);
                }
            }
            if (this.OKButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            if (this.UpdataWorldButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
                WorldInfo world = GameManager.WorldInfo;
                GameManager.SaveProject(true, true);
                GameManager.DisposeProject();
                object[] expr_E9 = new object[2];
                expr_E9[0] = world;
                ScreensManager.SwitchScreen("GameLoading", expr_E9);
            }
            if (this.paletteButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new CreatorModAPIEditPaletteDialog(worldSettings.Palette));
            }

            Texture2D texture = this.blockTexturesCache.GetTexture(this.worldSettings.BlocksTextureName);

            this.blocksTextureIcon.Subtexture = new Subtexture(texture, Vector2.Zero, Vector2.One);
            this.blocksTextureLabel.Text      = BlocksTexturesManager.GetDisplayName(this.worldSettings.BlocksTextureName);
            this.blocksTextureDetails.Text    = string.Format("{0}x{1}", texture.Width, texture.Height);
            if (this.blocksTextureButton.IsClicked)
            {
                BlocksTexturesManager.UpdateBlocksTexturesList();
                ListSelectionDialog dialog = new ListSelectionDialog("Select Blocks Texture", BlocksTexturesManager.BlockTexturesNames, 64f, delegate(object item)
                {
                    XElement node = ContentManager.Get <XElement>("Widgets/BlocksTextureItem");
                    ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(this, node, null);
                    Texture2D texture2 = this.blockTexturesCache.GetTexture((string)item);
                    containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Text", true).Text           = BlocksTexturesManager.GetDisplayName((string)item);
                    containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Details", true).Text        = string.Format("{0}x{1}", texture2.Width, texture2.Height);
                    containerWidget.Children.Find <RectangleWidget>("BlocksTextureItem.Icon", true).Subtexture = new Subtexture(texture2, Vector2.Zero, Vector2.One);
                    return(containerWidget);
                }, delegate(object item)
                {
                    this.worldSettings.BlocksTextureName          = (string)item;
                    SubsystemBlocksTexture subsystemBlocksTexture = GameManager.Project.FindSubsystem <SubsystemBlocksTexture>();
                    subsystemBlocksTexture.Dispose();
                    subsystemBlocksTexture.Load(new ValuesDictionary());
                });
                DialogsManager.ShowDialog(null, dialog);
            }
            if (this.supernaturalCreaturesButton.IsClicked)
            {
                this.worldSettings.AreSupernaturalCreaturesEnabled = !this.worldSettings.AreSupernaturalCreaturesEnabled;
            }
            if (this.environmentBehaviorButton.IsClicked)
            {
                IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(EnvironmentBehaviorMode));
                this.worldSettings.EnvironmentBehaviorMode = (EnvironmentBehaviorMode)((enumValues2.IndexOf((int)this.worldSettings.EnvironmentBehaviorMode) + 1) % enumValues2.Count);
            }
            if (this.timeOfDayButton.IsClicked)
            {
                IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(TimeOfDayMode));
                this.worldSettings.TimeOfDayMode = (TimeOfDayMode)((enumValues3.IndexOf((int)this.worldSettings.TimeOfDayMode) + 1) % enumValues3.Count);
            }
            if (this.weatherEffectsButton.IsClicked)
            {
                this.worldSettings.AreWeatherEffectsEnabled = !this.worldSettings.AreWeatherEffectsEnabled;
            }
            if (this.adventureRespawnButton.IsClicked)
            {
                this.worldSettings.IsAdventureRespawnAllowed = !this.worldSettings.IsAdventureRespawnAllowed;
            }
            if (this.adventureSurvivalMechanicsButton.IsClicked)
            {
                this.worldSettings.AreAdventureSurvivalMechanicsEnabled = !this.worldSettings.AreAdventureSurvivalMechanicsEnabled;
            }
            if (this.terrainGenerationButton.IsClicked)
            {
                IList <int> enumValues = EnumUtils.GetEnumValues(typeof(TerrainGenerationMode));
                DialogsManager.ShowDialog(null, new ListSelectionDialog("Select World Type", enumValues, 56f, (object e) => ((TerrainGenerationMode)e).ToString(), delegate(object e)
                {
                    this.worldSettings.TerrainGenerationMode = (TerrainGenerationMode)e;
                    SubsystemTerrain subsystemTerrain        = GameManager.Project.FindSubsystem <SubsystemTerrain>();
                    if ((TerrainGenerationMode)e == TerrainGenerationMode.Flat)
                    {
                        subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGeneratorFlat(subsystemTerrain);
                    }
                    else
                    {
                        subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGenerator(subsystemTerrain);
                    }
                }));
            }
            if (this.seaLevelOffsetSlider.IsSliding)
            {
                this.worldSettings.SeaLevelOffset = (int)this.seaLevelOffsetSlider.Value;
            }
            if (this.temperatureOffsetSlider.IsSliding)
            {
                this.worldSettings.TemperatureOffset = this.temperatureOffsetSlider.Value;
            }
            if (this.humidityOffsetSlider.IsSliding)
            {
                this.worldSettings.HumidityOffset = this.humidityOffsetSlider.Value;
            }
            if (this.biomeSizeSlider.IsSliding)
            {
                this.worldSettings.BiomeSize = this.biomeSizes[MathUtils.Clamp((int)this.biomeSizeSlider.Value, 0, this.biomeSizes.Length - 1)];
            }
            if (this.islandSizeEW.IsSliding)
            {
                this.worldSettings.IslandSize.X = this.islandSizes[MathUtils.Clamp((int)this.islandSizeEW.Value, 0, this.islandSizes.Length - 1)];
            }
            if (this.islandSizeNS.IsSliding)
            {
                this.worldSettings.IslandSize.Y = this.islandSizes[MathUtils.Clamp((int)this.islandSizeNS.Value, 0, this.islandSizes.Length - 1)];
            }
            if (this.flatTerrainLevelSlider.IsSliding)
            {
                this.worldSettings.TerrainLevel = (int)this.flatTerrainLevelSlider.Value;
            }
            if (this.flatTerrainBlockButton.IsClicked)
            {
                int[] items = new int[]
                {
                    8,
                    2,
                    7,
                    3,
                    67,
                    66,
                    4,
                    5,
                    26,
                    73,
                    21,
                    46,
                    47,
                    15,
                    62,
                    68,
                    126,
                    71,
                    1
                };
                DialogsManager.ShowDialog(null, new ListSelectionDialog("Select Block", items, 72f, delegate(object index)
                {
                    XElement node = ContentManager.Get <XElement>("Widgets/SelectBlockItem");
                    ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(null, node, null);
                    containerWidget.Children.Find <BlockIconWidget>("SelectBlockItem.Block", true).Contents = (int)index;
                    containerWidget.Children.Find <LabelWidget>("SelectBlockItem.Text", true).Text          = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index));
                    return(containerWidget);
                }, delegate(object index)
                {
                    this.worldSettings.TerrainBlockIndex = (int)index;
                }));
            }
            if (this.flatTerrainMagmaOceanCheckbox.IsClicked)
            {
                this.worldSettings.TerrainOceanBlockIndex = ((this.worldSettings.TerrainOceanBlockIndex == 18) ? 92 : 18);
            }
            this.islandTerrainPanel.IsVisible            = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Island);
            this.flatTerrainPanel.IsVisible              = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Flat);
            this.continentTerrainPanel.IsVisible         = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Continent);
            this.flatTerrainLevelSlider.Value            = (float)this.worldSettings.TerrainLevel;
            this.flatTerrainLevelSlider.Text             = this.worldSettings.TerrainLevel.ToString();
            this.flatTerrainBlock.Contents               = this.worldSettings.TerrainBlockIndex;
            this.flatTerrainMagmaOceanCheckbox.IsChecked = (this.worldSettings.TerrainOceanBlockIndex == 92);
            this.seaLevelOffsetSlider.Value              = (float)this.worldSettings.SeaLevelOffset;
            this.seaLevelOffsetSlider.Text               = WorldOptionsScreen.FormatOffset((float)this.worldSettings.SeaLevelOffset);
            this.temperatureOffsetSlider.Value           = this.worldSettings.TemperatureOffset;
            this.temperatureOffsetSlider.Text            = WorldOptionsScreen.FormatOffset(this.worldSettings.TemperatureOffset);
            this.humidityOffsetSlider.Value              = this.worldSettings.HumidityOffset;
            this.humidityOffsetSlider.Text               = WorldOptionsScreen.FormatOffset(this.worldSettings.HumidityOffset);
            this.biomeSizeSlider.Value                 = (float)FindNearestIndex(this.biomeSizes, this.worldSettings.BiomeSize);
            this.biomeSizeSlider.Text                  = this.worldSettings.BiomeSize.ToString() + "x";
            this.islandSizeEW.Value                    = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.X);
            this.islandSizeEW.Text                     = this.worldSettings.IslandSize.X.ToString();
            this.islandSizeNS.Value                    = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.Y);
            this.islandSizeNS.Text                     = this.worldSettings.IslandSize.Y.ToString();
            this.supernaturalCreaturesButton.Text      = (this.worldSettings.AreSupernaturalCreaturesEnabled ? "Enabled" : "Disabled");
            this.environmentBehaviorButton.Text        = this.worldSettings.EnvironmentBehaviorMode.ToString();
            this.timeOfDayButton.Text                  = this.worldSettings.TimeOfDayMode.ToString();
            this.weatherEffectsButton.Text             = (this.worldSettings.AreWeatherEffectsEnabled ? "Enabled" : "Disabled");
            this.adventureRespawnButton.Text           = (this.worldSettings.IsAdventureRespawnAllowed ? "Allowed" : "Not Allowed");
            this.adventureSurvivalMechanicsButton.Text = (this.worldSettings.AreAdventureSurvivalMechanicsEnabled ? "Enabled" : "Disabled");
            this.terrainGenerationLabel.Text           = this.worldSettings.TerrainGenerationMode.ToString();
        }
Exemplo n.º 2
0
        public override void Update()
        {
            if (this.SphereButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new SphereDialog(creatorAPI));
            }
            if (this.PrismButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new PrismDialog(creatorAPI));
            }
            if (this.PyramidButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new PyramidDialog(creatorAPI));
            }
            if (this.CylindricalButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new CylindricalDialog(creatorAPI));
            }
            if (this.PrismColumnButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new PrismColumnDialog(creatorAPI));
            }
            if (this.PillarsButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new PillarsDialog(creatorAPI));
            }
            if (this.RectangularButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new RectangularDialog(creatorAPI));
            }
            if (this.CircleButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new CircleDialog(creatorAPI));
            }
            if (this.MazeButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new MazeDialog(creatorAPI));
            }
            if (this.PavageButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new PavageDialog(creatorAPI));
            }
            if (this.FillingButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new FillingDialog(creatorAPI));
            }
            if (this.MountainButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new MountainDialog(creatorAPI));
            }
            if (this.TransferButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new TransferDialog(creatorAPI));
            }
            if (this.LevelSetButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new LevelSetDialog(creatorAPI));
            }
            if (this.SetButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new SetDialog(creatorAPI));
            }
            if (this.SpiralButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new SpiralDialog(creatorAPI));
            }
            if (this.PenetrateButton.IsClicked)
            {
                if (CreatorMain.Penetrate)
                {
                    foreach (int blockID in CreatorMain.PenetrateBlocksID)
                    {
                        BlocksManager.Blocks[blockID].IsCollidable = true;
                    }
                    CreatorMain.PenetrateBlocksID.Clear();
                }
                else
                {
                    this.worldSettings.EnvironmentBehaviorMode = EnvironmentBehaviorMode.Static;
                    foreach (Block block in BlocksManager.Blocks)
                    {
                        if (block.IsCollidable)
                        {
                            block.IsCollidable = false;
                            CreatorMain.PenetrateBlocksID.Add(block.BlockIndex);
                        }
                    }
                }
                CreatorMain.Penetrate = !CreatorMain.Penetrate;
            }
            if (this.LightWorldButton.IsClicked)
            {
                if (CreatorMain.LightWorld)
                {
                    foreach (int blockID in CreatorMain.LightWorldBlockID)
                    {
                        BlocksManager.Blocks[blockID].EmittedLightAmount = 0;
                    }
                    CreatorMain.LightWorldBlockID.Clear();
                }
                else
                {
                    foreach (Block block in BlocksManager.Blocks)
                    {
                        if (block.EmittedLightAmount == 0)
                        {
                            block.EmittedLightAmount = 15;
                            CreatorMain.LightWorldBlockID.Add(block.BlockIndex);
                        }
                    }
                }
                CreatorMain.LightWorld = !CreatorMain.LightWorld;
            }
            if (CreatorMain.LightWorld)
            {
                this.LightWorldButton.Color = Color.Yellow;
            }
            else
            {
                this.LightWorldButton.Color = Color.White;
            }

            if (CreatorMain.Penetrate)
            {
                this.PenetrateButton.Color = Color.Yellow;
            }
            else
            {
                this.PenetrateButton.Color = Color.White;
            }
            if (this.EditRegionButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new EditRegionDialog(creatorAPI));
            }
            if (this.EditWorldButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new EditWorldDialog(creatorAPI));
            }
            if (this.ClearBlockButton.IsClicked)
            {
                this.player.ComponentGui.DisplaySmallMessage("可在设置中关闭生成在来停止正在清理的进程,在超距模式下谨慎使用清理方块", true, false);
                this.creatorAPI.ClearBlock = !this.creatorAPI.ClearBlock;
            }
            if (this.creatorAPI.ClearBlock)
            {
                this.ClearBlockButton.Color = Color.Yellow;
            }
            else
            {
                this.ClearBlockButton.Color = Color.White;
            }
            if (this.SetLinkButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new TwoPointLineDialog(creatorAPI));
            }

            /*            if (this.SetLinkButton.IsClicked)
             *          {
             *              if (this.creatorAPI.twoPointsOfAttachment)
             *                  this.creatorAPI.twoPointsOfAttachment = false;
             *              else
             *                  this.creatorAPI.twoPointsOfAttachment = true;
             *          }
             *          if (this.creatorAPI.twoPointsOfAttachment) this.SetLinkButton.Color = Color.Yellow; else this.SetLinkButton.Color = Color.White;*/


            if (this.SetPositionButton.IsClicked)
            {
                Vector3 position = player.ComponentBody.Position;
                Point3  point3   = new Point3((int)position.X, (int)position.Y, (int)position.Z);
                int[]   p        = new int[4] {
                    1, 2, 3, 4
                };
                DialogsManager.ShowDialog(null, new ListSelectionDialog("选择设置的点", p, 56f, (object e) => $"设置点{(int)e}", delegate(object e)
                {
                    creatorAPI.Position[(int)e - 1] = point3;
                    this.player.ComponentGui.DisplaySmallMessage($"成功设置点{(int)e}:\nX:{point3.X} , Y:{point3.Y} , Z:{point3.Z}", true, true);
                }));
            }
            if (this.creatorAPI.RevokeSwitch)
            {
                if (creatorAPI.revokeData == null)
                {
                    this.RevokeButton.IsEnabled = false;
                }
                else
                {
                    this.RevokeButton.IsEnabled = true;
                }
            }
            else
            {
                this.RevokeButton.IsEnabled = false;
            }
            if (this.RevokeButton.IsClicked)
            {
                this.creatorAPI.revokeData.Render();
                this.player.ComponentGui.DisplaySmallMessage($"撤回成功", true, true);
            }
            if (this.SetSpawn.IsClicked)
            {
                Vector3 position = this.player.ComponentBody.Position;
                this.player.PlayerData.SpawnPosition = position + new Vector3(0f, 0.1f, 0f);
                this.player.ComponentGui.DisplaySmallMessage(string.Format("玩家重生点位置设置\n X: {0} Y : {1} Z : {2}", (int)position.X, (int)position.Y, (int)position.Z), true, true);
            }
            if (this.ModButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new ModDialog(creatorAPI));
            }
            if (this.ReplaceButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new ReplaceDialog(creatorAPI));
            }
            if (this.SetModeButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new SetModeDialog(creatorAPI));
            }
            if (this.OnekeyButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new OnekeyGenerationDialog(creatorAPI));
            }
            if (this.CopyPasteButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new CopyPasteDialog(creatorAPI));
            }
            this.ClearCacheButton.IsEnabled = Directory.Exists(CreatorMain.CacheDirectory);
            if (this.ClearCacheButton.IsClicked)
            {
                if (FileOperation.Delete(CreatorMain.CacheDirectory))
                {
                    this.player.ComponentGui.DisplaySmallMessage("清除成功", true, true);
                }
                else
                {
                    this.player.ComponentGui.DisplaySmallMessage("清除失败", true, true);
                }
            }
            if (this.RemoveAnimalButton.IsClicked)
            {
                int num = 0;
                foreach (ComponentCreature current in player.Project.FindSubsystem <SubsystemCreatureSpawn>(true).Creatures)
                {
                    if (!(current is ComponentPlayer))
                    {
                        current.ComponentSpawn.Despawn();
                        num++;
                    }
                }
                this.player.ComponentGui.DisplaySmallMessage(string.Format("清除成功,共清除{0}只动物", num), true, false);
            }
            if (this.RemoveItemButton.IsClicked)
            {
                int num = 0;
                foreach (Pickable item in GameManager.Project.FindSubsystem <SubsystemPickables>(true).Pickables)
                {
                    item.Count    = 0;
                    item.ToRemove = true;
                    num++;
                }
                this.player.ComponentGui.DisplaySmallMessage(string.Format("清除成功,共清除{0}个掉落物", num), true, false);
            }
            if (this.TerrainTestButton.IsClicked)
            {
                IList <int>      enumValues       = EnumUtils.GetEnumValues(typeof(CreatorTerrainType));
                SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>();
                DialogsManager.ShowDialog(null, new ListSelectionDialog("选择地形类型", enumValues, 56f, (object e) => ((TerrainGenerationMode)e).ToString(), delegate(object e)
                {
                    ITerrainContentsGenerator myTerrain;
                    if ((CreatorTerrainType)e == CreatorTerrainType.Flat)
                    {
                        myTerrain = new CreatorNormalTerrain(subsystemTerrain);
                    }
                    else
                    {
                        myTerrain = new CreatorNormalTerrain(subsystemTerrain);
                    }
                    subsystemTerrain.Dispose();
                    subsystemTerrain.Load(new ValuesDictionary());
                    subsystemTerrain.TerrainContentsGenerator = myTerrain;
                }));
            }
            if (this.SetPositionCarefulButton.IsClicked)
            {
            }
            if (this.AdjustPositionButton.IsClicked)
            {
            }
            if (this.ThreePointPlaneButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new ThreePointToPlaneDialog(creatorAPI));
            }
            if (this.FourPointSpaceButton.IsClicked)
            {
                DialogsManager.ShowDialog(player.View.GameWidget, new FourPointSpaceDialog(creatorAPI));
            }
            //.........



            if (this.SetDifficultyButton.IsClicked)
            {
                Vector3 position = player.ComponentBody.Position;
                Point3  point3   = new Point3((int)position.X, (int)position.Y, (int)position.Z);
                int[]   p        = new int[4] {
                    0, 1, 2, 3
                };
                string[] difference = new string[4] {
                    "容易", "一般", "困难", "地狱"
                };
                DialogsManager.ShowDialog(null, new ListSelectionDialog("选择难度", p, 56f, (object e) => difference[(int)e], delegate(object e)
                {
                    this.player.ComponentGui.DisplaySmallMessage($"成功设置难度位: {difference[(int)e]}", true, true);
                }));
            }
        }