public override void Update() { CommunityContentEntry communityContentEntry = m_listPanel.SelectedItem as CommunityContentEntry; m_downloadButton.IsEnabled = (communityContentEntry != null); m_deleteButton.IsEnabled = (UserManager.ActiveUser != null && communityContentEntry != null && communityContentEntry.UserId == UserManager.ActiveUser.UniqueId); m_orderLabel.Text = GetOrderDisplayName(m_order); m_filterLabel.Text = GetFilterDisplayName(m_filter); if (m_changeOrderButton.IsClicked) { List <Order> items = EnumUtils.GetEnumValues(typeof(Order)).Cast <Order>().ToList(); DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, "Order Type"), items, 60f, (object item) => GetOrderDisplayName((Order)item), delegate(object item) { m_order = (Order)item; PopulateList(null); })); } if (m_changeFilterButton.IsClicked) { List <object> list = new List <object>(); list.Add(string.Empty); foreach (ExternalContentType item in from ExternalContentType t in EnumUtils.GetEnumValues(typeof(ExternalContentType)) where ExternalContentManager.IsEntryTypeDownloadSupported(t) select t) { list.Add(item); } if (UserManager.ActiveUser != null) { list.Add(UserManager.ActiveUser.UniqueId); } DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, "Filter"), list, 60f, (object item) => GetFilterDisplayName(item), delegate(object item) { m_filter = item; PopulateList(null); })); } if (m_downloadButton.IsClicked && communityContentEntry != null) { DownloadEntry(communityContentEntry); } if (m_deleteButton.IsClicked && communityContentEntry != null) { DeleteEntry(communityContentEntry); } if (m_moreOptionsButton.IsClicked) { DialogsManager.ShowDialog(null, new MoreCommunityLinkDialog()); } if (m_moreLink != null && m_moreLink.IsClicked) { PopulateList((string)m_moreLink.Tag); } if (base.Input.Back || Children.Find <BevelledButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen("Content"); } if (base.Input.Hold.HasValue && base.Input.HoldTime > 2f && base.Input.Hold.Value.Y < 20f) { m_contentExpiryTime = 0.0; Task.Delay(250).Wait(); } }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemTime = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true); m_subsystemPickables = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true); m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true); m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true); m_foodFactors = new float[EnumUtils.GetEnumValues(typeof(FoodType)).Max() + 1]; foreach (KeyValuePair <string, object> item in valuesDictionary.GetValue <ValuesDictionary>("FoodFactors")) { FoodType foodType = (FoodType)Enum.Parse(typeof(FoodType), item.Key, ignoreCase: false); m_foodFactors[(int)foodType] = (float)item.Value; } m_subsystemPickables.PickableAdded += delegate(Pickable pickable) { if (TryAddPickable(pickable) && m_pickable == null) { m_pickable = pickable; } }; m_subsystemPickables.PickableRemoved += delegate(Pickable pickable) { m_pickables.Remove(pickable); if (m_pickable == pickable) { m_pickable = null; } }; m_stateMachine.AddState("Inactive", delegate { m_importanceLevel = 0f; m_pickable = null; }, delegate { if (m_satiation < 1f) { if (m_pickable == null) { if (m_subsystemTime.GameTime > m_nextFindPickableTime) { m_nextFindPickableTime = m_subsystemTime.GameTime + (double)m_random.Float(2f, 4f); m_pickable = FindPickable(m_componentCreature.ComponentBody.Position); } } else { m_importanceLevel = m_random.Float(5f, 10f); } } if (IsActive) { m_stateMachine.TransitionTo("Move"); m_blockedCount = 0; } }, null); m_stateMachine.AddState("Move", delegate { if (m_pickable != null) { float speed = (m_satiation == 0f) ? m_random.Float(0.5f, 0.7f) : 0.5f; int maxPathfindingPositions = (m_satiation == 0f) ? 1000 : 500; float num2 = Vector3.Distance(m_componentCreature.ComponentCreatureModel.EyePosition, m_componentCreature.ComponentBody.Position); m_componentPathfinding.SetDestination(m_pickable.Position, speed, 1f + num2, maxPathfindingPositions, useRandomMovements: true, ignoreHeightDifference: false, raycastDestination: true, null); if (m_random.Float(0f, 1f) < 0.66f) { m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true); } } }, delegate { if (!IsActive) { m_stateMachine.TransitionTo("Inactive"); } else if (m_pickable == null) { m_importanceLevel = 0f; } else if (m_componentPathfinding.IsStuck) { m_importanceLevel = 0f; m_satiation += 0.75f; } else if (!m_componentPathfinding.Destination.HasValue) { m_stateMachine.TransitionTo("Eat"); } else if (Vector3.DistanceSquared(m_componentPathfinding.Destination.Value, m_pickable.Position) > 0.0625f) { m_stateMachine.TransitionTo("PickableMoved"); } if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta) { m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true); } if (m_pickable != null) { m_componentCreature.ComponentCreatureModel.LookAtOrder = m_pickable.Position; } else { m_componentCreature.ComponentCreatureModel.LookRandomOrder = true; } }, null); m_stateMachine.AddState("PickableMoved", null, delegate { if (m_pickable != null) { m_componentCreature.ComponentCreatureModel.LookAtOrder = m_pickable.Position; } if (m_subsystemTime.PeriodicGameTimeEvent(0.25, (double)(GetHashCode() % 100) * 0.01)) { m_stateMachine.TransitionTo("Move"); } }, null); m_stateMachine.AddState("Eat", delegate { m_eatTime = m_random.Float(4f, 5f); m_blockedTime = 0f; }, delegate { if (!IsActive) { m_stateMachine.TransitionTo("Inactive"); } if (m_pickable == null) { m_importanceLevel = 0f; } if (m_pickable != null) { if (Vector3.DistanceSquared(new Vector3(m_componentCreature.ComponentCreatureModel.EyePosition.X, m_componentCreature.ComponentBody.Position.Y, m_componentCreature.ComponentCreatureModel.EyePosition.Z), m_pickable.Position) < 0.640000045f) { m_eatTime -= m_subsystemTime.GameTimeDelta; m_blockedTime = 0f; if (m_eatTime <= 0.0) { m_satiation += 1f; m_pickable.Count = MathUtils.Max(m_pickable.Count - 1, 0); if (m_pickable.Count == 0) { m_pickable.ToRemove = true; m_importanceLevel = 0f; } else if (m_random.Float(0f, 1f) < 0.5f) { m_importanceLevel = 0f; } } } else { float num = Vector3.Distance(m_componentCreature.ComponentCreatureModel.EyePosition, m_componentCreature.ComponentBody.Position); m_componentPathfinding.SetDestination(m_pickable.Position, 0.3f, 0.5f + num, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null); m_blockedTime += m_subsystemTime.GameTimeDelta; } if (m_blockedTime > 3f) { m_blockedCount++; if (m_blockedCount >= 3) { m_importanceLevel = 0f; m_satiation += 0.75f; } else { m_stateMachine.TransitionTo("Move"); } } } m_componentCreature.ComponentCreatureModel.FeedOrder = true; if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta) { m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true); } if (m_random.Float(0f, 1f) < 1.5f * m_subsystemTime.GameTimeDelta) { m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(2f); } }, null); m_stateMachine.TransitionTo("Inactive"); }
public override void Update() { if (m_moveControlModeButton.IsClicked) { SettingsManager.MoveControlMode = (MoveControlMode)((int)(SettingsManager.MoveControlMode + 1) % EnumUtils.GetEnumValues(typeof(MoveControlMode)).Count); } if (m_lookControlModeButton.IsClicked) { SettingsManager.LookControlMode = (LookControlMode)((int)(SettingsManager.LookControlMode + 1) % EnumUtils.GetEnumValues(typeof(LookControlMode)).Count); } if (m_leftHandedLayoutButton.IsClicked) { SettingsManager.LeftHandedLayout = !SettingsManager.LeftHandedLayout; } if (m_flipVerticalAxisButton.IsClicked) { SettingsManager.FlipVerticalAxis = !SettingsManager.FlipVerticalAxis; } if (m_autoJumpButton.IsClicked) { SettingsManager.AutoJump = !SettingsManager.AutoJump; } if (m_horizontalCreativeFlightButton.IsClicked) { SettingsManager.HorizontalCreativeFlight = !SettingsManager.HorizontalCreativeFlight; } if (m_moveSensitivitySlider.IsSliding) { SettingsManager.MoveSensitivity = m_moveSensitivitySlider.Value; } if (m_lookSensitivitySlider.IsSliding) { SettingsManager.LookSensitivity = m_lookSensitivitySlider.Value; } if (m_gamepadCursorSpeedSlider.IsSliding) { SettingsManager.GamepadCursorSpeed = m_gamepadCursorSpeedSlider.Value; } if (m_gamepadDeadZoneSlider.IsSliding) { SettingsManager.GamepadDeadZone = m_gamepadDeadZoneSlider.Value; } if (m_creativeDigTimeSlider.IsSliding) { SettingsManager.CreativeDigTime = m_creativeDigTimeSlider.Value; } if (m_creativeReachSlider.IsSliding) { SettingsManager.CreativeReach = m_creativeReachSlider.Value; } if (m_holdDurationSlider.IsSliding) { SettingsManager.MinimumHoldDuration = m_holdDurationSlider.Value; } if (m_dragDistanceSlider.IsSliding) { SettingsManager.MinimumDragDistance = m_dragDistanceSlider.Value; } m_moveControlModeButton.Text = LanguageControl.Get("MoveControlMode", SettingsManager.MoveControlMode.ToString()); m_lookControlModeButton.Text = LanguageControl.Get("LookControlMode", SettingsManager.LookControlMode.ToString()); m_leftHandedLayoutButton.Text = (SettingsManager.LeftHandedLayout ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_flipVerticalAxisButton.Text = (SettingsManager.FlipVerticalAxis ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_autoJumpButton.Text = (SettingsManager.AutoJump ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_horizontalCreativeFlightButton.Text = (SettingsManager.HorizontalCreativeFlight ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_moveSensitivitySlider.Value = SettingsManager.MoveSensitivity; m_moveSensitivitySlider.Text = MathUtils.Round(SettingsManager.MoveSensitivity * 10f).ToString(); m_lookSensitivitySlider.Value = SettingsManager.LookSensitivity; m_lookSensitivitySlider.Text = MathUtils.Round(SettingsManager.LookSensitivity * 10f).ToString(); m_gamepadCursorSpeedSlider.Value = SettingsManager.GamepadCursorSpeed; m_gamepadCursorSpeedSlider.Text = $"{SettingsManager.GamepadCursorSpeed:0.0}x"; m_gamepadDeadZoneSlider.Value = SettingsManager.GamepadDeadZone; m_gamepadDeadZoneSlider.Text = $"{SettingsManager.GamepadDeadZone * 100f:0}%"; m_creativeDigTimeSlider.Value = SettingsManager.CreativeDigTime; m_creativeDigTimeSlider.Text = $"{MathUtils.Round(1000f * SettingsManager.CreativeDigTime)}ms"; m_creativeReachSlider.Value = SettingsManager.CreativeReach; m_creativeReachSlider.Text = string.Format(LanguageControl.Get(fName, 1), $"{SettingsManager.CreativeReach:0.0} "); m_holdDurationSlider.Value = SettingsManager.MinimumHoldDuration; m_holdDurationSlider.Text = $"{MathUtils.Round(1000f * SettingsManager.MinimumHoldDuration)}ms"; m_dragDistanceSlider.Value = SettingsManager.MinimumDragDistance; m_dragDistanceSlider.Text = $"{MathUtils.Round(SettingsManager.MinimumDragDistance)} " + LanguageControl.Get(fName, 2); if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } }
public void Update(float dt) { if (m_subsystemGameInfo.WorldSettings.GameMode != 0 && m_subsystemGameInfo.WorldSettings.AreAdventureSurvivalMechanicsEnabled && m_subsystemTime.PeriodicGameTimeEvent(0.5, 0.0)) { foreach (int enumValue in EnumUtils.GetEnumValues(typeof(ClothingSlot))) { bool flag = false; m_clothesList.Clear(); m_clothesList.AddRange(GetClothes((ClothingSlot)enumValue)); int num = 0; while (num < m_clothesList.Count) { int value = m_clothesList[num]; ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value)); if ((float)clothingData.PlayerLevelRequired > m_componentPlayer.PlayerData.Level) { m_componentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), clothingData.PlayerLevelRequired, clothingData.DisplayName), Color.White, blinking: true, playNotificationSound: true); m_subsystemPickables.AddPickable(value, 1, m_componentBody.Position, null, null); m_clothesList.RemoveAt(num); flag = true; } else { num++; } } if (flag) { SetClothes((ClothingSlot)enumValue, m_clothesList); } } } if (m_subsystemGameInfo.WorldSettings.GameMode != 0 && m_subsystemGameInfo.WorldSettings.AreAdventureSurvivalMechanicsEnabled && m_subsystemTime.PeriodicGameTimeEvent(2.0, 0.0) && ((m_componentLocomotion.LastWalkOrder.HasValue && m_componentLocomotion.LastWalkOrder.Value != Vector2.Zero) || (m_componentLocomotion.LastSwimOrder.HasValue && m_componentLocomotion.LastSwimOrder.Value != Vector3.Zero) || m_componentLocomotion.LastJumpOrder != 0f)) { if (m_lastTotalElapsedGameTime.HasValue) { foreach (int enumValue2 in EnumUtils.GetEnumValues(typeof(ClothingSlot))) { bool flag2 = false; m_clothesList.Clear(); m_clothesList.AddRange(GetClothes((ClothingSlot)enumValue2)); for (int i = 0; i < m_clothesList.Count; i++) { int value2 = m_clothesList[i]; ClothingData clothingData2 = ClothingBlock.GetClothingData(Terrain.ExtractData(value2)); float num2 = (m_componentVitalStats.Wetness > 0f) ? (10f * clothingData2.Sturdiness) : (20f * clothingData2.Sturdiness); double num3 = MathUtils.Floor(m_lastTotalElapsedGameTime.Value / (double)num2); if (MathUtils.Floor(m_subsystemGameInfo.TotalElapsedGameTime / (double)num2) > num3 && m_random.Float(0f, 1f) < 0.75f) { m_clothesList[i] = BlocksManager.DamageItem(value2, 1); flag2 = true; } } int num4 = 0; while (num4 < m_clothesList.Count) { if (Terrain.ExtractContents(m_clothesList[num4]) != 203) { m_clothesList.RemoveAt(num4); m_subsystemParticles.AddParticleSystem(new BlockDebrisParticleSystem(m_subsystemTerrain, m_componentBody.Position + m_componentBody.BoxSize / 2f, 1f, 1f, Color.White, 0)); m_componentGui.DisplaySmallMessage(LanguageControl.Get(fName, 2), Color.White, blinking: true, playNotificationSound: true); } else { num4++; } } if (flag2) { SetClothes((ClothingSlot)enumValue2, m_clothesList); } } } m_lastTotalElapsedGameTime = m_subsystemGameInfo.TotalElapsedGameTime; } UpdateRenderTargets(); }
public override void Update() { if (m_resolutionButton.IsClicked) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(ResolutionMode)); SettingsManager.ResolutionMode = (ResolutionMode)((enumValues.IndexOf((int)SettingsManager.ResolutionMode) + 1) % enumValues.Count); } if (m_visibilityRangeSlider.IsSliding) { SettingsManager.VisibilityRange = m_visibilityRanges[MathUtils.Clamp((int)m_visibilityRangeSlider.Value, 0, m_visibilityRanges.Count - 1)]; } if (m_viewAnglesButton.IsClicked) { IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(ViewAngleMode)); SettingsManager.ViewAngleMode = (ViewAngleMode)((enumValues2.IndexOf((int)SettingsManager.ViewAngleMode) + 1) % enumValues2.Count); } if (m_terrainMipmapsButton.IsClicked) { SettingsManager.TerrainMipmapsEnabled = !SettingsManager.TerrainMipmapsEnabled; } if (m_skyRenderingModeButton.IsClicked) { IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(SkyRenderingMode)); SettingsManager.SkyRenderingMode = (SkyRenderingMode)((enumValues3.IndexOf((int)SettingsManager.SkyRenderingMode) + 1) % enumValues3.Count); } if (m_objectShadowsButton.IsClicked) { SettingsManager.ObjectsShadowsEnabled = !SettingsManager.ObjectsShadowsEnabled; } if (m_framerateLimitSlider.IsSliding) { SettingsManager.PresentationInterval = m_presentationIntervals[MathUtils.Clamp((int)m_framerateLimitSlider.Value, 0, m_presentationIntervals.Count - 1)]; } if (m_displayFpsCounterButton.IsClicked) { SettingsManager.DisplayFpsCounter = !SettingsManager.DisplayFpsCounter; } if (m_displayFpsRibbonButton.IsClicked) { SettingsManager.DisplayFpsRibbon = !SettingsManager.DisplayFpsRibbon; } m_resolutionButton.Text = LanguageControl.Get("ResolutionMode", SettingsManager.ResolutionMode.ToString()); m_visibilityRangeSlider.Value = ((m_visibilityRanges.IndexOf(SettingsManager.VisibilityRange) >= 0) ? m_visibilityRanges.IndexOf(SettingsManager.VisibilityRange) : 64); m_visibilityRangeSlider.Text = string.Format(LanguageControl.Get(fName, 1), SettingsManager.VisibilityRange); if (SettingsManager.VisibilityRange <= 48) { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 2); } else if (SettingsManager.VisibilityRange <= 64) { m_visibilityRangeWarningLabel.IsVisible = false; } else if (SettingsManager.VisibilityRange <= 112) { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 3); } else if (SettingsManager.VisibilityRange <= 224) { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 4); } else if (SettingsManager.VisibilityRange <= 384) { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 5); } else if (SettingsManager.VisibilityRange <= 512) { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 6); } else { m_visibilityRangeWarningLabel.IsVisible = true; m_visibilityRangeWarningLabel.Text = LanguageControl.Get(fName, 7); } m_viewAnglesButton.Text = LanguageControl.Get("ViewAngleMode", SettingsManager.ViewAngleMode.ToString()); if (SettingsManager.TerrainMipmapsEnabled) { m_terrainMipmapsButton.Text = LanguageControl.Get("Usual", "enable"); } else { m_terrainMipmapsButton.Text = LanguageControl.Get("Usual", "disable"); } m_skyRenderingModeButton.Text = LanguageControl.Get("SkyRenderingMode", SettingsManager.SkyRenderingMode.ToString()); m_objectShadowsButton.Text = SettingsManager.ObjectsShadowsEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable"); m_framerateLimitSlider.Value = (m_presentationIntervals.IndexOf(SettingsManager.PresentationInterval) >= 0) ? m_presentationIntervals.IndexOf(SettingsManager.PresentationInterval) : (m_presentationIntervals.Count - 1); m_framerateLimitSlider.Text = (SettingsManager.PresentationInterval != 0) ? string.Format(LanguageControl.Get(fName, 8), SettingsManager.PresentationInterval) : LanguageControl.Get(fName, 9); m_displayFpsCounterButton.Text = (SettingsManager.DisplayFpsCounter ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no")); m_displayFpsRibbonButton.Text = (SettingsManager.DisplayFpsRibbon ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no")); if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { bool flag = SettingsManager.VisibilityRange > 128; if (SettingsManager.VisibilityRange > m_enterVisibilityRange && flag) { DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 10), LanguageControl.Get(fName, 11), LanguageControl.Get("Usual", "ok"), LanguageControl.Get("Usual", "back"), delegate(MessageDialogButton button) { if (button == MessageDialogButton.Button1) { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } })); } else { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } } }