feat: added support to get item durability
This commit is contained in:
45
Plugin/Extensions/ItemExtensions.cs
Normal file
45
Plugin/Extensions/ItemExtensions.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using EFT.InventoryLogic;
|
||||
using SPT.Reflection.Utils;
|
||||
using System.Text;
|
||||
|
||||
namespace LootValueEX.Extensions
|
||||
{
|
||||
internal static class ItemExtensions
|
||||
{
|
||||
internal static bool IsExamined(this Item? item) => item != null && ClientAppUtils.GetMainApp().GetClientBackEndSession().Profile.Examined(item);
|
||||
internal static string CustomHash(this Item? item)
|
||||
{
|
||||
if (item == null)
|
||||
return string.Empty;
|
||||
|
||||
string itemHashTemplate = string.Format("{0}|{1}|{2}", item.TemplateId, item.StackMaxSize, item.StackObjectsCount);
|
||||
return "0";
|
||||
}
|
||||
internal static string AttributesToString(this Item? item)
|
||||
{
|
||||
if (item == null)
|
||||
return String.Empty;
|
||||
|
||||
if (item.Attributes.IsNullOrEmpty())
|
||||
return String.Empty;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
item.Attributes.ForEach(attr => sb.Append($"\n{attr.Id}\n\tName: {attr.Name}\n\tBase Value: {attr.Base()}\n\tString value: {attr.StringValue()}\n\tDisplay Type: {attr.DisplayType()}"));
|
||||
return sb.ToString();
|
||||
|
||||
}
|
||||
internal static float GetDurability(this Item? item)
|
||||
{
|
||||
if (item == null)
|
||||
return -1f;
|
||||
|
||||
try
|
||||
{
|
||||
return item.Attributes.Single(att => att.Id.Equals(EItemAttributeId.Durability)).Base();
|
||||
}catch(InvalidOperationException)
|
||||
{
|
||||
return -1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Plugin/Extensions/TarkovApplicationExtensions.cs
Normal file
8
Plugin/Extensions/TarkovApplicationExtensions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace LootValueEX.Extensions
|
||||
{
|
||||
internal static class TarkovApplicationExtensions
|
||||
{
|
||||
internal static IEnumerable<TraderClass> GetValidTraders(this EFT.TarkovApplication client) => client.GetClientBackEndSession().DisplayableTraders;
|
||||
internal static bool RagfairUnlocked(this EFT.TarkovApplication client) => client.Session.RagFair.Available;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user