Files
7d2dXG/Mods/0A-KFCommonUtilityLib/Scripts/Requirements/ItemInInventory.cs
Nathaniel Cosford 062dfab2cd Patched
2025-05-30 01:04:40 +09:30

34 lines
917 B
C#

using System.Xml.Linq;
public class ItemInInventory : RequirementBase
{
private string itemName;
private ItemValue itemValueCache = null;
public override bool IsValid(MinEventParams _params)
{
return base.IsValid(_params) && compareValues(_params.Self.GetItemCount(itemValueCache), operation, value) ^ invert;
}
public override bool ParamsValid(MinEventParams _params)
{
if (itemValueCache == null)
itemValueCache = ItemClass.GetItem(itemName);
return base.ParamsValid(_params) && itemValueCache != null;
}
public override bool ParseXAttribute(XAttribute _attribute)
{
if (base.ParseXAttribute(_attribute))
return true;
string name = _attribute.Name.LocalName;
if (name == "item")
{
itemName = _attribute.Value;
return true;
}
return false;
}
}