From 7b88c6523f694d66e40c358361eda081d8658f32 Mon Sep 17 00:00:00 2001 From: Awbugl Date: Fri, 27 Jan 2023 01:03:29 +0800 Subject: [PATCH] Update 2.5.1 --- CHANGELOG.md | 12 +++++++++--- .../Logic/PlanetBase/InternalFunctions.cs | 15 ++++++++++----- .../UI/UIPlanetBase/UIPlanetBaseWindow.cs | 19 +++++++++++-------- src/ProjectGenesis.cs | 2 +- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a05200a..501bc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +- v2.5.1 + + 修复了`v2.5.0`版本导致的性能问题 + + + Fix the performance problem caused by `v2.5.0` version + + +
+ 点击展开日志 | Click to view all + - v2.5.0 升格凝想 | Elevational Contemplations + 添加 `行星协调中心` :可为星球添加数种增益效果 + 添加 `DSPMoreRecipes` mod 兼容补丁 @@ -12,9 +21,6 @@ + Fix the problem that the item is missing in the custom mecha UI -
- 点击展开日志 | Click to view all - - v2.4.10 + 修复了火力发电站燃料需求不正确的问题 diff --git a/src/Patches/Logic/PlanetBase/InternalFunctions.cs b/src/Patches/Logic/PlanetBase/InternalFunctions.cs index 6a498c8..d118293 100644 --- a/src/Patches/Logic/PlanetBase/InternalFunctions.cs +++ b/src/Patches/Logic/PlanetBase/InternalFunctions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Concurrent; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -46,11 +45,17 @@ internal static void Import(BinaryReader r) internal static void IntoOtherSave() => ReInitAll(); private static void ReInitAll() => _planetBases = new ConcurrentDictionary(); - + private static bool ContainsFocus(int planetId, int focusid) { - if (!_planetBases.ContainsKey(planetId)) return false; - return Array.Exists(_planetBases[planetId], i => i == focusid); + if (_planetBases.TryGetValue(planetId, out var planetBase)) + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (var t in planetBase) + { + if (t == focusid) return true; + } + + return false; } } } diff --git a/src/Patches/UI/UIPlanetBase/UIPlanetBaseWindow.cs b/src/Patches/UI/UIPlanetBase/UIPlanetBaseWindow.cs index 741a32a..2ef34b7 100644 --- a/src/Patches/UI/UIPlanetBase/UIPlanetBaseWindow.cs +++ b/src/Patches/UI/UIPlanetBase/UIPlanetBaseWindow.cs @@ -1,5 +1,4 @@ -using System; -using CommonAPI.Systems; +using CommonAPI.Systems; using HarmonyLib; using ProjectGenesis.Utils; using UnityEngine; @@ -115,7 +114,7 @@ private void OnIconBtnClick(int id) private void OnIconBtnRightClick(int id) { _currentFocusIds[id] = 0; - SetPlanetFocus(CurPlanetId, id,0); + SetPlanetFocus(CurPlanetId, id, 0); _iconImgs[id].sprite = _tagNotSelectedSprite; _iconTexts[id].text = ""; } @@ -126,14 +125,18 @@ private void OnPickReturn(ItemProto proto, int id) var currentFocusId = proto.ID; - if (Array.Exists(_currentFocusIds, i => i == currentFocusId)) + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (var t in _currentFocusIds) { - UIRealtimeTip.Popup("不能重复选择".TranslateFromJson()); - return; + if (t == currentFocusId) + { + UIRealtimeTip.Popup("不能重复选择".TranslateFromJson()); + return; + } } - + _currentFocusIds[id] = currentFocusId; - SetPlanetFocus(CurPlanetId, id,currentFocusId); + SetPlanetFocus(CurPlanetId, id, currentFocusId); _iconTexts[id].text = FilterIds[currentFocusId].TranslateFromJson(); var sprite = proto.iconSprite; if (sprite != null) _iconImgs[id].sprite = sprite; diff --git a/src/ProjectGenesis.cs b/src/ProjectGenesis.cs index 7fef027..f95e76b 100644 --- a/src/ProjectGenesis.cs +++ b/src/ProjectGenesis.cs @@ -44,7 +44,7 @@ public class ProjectGenesis : BaseUnityPlugin, IModCanSave, IMultiplayerModWithS { public const string MODGUID = "org.LoShin.GenesisBook"; public const string MODNAME = "GenesisBook"; - public const string VERSION = "2.5.0"; + public const string VERSION = "2.5.1"; public string Version => VERSION;