This commit is contained in:
IcyClawz 2024-10-25 20:55:26 +03:00
parent 7183b28e8b
commit ec50b42dc7
4 changed files with 20 additions and 25 deletions

View File

@ -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<GUISounds>.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<GUISounds>.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<GUISounds>.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;
}

View File

@ -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))

View File

@ -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;

View File

@ -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);
}
}