67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Xml.Linq;
|
|
|
|
public class IsAttachedToEntitySDX : TargetedCompareRequirementBase
|
|
{
|
|
|
|
public override bool IsValid(MinEventParams _params)
|
|
{
|
|
if (!base.IsValid(_params))
|
|
{
|
|
return false;
|
|
}
|
|
Entity vehicle;
|
|
EntityAlive me = _params.Self;
|
|
|
|
bool hasTags = false;
|
|
|
|
bool attachedToEntity = me.AttachedToEntity != null;
|
|
|
|
if (attachedToEntity)
|
|
{
|
|
vehicle = me.AttachedToEntity;
|
|
hasTags = vehicle.HasAnyTags(this.tagsToCompare);
|
|
//Log.Out("IsAttachedToEntitySDX-hasTags (Vehicle): " + vehicle.EntityTags);
|
|
}
|
|
|
|
//Log.Out("IsAttachedToEntitySDX-attachedToEntity: " + attachedToEntity);
|
|
|
|
if (!this.invert)
|
|
{
|
|
return hasTags && attachedToEntity;
|
|
}
|
|
return (!hasTags && attachedToEntity);
|
|
}
|
|
|
|
public override bool ParseXAttribute(XAttribute _attribute)
|
|
{
|
|
bool flag = base.ParseXAttribute(_attribute);
|
|
if (!flag)
|
|
{
|
|
string name = _attribute.Name.LocalName;
|
|
if (name != null)
|
|
{
|
|
if (name == "tags")
|
|
{
|
|
this.tagsToCompare = FastTags<TagGroup.Global>.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
}
|
|
if (name != null && name == "target")
|
|
{
|
|
this.targetType = EnumUtils.Parse<TargetedCompareRequirementBase.TargetTypes>(_attribute.Value, true);
|
|
return true;
|
|
}
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
public override void GetInfoStrings(ref List<string> list)
|
|
{
|
|
list.Add(string.Format("Is {0}Attached To Entity", this.invert ? "NOT " : ""));
|
|
}
|
|
|
|
private FastTags<TagGroup.Global> tagsToCompare;
|
|
|
|
}
|