From ec50b42dc7fefdc47d99c9564cb45af18a176ee6 Mon Sep 17 00:00:00 2001 From: IcyClawz Date: Fri, 25 Oct 2024 20:55:26 +0300 Subject: [PATCH] style --- ItemContextMenuExt/ItemContextMenuExt.cs | 17 ++++++++--------- ItemSellPrice/ItemSellPrice.cs | 19 +++++++------------ MagazineInspector/MagazineInspector.cs | 2 +- MunitionsExpert/Plugin.cs | 7 ++++--- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/ItemContextMenuExt/ItemContextMenuExt.cs b/ItemContextMenuExt/ItemContextMenuExt.cs index 7892da8..7e3c695 100644 --- a/ItemContextMenuExt/ItemContextMenuExt.cs +++ b/ItemContextMenuExt/ItemContextMenuExt.cs @@ -48,7 +48,7 @@ internal sealed class CustomInteractionsProvider : IItemCustomInteractionsProvid Icon = () => StaticIcons.GetAttributeIcon(EItemAttributeId.Weapon), SubMenu = () => new FireModeSubMenu(uiContext, fireModeComponent), Enabled = () => fireModeComponent.AvailableEFireModes.Length > 1, - Error = () => "This weapon is incapable of selective fire" + Error = () => "This weapon is incapable of selective fire", }; yield break; } @@ -66,7 +66,7 @@ internal sealed class CustomInteractionsProvider : IItemCustomInteractionsProvid Singleton.Instance.PlayUISound(EUISoundType.MenuContextMenu); ComponentUtils.SetLightState(lightComponent, !lightComponent.IsActive, lightComponent.SelectedMode); GlobalEvents.RequestGlobalRedraw(); - } + }, }; // Switch mode yield return new() @@ -75,7 +75,7 @@ internal sealed class CustomInteractionsProvider : IItemCustomInteractionsProvid Icon = () => StaticIcons.GetAttributeIcon(EItemAttributeId.EncodeState), SubMenu = () => new LightModeSubMenu(uiContext, lightComponent), Enabled = () => lightComponent.GetModesCount() > 1, - Error = () => "This device has no alternative modes" + Error = () => "This device has no alternative modes", }; yield break; } @@ -95,7 +95,7 @@ internal class FireModeSubMenu : CustomSubInteractions Singleton.Instance.PlayUISound(EUISoundType.MenuContextMenu); ComponentUtils.SetFireMode(component, fireMode); }, - Enabled = () => fireMode != component.FireMode + Enabled = () => fireMode != component.FireMode, })); } } @@ -113,7 +113,7 @@ internal class LightModeSubMenu : CustomSubInteractions Singleton.Instance.PlayUISound(EUISoundType.MenuContextMenu); ComponentUtils.SetLightState(component, component.IsActive, lightMode); }, - Enabled = () => lightMode != component.SelectedMode + Enabled = () => lightMode != component.SelectedMode, })); } } @@ -126,14 +126,13 @@ internal static class ComponentUtils if (player is not null && player.HandsController is Player.FirearmController fc && component.Item == fc.Item) { - if (fc.Item.MalfState.State is not Weapon.EMalfunctionState.None) + if (fc.Item.MalfState.State is Weapon.EMalfunctionState.None) + fc.ChangeFireMode(fireMode); + else { fc.FirearmsAnimator.MisfireSlideUnknown(false); player.GetInventoryController().ExamineMalfunction(fc.Item, false); - return; } - - fc.ChangeFireMode(fireMode); return; } diff --git a/ItemSellPrice/ItemSellPrice.cs b/ItemSellPrice/ItemSellPrice.cs index 026d89b..2cfdbb0 100644 --- a/ItemSellPrice/ItemSellPrice.cs +++ b/ItemSellPrice/ItemSellPrice.cs @@ -55,7 +55,7 @@ internal static class ItemExtensions ["po"] = ["Preço de venda ({0})", "Não pode ser vendido a comerciantes"], ["ru"] = ["Цена продажи ({0})", "Невозможно продать торговцам"], ["sk"] = ["Predajná cena ({0})", "Nedá sa predať obchodníkom"], - ["tu"] = ["Satış fiyatı ({0})", "Tüccarlara satılamaz"] + ["tu"] = ["Satış fiyatı ({0})", "Tüccarlara satılamaz"], }; private static ISession _Session; @@ -95,7 +95,7 @@ internal static class ItemExtensions ? string.Join(Environment.NewLine, offers.Select(offer => $"{offer.Name}: {offer.Currency} {offer.Price}")) : ""; }, - DisplayType = () => EItemAttributeDisplayType.Compact + DisplayType = () => EItemAttributeDisplayType.Compact, }; item.Attributes = [attribute, .. item.Attributes]; } @@ -125,17 +125,12 @@ internal static class ItemExtensions { if (!Session.Profile.Examined(item)) return null; - switch (item.Owner?.OwnerType) + if (item.Owner?.OwnerType is EOwnerType.RagFair or EOwnerType.Trader + && (item.StackObjectsCount > 1 || item.UnlimitedCount)) { - case EOwnerType.RagFair: - case EOwnerType.Trader: - if (item.StackObjectsCount > 1 || item.UnlimitedCount) - { - item = item.CloneItem(); - item.StackObjectsCount = 1; - item.UnlimitedCount = false; - } - break; + item = item.CloneItem(); + item.StackObjectsCount = 1; + item.UnlimitedCount = false; } return Session.Traders .Select(trader => GetTraderOffer(item, trader)) diff --git a/MagazineInspector/MagazineInspector.cs b/MagazineInspector/MagazineInspector.cs index 85ded91..88f77bc 100644 --- a/MagazineInspector/MagazineInspector.cs +++ b/MagazineInspector/MagazineInspector.cs @@ -30,7 +30,7 @@ internal static class MagazineClassExtensions ["po"] = "Munição carregada", ["ru"] = "Заряженные боеприпасы", ["sk"] = "Nabitá munícia", - ["tu"] = "Yüklü mühimmat" + ["tu"] = "Yüklü mühimmat", }; private static ISession _Session; diff --git a/MunitionsExpert/Plugin.cs b/MunitionsExpert/Plugin.cs index 45f9dcf..bb9c918 100644 --- a/MunitionsExpert/Plugin.cs +++ b/MunitionsExpert/Plugin.cs @@ -30,7 +30,7 @@ public class Plugin : BaseUnityPlugin Config.Bind(COLORIZE, "Class 3", ColorName.Green, new ConfigurationManagerAttributes { Order = 3 }), Config.Bind(COLORIZE, "Class 4", ColorName.Yellow, new ConfigurationManagerAttributes { Order = 2 }), Config.Bind(COLORIZE, "Class 5", ColorName.Orange, new ConfigurationManagerAttributes { Order = 1 }), - Config.Bind(COLORIZE, "Class 6+", ColorName.Red, new ConfigurationManagerAttributes { Order = 0 }) + Config.Bind(COLORIZE, "Class 6+", ColorName.Red, new ConfigurationManagerAttributes { Order = 0 }), ]; new StaticIconsPatch().Enable(); new AmmoTemplatePatch().Enable(); @@ -107,8 +107,9 @@ internal class EntityIconPatch : ModulePatch { if (!Plugin.Colorize || item is not BulletClass bullet || bullet.PenetrationPower <= 0) return; + if (ColorPanelField.GetValue(__instance) is not Image image) + return; int armorClass = bullet.AmmoTemplate.GetPenetrationArmorClass(); - if (ColorPanelField.GetValue(__instance) is Image image) - image.color = Plugin.GetArmorClassColor(armorClass); + image.color = Plugin.GetArmorClassColor(armorClass); } }