public void upDataWorld() { 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); }
public override void Update() { ListItem selectedItem = (ListItem)m_contentList.SelectedItem; m_deleteButton.IsEnabled = (selectedItem != null && !selectedItem.IsBuiltIn); m_uploadButton.IsEnabled = (selectedItem != null && !selectedItem.IsBuiltIn); m_filterLabel.Text = GetFilterDisplayName(m_filter); if (m_deleteButton.IsClicked) { string smallMessage = (selectedItem.UseCount <= 0) ? string.Format(LanguageControl.Get(fName, 5), selectedItem.DisplayName) : string.Format(LanguageControl.Get(fName, 6), selectedItem.DisplayName, selectedItem.UseCount); DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 9), smallMessage, LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button) { if (button == MessageDialogButton.Button1) { ExternalContentManager.DeleteExternalContent(selectedItem.Type, selectedItem.Name); UpdateList(); } })); } if (m_uploadButton.IsClicked) { ExternalContentManager.ShowUploadUi(selectedItem.Type, selectedItem.Name); } if (m_changeFilterButton.IsClicked) { List <ExternalContentType> list = new List <ExternalContentType>(); list.Add(ExternalContentType.Unknown); list.Add(ExternalContentType.BlocksTexture); list.Add(ExternalContentType.CharacterSkin); list.Add(ExternalContentType.FurniturePack); DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 7), list, 60f, (object item) => GetFilterDisplayName((ExternalContentType)item), delegate(object item) { if ((ExternalContentType)item != m_filter) { m_filter = (ExternalContentType)item; UpdateList(); } })); } if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } }
public new void HandleInput() { WidgetInput input = m_componentPlayer.View.Input; PlayerInput playerInput = m_componentPlayer.ComponentInput.PlayerInput; ComponentRider componentRider = m_componentPlayer.ComponentRider; if (m_componentPlayer.View.ActiveCamera.IsEntityControlEnabled) { if (!m_keyboardHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Keyboard) != 0 && Time.PeriodicEvent(7.0, 0.0)) { m_keyboardHelpMessageShown = true; DisplaySmallMessage("按 H 键查看键盘控制帮助\n(或看帮助)", blinking: true, playNotificationSound: true); } else if (!m_gamepadHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Gamepads) != 0 && Time.PeriodicEvent(7.0, 0.0)) { m_gamepadHelpMessageShown = true; DisplaySmallMessage("按 START/PAUSE 键查看手柄控制帮助\n(或看帮助)", blinking: true, playNotificationSound: true); } } if (playerInput.KeyboardHelp) { if (m_keyboardHelpDialog == null) { m_keyboardHelpDialog = new KeyboardHelpDialog(); } if (m_keyboardHelpDialog.ParentWidget != null) { DialogsManager.HideDialog(m_keyboardHelpDialog); } else { DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_keyboardHelpDialog); } } if (playerInput.GamepadHelp) { if (m_gamepadHelpDialog == null) { m_gamepadHelpDialog = new GamepadHelpDialog(); } if (m_gamepadHelpDialog.ParentWidget != null) { DialogsManager.HideDialog(m_gamepadHelpDialog); } else { DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_gamepadHelpDialog); } } if (m_helpButtonWidget.IsClicked) { ScreensManager.SwitchScreen("Help"); } if (playerInput.ToggleInventory || m_inventoryButtonWidget.IsClicked) { if (IsInventoryVisible()) { ModalPanelWidget = null; } else if (m_componentPlayer.ComponentMiner.Inventory is ComponentCreativeInventory) { ModalPanelWidget = new CreativeInventoryWidget(m_componentPlayer.Entity); } else { ModalPanelWidget = new FullInventoryWidget(m_componentPlayer.ComponentMiner.Inventory, m_componentPlayer.Entity.FindComponent <ComponentCraftingTable>(throwOnError: true)); } } if (playerInput.ToggleClothing || m_clothingButtonWidget.IsClicked) { if (IsClothingVisible()) { ModalPanelWidget = null; } else { ModalPanelWidget = new ClothingWidget(m_componentPlayer); } } if (m_sneakButtonWidget.IsClicked || playerInput.ToggleSneak) { bool isSneaking = m_componentPlayer.ComponentBody.IsSneaking; m_componentPlayer.ComponentBody.IsSneaking = !isSneaking; if (m_componentPlayer.ComponentBody.IsSneaking != isSneaking) { if (m_componentPlayer.ComponentBody.IsSneaking) { DisplaySmallMessage("Sneak mode on", blinking: false, playNotificationSound: false); } else { DisplaySmallMessage("Sneak mode off", blinking: false, playNotificationSound: false); } } } if (componentRider != null && (m_mountButtonWidget.IsClicked || playerInput.ToggleMount)) { bool flag = componentRider.Mount != null; if (flag) { componentRider.StartDismounting(); } else { ComponentMount componentMount = componentRider.FindNearestMount(); if (componentMount != null) { componentRider.StartMounting(componentMount); } } if (componentRider.Mount != null != flag) { if (componentRider.Mount != null) { DisplaySmallMessage("Mounted", blinking: false, playNotificationSound: false); } else { DisplaySmallMessage("Dismounted", blinking: false, playNotificationSound: false); } } } if ((m_editItemButton.IsClicked || playerInput.EditItem) && m_nearbyEditableCell.HasValue) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z); int contents = Terrain.ExtractContents(cellValue); SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(contents); for (int i = 0; i < blockBehaviors.Length && !blockBehaviors[i].OnEditBlock(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z, cellValue, m_componentPlayer); i++) { } } else if ((m_editItemButton.IsClicked || playerInput.EditItem) && IsActiveSlotEditable()) { IInventory inventory = m_componentPlayer.ComponentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; int num = Terrain.ExtractContents(inventory.GetSlotValue(activeSlotIndex)); if (BlocksManager.Blocks[num].IsEditable) { SubsystemBlockBehavior[] blockBehaviors2 = m_subsystemBlockBehaviors.GetBlockBehaviors(num); for (int j = 0; j < blockBehaviors2.Length && !blockBehaviors2[j].OnEditInventoryItem(inventory, activeSlotIndex, m_componentPlayer); j++) { } } } } if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_creativeFlyButtonWidget.IsClicked || playerInput.ToggleCreativeFly) && componentRider.Mount == null) { bool isCreativeFlyEnabled = m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled; m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled = !isCreativeFlyEnabled; if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled != isCreativeFlyEnabled) { if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled) { m_componentPlayer.ComponentLocomotion.JumpOrder = 1f; DisplaySmallMessage("Fly mode on", blinking: false, playNotificationSound: false); } else { DisplaySmallMessage("Fly mode off", blinking: false, playNotificationSound: false); } } } if (m_cameraButtonWidget.IsClicked || playerInput.SwitchCameraMode) { View view = m_componentPlayer.View; if (view.ActiveCamera.GetType() == typeof(FppCamera)) { view.ActiveCamera = view.FindCamera <TppCamera>(); DisplaySmallMessage("第三人称视角", blinking: false, playNotificationSound: false); } else if (view.ActiveCamera.GetType() == typeof(TppCamera)) { view.ActiveCamera = view.FindCamera <OrbitCamera>(); DisplaySmallMessage("滑轨视角", blinking: false, playNotificationSound: false); } else if (view.ActiveCamera.GetType() == typeof(OrbitCamera)) { view.ActiveCamera = view.FindCamera <FixedCamera>(); DisplaySmallMessage("固定视角", blinking: false, playNotificationSound: false); } else if (view.ActiveCamera.GetType() == typeof(FixedCamera)) { view.ActiveCamera = new DebugCamera(view); DisplaySmallMessage("调试视角", blinking: false, playNotificationSound: false); } else { view.ActiveCamera = view.FindCamera <FppCamera>(); DisplaySmallMessage("第一人称视角", blinking: false, playNotificationSound: false); } } if (m_photoButtonWidget.IsClicked || playerInput.TakeScreenshot) { ScreenCaptureManager.CapturePhoto(); Time.QueueFrameCountDelayedExecution(Time.FrameIndex + 1, HandleInput_b__108_0); } if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_lightningButtonWidget.IsClicked || playerInput.Lighting)) { Matrix matrix = Matrix.CreateFromQuaternion(m_componentPlayer.ComponentCreatureModel.EyeRotation); base.Project.FindSubsystem <SubsystemWeather>(throwOnError: true).ManualLightingStrike(m_componentPlayer.ComponentCreatureModel.EyePosition, matrix.Forward); } if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && (m_timeOfDayButtonWidget.IsClicked || playerInput.TimeOfDay)) { float num2 = MathUtils.Remainder(0.25f, 1f); float num3 = MathUtils.Remainder(0.5f, 1f); float num4 = MathUtils.Remainder(0.75f, 1f); float num5 = MathUtils.Remainder(1f, 1f); float num6 = MathUtils.Remainder(num2 - m_subsystemTimeOfDay.TimeOfDay, 1f); float num7 = MathUtils.Remainder(num3 - m_subsystemTimeOfDay.TimeOfDay, 1f); float num8 = MathUtils.Remainder(num4 - m_subsystemTimeOfDay.TimeOfDay, 1f); float num9 = MathUtils.Remainder(num5 - m_subsystemTimeOfDay.TimeOfDay, 1f); float num10 = MathUtils.Min(num6, num7, num8, num9); if (num6 == num10) { m_subsystemTimeOfDay.TimeOfDayOffset += num6; DisplaySmallMessage("Dawn", blinking: false, playNotificationSound: false); } else if (num7 == num10) { m_subsystemTimeOfDay.TimeOfDayOffset += num7; DisplaySmallMessage("Noon", blinking: false, playNotificationSound: false); } else if (num8 == num10) { m_subsystemTimeOfDay.TimeOfDayOffset += num8; DisplaySmallMessage("Dusk", blinking: false, playNotificationSound: false); } else if (num9 == num10) { m_subsystemTimeOfDay.TimeOfDayOffset += num9; DisplaySmallMessage("Midnight", blinking: false, playNotificationSound: false); } } if (ModalPanelWidget != null) { if (input.Cancel || input.Back || m_backButtonWidget.IsClicked) { ModalPanelWidget = null; } } else if (input.Back || m_backButtonWidget.IsClicked) { DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, new GameMenuDialog(m_componentPlayer)); } }
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(); }