61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using System.Globalization;
|
|
using System.Xml.Linq;
|
|
|
|
public class HasBonusSpecific : TargetedCompareRequirementBase
|
|
{
|
|
|
|
public override bool IsValid(MinEventParams _params)
|
|
{
|
|
//Log.Out("HasBonusSpecific-IsValid START");
|
|
if (!base.IsValid(_params))
|
|
{
|
|
return false;
|
|
}
|
|
EntityAlive me = _params.Self;
|
|
|
|
bool flag = false;
|
|
|
|
ItemValue itemValue = _params.ItemValue;
|
|
|
|
if (itemValue != null && itemValue.ItemClass != null)
|
|
{
|
|
if (itemValue != null &&
|
|
itemValue.HasMetadata("bonus") &&
|
|
itemValue.HasMetadata("level") &&
|
|
itemValue.HasMetadata("type") &&
|
|
itemValue.HasMetadata("active"))
|
|
{
|
|
if (bonus == (string)itemValue.GetMetadata("bonus") &&
|
|
level == (int)itemValue.GetMetadata("level"))
|
|
{
|
|
flag = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return flag;
|
|
}
|
|
|
|
public override bool ParseXAttribute(XAttribute _attribute)
|
|
{
|
|
string localName = _attribute.Name.LocalName;
|
|
if (localName == "bonus")
|
|
{
|
|
bonus = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (localName == "level")
|
|
{
|
|
level = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected string bonus;
|
|
protected int level;
|
|
}
|