From 75ab58dc06e87351760e4798c51af14c86eb232c Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Sat, 16 Jul 2022 19:19:07 +0200 Subject: [PATCH] [KKS][MSI] Version up to 2.1; Code cleanup --- .../Features/EroDetectorFeat.cs | 59 ++++++++----------- src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs | 2 +- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/src/KKS_MoreStoreItems/Features/EroDetectorFeat.cs b/src/KKS_MoreStoreItems/Features/EroDetectorFeat.cs index 4586615..bde14bf 100644 --- a/src/KKS_MoreStoreItems/Features/EroDetectorFeat.cs +++ b/src/KKS_MoreStoreItems/Features/EroDetectorFeat.cs @@ -16,12 +16,11 @@ public class EroDetectorFeat : IFeature private static ConfigEntry _notifyLesb; private static string _infoTextPrefixMast = "{0}は{1}でオナニーしている"; private static string _infoTextPrefixLesb = "{0}は{1}でレズのセックスしている"; - private static string _infoTextPrefix = "エロ活動:{0}"; + private static string _infoTextPrefixGeneral = "エロ活動:{0}"; public bool ApplyFeature(ref CompositeDisposable disp, MoreShopItemsPlugin inst) { const string itemName = "Ero Detection App"; - const string itemUpgradeName = "Upgraded Ero Detection App"; disp.Add(StoreApi.RegisterShopItem( itemId: MoreShopItemsPlugin.DetectorItemId, @@ -41,7 +40,7 @@ public bool ApplyFeature(ref CompositeDisposable disp, MoreShopItemsPlugin inst) _notifyMast = inst.Config.Bind(itemName, "Notification on masturbation", true, "If the item is purchased, show a notification whenever any NPC starts a masturbation action."); _notifyLesb = inst.Config.Bind(itemName, "Notification on lesbian", true, "If the item is purchased, show a notification whenever any NPC starts a lesbian action."); - TranslationHelper.TranslateAsync(_infoTextPrefix, s => _infoTextPrefix = s); + TranslationHelper.TranslateAsync(_infoTextPrefixGeneral, s => _infoTextPrefixGeneral = s); TranslationHelper.TranslateAsync(_infoTextPrefixMast, s => _infoTextPrefixMast = s); TranslationHelper.TranslateAsync(_infoTextPrefixLesb, s => _infoTextPrefixLesb = s); @@ -55,47 +54,35 @@ private static void WaitPointDataChangedHook(Base __instance, Base.WaitPointData // wpData is null when the character is still walking to the current action location if (value == null) return; - if (__instance is NPC npc) + if (__instance is NPC npc && (npc.isOnanism && _notifyMast.Value || npc.isLesbian && _notifyLesb.Value)) { - if (npc.isOnanism && _notifyMast.Value || npc.isLesbian && _notifyLesb.Value) + try { - try + var featureLevel = StoreApi.GetItemAmountBought(MoreShopItemsPlugin.DetectorItemId); + if (featureLevel > 0) { - if (StoreApi.GetItemAmountBought(MoreShopItemsPlugin.DetectorItemId) > 0) + var mapNo = __instance.mapNo; + //if (ActionScene.initialized && ActionScene.instance.Player.mapNo != mapNo) + if (ActionScene.instance.Map.infoDic.TryGetValue(mapNo, out var param)) { - var mapNo = __instance.mapNo; - //if (ActionScene.initialized && ActionScene.instance.Player.mapNo != mapNo) - if (ActionScene.instance.Map.infoDic.TryGetValue(mapNo, out var param)) - { - var location = ""; - TranslationHelper.TryTranslate(param.DisplayName,out location); - - if (StoreApi.GetItemAmountBought(MoreShopItemsPlugin.DetectorItemId) > 1) - { - TranslationHelper.TranslateAsync(npc.charaData.Name, s => - { - if (npc.isOnanism) - { - InformationUI.SetAsync(string.Format(_infoTextPrefixMast, s, location), InformationUI.Mode.Normal).Forget(); - } - else if (npc.isLesbian) - { - InformationUI.SetAsync(string.Format(_infoTextPrefixLesb, s, location), InformationUI.Mode.Normal).Forget(); - } - return; - }); - return; - } - - InformationUI.SetAsync(string.Format(_infoTextPrefix, location), InformationUI.Mode.Normal).Forget(); + TranslationHelper.TryTranslate(param.DisplayName, out var locationName); + if (featureLevel > 1) + { + TranslationHelper.TranslateAsync( + npc.charaData.Name, + s => InformationUI.SetAsync(string.Format(npc.isOnanism ? _infoTextPrefixMast : _infoTextPrefixLesb, s, locationName), InformationUI.Mode.Normal).Forget()); + } + else + { + InformationUI.SetAsync(string.Format(_infoTextPrefixGeneral, locationName), InformationUI.Mode.Normal).Forget(); } } } - catch (Exception e) - { - UnityEngine.Debug.LogException(e); - } + } + catch (Exception e) + { + UnityEngine.Debug.LogException(e); } } } diff --git a/src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs b/src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs index 4813ebb..5a780a2 100644 --- a/src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs +++ b/src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs @@ -15,7 +15,7 @@ namespace MoreShopItems public class MoreShopItemsPlugin : BaseUnityPlugin { public const string GUID = "MoreShopItems"; - public const string Version = "2.0"; + public const string Version = "2.1"; internal const int DetectorItemId = 3456651; internal const int TalismanItemId = 3456650;