Add missing ammo attributes
This commit is contained in:
parent
0f7ee0b1e3
commit
ccad3d23d0
@ -31,7 +31,7 @@ internal static class ColorCache
|
|||||||
[ColorName.Silver] = new Color32(150, 150, 150, ALPHA),
|
[ColorName.Silver] = new Color32(150, 150, 150, ALPHA),
|
||||||
[ColorName.Tan] = new Color32(175, 145, 100, ALPHA),
|
[ColorName.Tan] = new Color32(175, 145, 100, ALPHA),
|
||||||
[ColorName.Violet] = new Color32(80, 50, 180, ALPHA),
|
[ColorName.Violet] = new Color32(80, 50, 180, ALPHA),
|
||||||
[ColorName.Yellow] = new Color32(170, 170, 0, ALPHA)
|
[ColorName.Yellow] = new Color32(170, 170, 0, ALPHA),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Color Get(ColorName name) => Cache.TryGetValue(name, out Color color) ? color : default;
|
public static Color Get(ColorName name) => Cache.TryGetValue(name, out Color color) ? color : default;
|
||||||
@ -60,7 +60,7 @@ internal static class IconCache
|
|||||||
{
|
{
|
||||||
[EAmmoExtraAttributeId.ArmorDamage] = Properties.Resources.ArmorDamage.ToSprite(),
|
[EAmmoExtraAttributeId.ArmorDamage] = Properties.Resources.ArmorDamage.ToSprite(),
|
||||||
[EAmmoExtraAttributeId.FragmentationChance] = Properties.Resources.FragmentationChance.ToSprite(),
|
[EAmmoExtraAttributeId.FragmentationChance] = Properties.Resources.FragmentationChance.ToSprite(),
|
||||||
[EAmmoExtraAttributeId.RicochetChance] = Properties.Resources.RicochetChance.ToSprite()
|
[EAmmoExtraAttributeId.RicochetChance] = Properties.Resources.RicochetChance.ToSprite(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Sprite Get(Enum id) => Cache.TryGetValue(id, out Sprite sprite) ? sprite : default;
|
public static Sprite Get(Enum id) => Cache.TryGetValue(id, out Sprite sprite) ? sprite : default;
|
||||||
@ -68,6 +68,15 @@ internal static class IconCache
|
|||||||
|
|
||||||
internal static class AmmoTemplateExtensions
|
internal static class AmmoTemplateExtensions
|
||||||
{
|
{
|
||||||
|
private static readonly float MaxMalfMisfireChance = (float)
|
||||||
|
typeof(AmmoTemplate).GetField("MaxMalfMisfireChance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
|
||||||
|
|
||||||
|
private static readonly float MaxMalfFeedChance = (float)
|
||||||
|
typeof(AmmoTemplate).GetField("MaxMalfFeedChance", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
|
||||||
|
|
||||||
|
private static readonly string[] MalfChancesKeys = (string[])
|
||||||
|
typeof(AmmoTemplate).GetField("MalfChancesKeys", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
|
||||||
|
|
||||||
private static readonly FieldInfo CachedQualitiesField =
|
private static readonly FieldInfo CachedQualitiesField =
|
||||||
typeof(AmmoTemplate).GetField("_cachedQualities", BindingFlags.NonPublic | BindingFlags.Instance);
|
typeof(AmmoTemplate).GetField("_cachedQualities", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
@ -82,7 +91,27 @@ internal static class AmmoTemplateExtensions
|
|||||||
DisplayNameFunc = () => "Armor damage",
|
DisplayNameFunc = () => "Armor damage",
|
||||||
Base = () => instance.ArmorDamage,
|
Base = () => instance.ArmorDamage,
|
||||||
StringValue = () => $"{instance.ArmorDamage}%",
|
StringValue = () => $"{instance.ArmorDamage}%",
|
||||||
DisplayType = () => EItemAttributeDisplayType.Compact
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EItemAttributeId.DurabilityBurn)
|
||||||
|
{
|
||||||
|
Name = EItemAttributeId.DurabilityBurn.GetName(),
|
||||||
|
Base = () => instance.DurabilityBurnModificator - 1f,
|
||||||
|
StringValue = () => $"{(instance.DurabilityBurnModificator - 1f) * 100f:F1}%",
|
||||||
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
|
LabelVariations = EItemAttributeLabelVariations.Colored,
|
||||||
|
LessIsGood = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EItemAttributeId.HeatFactor)
|
||||||
|
{
|
||||||
|
Name = EItemAttributeId.HeatFactor.GetName(),
|
||||||
|
Base = () => instance.HeatFactor - 1f,
|
||||||
|
StringValue = () => $"{(instance.HeatFactor - 1f) * 100f:F1}%",
|
||||||
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
|
LabelVariations = EItemAttributeLabelVariations.Colored,
|
||||||
|
LessIsGood = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.SafelyAddQualityToList(new ItemAttributeClass(EAmmoExtraAttributeId.FragmentationChance)
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EAmmoExtraAttributeId.FragmentationChance)
|
||||||
@ -90,8 +119,8 @@ internal static class AmmoTemplateExtensions
|
|||||||
Name = EAmmoExtraAttributeId.FragmentationChance.ToString(),
|
Name = EAmmoExtraAttributeId.FragmentationChance.ToString(),
|
||||||
DisplayNameFunc = () => "Fragmentation chance",
|
DisplayNameFunc = () => "Fragmentation chance",
|
||||||
Base = () => instance.FragmentationChance,
|
Base = () => instance.FragmentationChance,
|
||||||
StringValue = () => $"{Math.Round(instance.FragmentationChance * 100, 1)}%",
|
StringValue = () => $"{instance.FragmentationChance * 100f:F1}%",
|
||||||
DisplayType = () => EItemAttributeDisplayType.Compact
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.SafelyAddQualityToList(new ItemAttributeClass(EAmmoExtraAttributeId.RicochetChance)
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EAmmoExtraAttributeId.RicochetChance)
|
||||||
@ -99,8 +128,56 @@ internal static class AmmoTemplateExtensions
|
|||||||
Name = EAmmoExtraAttributeId.RicochetChance.ToString(),
|
Name = EAmmoExtraAttributeId.RicochetChance.ToString(),
|
||||||
DisplayNameFunc = () => "Ricochet chance",
|
DisplayNameFunc = () => "Ricochet chance",
|
||||||
Base = () => instance.RicochetChance,
|
Base = () => instance.RicochetChance,
|
||||||
StringValue = () => $"{Math.Round(instance.RicochetChance * 100, 1)}%",
|
StringValue = () => $"{(instance.RicochetChance * 100f):F1}%",
|
||||||
DisplayType = () => EItemAttributeDisplayType.Compact
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EItemAttributeId.MalfMisfireChance)
|
||||||
|
{
|
||||||
|
Name = EItemAttributeId.MalfMisfireChance.GetName(),
|
||||||
|
Base = () => instance.MalfMisfireChance,
|
||||||
|
StringValue = () =>
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (instance.MalfMisfireChance <= 0f)
|
||||||
|
value = MalfChancesKeys[0];
|
||||||
|
else if (instance.MalfMisfireChance < 3f * MaxMalfMisfireChance / 7f)
|
||||||
|
value = MalfChancesKeys[1];
|
||||||
|
else if (instance.MalfMisfireChance < 4f * MaxMalfMisfireChance / 7f)
|
||||||
|
value = MalfChancesKeys[2];
|
||||||
|
else if (instance.MalfMisfireChance < 5f * MaxMalfMisfireChance / 7f)
|
||||||
|
value = MalfChancesKeys[3];
|
||||||
|
else if (instance.MalfMisfireChance < 6f * MaxMalfMisfireChance / 7f)
|
||||||
|
value = MalfChancesKeys[4];
|
||||||
|
else
|
||||||
|
value = MalfChancesKeys[5];
|
||||||
|
return value.Localized();
|
||||||
|
},
|
||||||
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.SafelyAddQualityToList(new ItemAttributeClass(EItemAttributeId.MalfFeedChance)
|
||||||
|
{
|
||||||
|
Name = EItemAttributeId.MalfFeedChance.GetName(),
|
||||||
|
Base = () => instance.MalfFeedChance,
|
||||||
|
StringValue = () =>
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (instance.MalfFeedChance <= 0f)
|
||||||
|
value = MalfChancesKeys[0];
|
||||||
|
else if (instance.MalfFeedChance < 1f * MaxMalfFeedChance / 7f)
|
||||||
|
value = MalfChancesKeys[1];
|
||||||
|
else if (instance.MalfFeedChance < 3f * MaxMalfFeedChance / 7f)
|
||||||
|
value = MalfChancesKeys[2];
|
||||||
|
else if (instance.MalfFeedChance < 5f * MaxMalfFeedChance / 7f)
|
||||||
|
value = MalfChancesKeys[3];
|
||||||
|
else if (instance.MalfFeedChance < 6f * MaxMalfFeedChance / 7f)
|
||||||
|
value = MalfChancesKeys[4];
|
||||||
|
else
|
||||||
|
value = MalfChancesKeys[5];
|
||||||
|
return value.Localized();
|
||||||
|
},
|
||||||
|
DisplayType = () => EItemAttributeDisplayType.Compact,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<AssemblyName>IcyClawz.MunitionsExpert</AssemblyName>
|
<AssemblyName>IcyClawz.MunitionsExpert</AssemblyName>
|
||||||
<Version>1.4.0</Version>
|
<Version>1.4.1</Version>
|
||||||
<RootNamespace>IcyClawz.MunitionsExpert</RootNamespace>
|
<RootNamespace>IcyClawz.MunitionsExpert</RootNamespace>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -13,7 +13,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
namespace IcyClawz.MunitionsExpert;
|
namespace IcyClawz.MunitionsExpert;
|
||||||
|
|
||||||
[BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.4.0")]
|
[BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.4.1")]
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
private static ConfigEntry<bool> ColorizeSwitch { get; set; }
|
private static ConfigEntry<bool> ColorizeSwitch { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user