diff --git a/Plugin/Extensions/ItemExtensions.cs b/Plugin/Extensions/ItemExtensions.cs
index 32134af..6efcba7 100644
--- a/Plugin/Extensions/ItemExtensions.cs
+++ b/Plugin/Extensions/ItemExtensions.cs
@@ -10,7 +10,19 @@ namespace LootValueEX.Extensions
{
internal static class ItemExtensions
{
+ ///
+ /// Checks if an item has been examined by the player.
+ ///
+ /// The item to check.
+ /// True if the item has been examined, false otherwise.
internal static bool IsExamined(this Item? item) => item != null && ClientAppUtils.GetMainApp().GetClientBackEndSession().Profile.Examined(item);
+
+ ///
+ /// Retrieves the value of a specific attribute from an item.
+ ///
+ /// The item to retrieve the attribute from.
+ /// The ID of the attribute to retrieve.
+ /// The value of the attribute, or -1f if the item is null or the attribute is not found.
internal static float GetItemAttribute(this Item? item, EItemAttributeId attributeId)
{
if (item == null)
@@ -24,13 +36,24 @@ namespace LootValueEX.Extensions
return -1f;
}
}
+
+ ///
+ /// Generates a custom hash for the given item.
+ ///
+ /// This function takes an optional Item as a parameter and returns its custom hash.
+ /// If the item is null, it returns an empty string. The custom hash is determined by the item's template, durability, and uses.
+ ///
+ /// The item to retrieve the custom hash for.
+ /// The custom hash of the item, or an empty string if the item is null.
internal static string GetCustomHash(this Item? item)
{
if (item == null)
return string.Empty;
+
StringBuilder prehashString = new StringBuilder();
item.GetAllItems().Where(prop => !prop.Equals(item)).ExecuteForEach(prop => prehashString.Append(prop.GetCustomHash()));
- if (item.Template.Equals(typeof(MagazineTemplate))){
+ if (item.Template.Equals(typeof(MagazineTemplate)))
+ {
MagazineTemplate magTemplate = (MagazineTemplate)item.Template;
magTemplate.Cartridges.ExecuteForEach(prop => prop.Items.ExecuteForEach(ammo => prehashString.Append(ammo.GetCustomHash())));
}
@@ -43,7 +66,7 @@ namespace LootValueEX.Extensions
if (item == null)
return String.Empty;
- if (item.Attributes.IsNullOrEmpty())
+ if (item.Attributes.IsNullOrEmpty())
return String.Empty;
StringBuilder sb = new StringBuilder();
@@ -51,10 +74,21 @@ namespace LootValueEX.Extensions
return sb.ToString();
}
#endif
+
+
+ ///
+ /// Retrieves the durability of a given item.
+ ///
+ /// This function takes an optional Item as a parameter and returns its durability.
+ /// If the item is null, it returns -1f. The durability is determined by the item's template.
+ ///
+ /// The item to retrieve the durability for.
+ /// The durability of the item, or -1f if the item is null.
internal static float GetDurability(this Item? item)
{
if (item == null)
return -1f;
+
switch (item.Template)
{
case ArmoredRigTemplate armoredRig:
@@ -64,10 +98,21 @@ namespace LootValueEX.Extensions
return item.GetItemAttribute(EItemAttributeId.Durability);
}
}
+
+ ///
+ /// Retrieves the number of uses remaining for a given item.
+ ///
+ /// This function takes an optional Item as a parameter and returns the number of uses remaining.
+ /// If the item is null, it returns -1f. The number of uses is determined by the item's template.
+ ///
+ /// The item to retrieve the number of uses for.
+ /// The number of uses remaining for the item, or -1f if the item is null.
+
internal static float GetUses(this Item? item)
{
if (item == null)
return -1f;
+
switch (item.Template)
{
case KeycardTemplate:
@@ -79,10 +124,10 @@ namespace LootValueEX.Extensions
return -1f;
case MagazineTemplate:
MagazineClass? magazineClass = item as MagazineClass;
- return magazineClass != null ? magazineClass.Count : -1f;
+ return magazineClass?.Count ?? -1f;
case AmmoBoxTemplate:
AmmoBox? ammoBox = item as AmmoBox;
- return ammoBox != null ? ammoBox.Count : -1f;
+ return ammoBox?.Count ?? -1f;
default:
return -1f;
}