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

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;
}