public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { TagDataNode childNode = GetChild(container, Name); T data = LookupTag <T>(container, Name); if (data == null) { return(false); } switch (Operator) { case NumericOperator.Equals: if (data.ToTagDouble() != Value) { return(false); } break; case NumericOperator.NotEquals: if (data.ToTagDouble() == Value) { return(false); } break; case NumericOperator.GreaterThan: if (data.ToTagDouble() <= Value) { return(false); } break; case NumericOperator.LessThan: if (data.ToTagDouble() >= Value) { return(false); } break; case NumericOperator.Any: break; default: return(false); } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); }
public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { foreach (var rule in Rules) { if (!rule.Matches(container, matchedNodes)) { return(false); } } return(true); }
protected static TagDataNode GetChild(TagCompoundDataNode container, string name) { foreach (var child in container.Nodes) { TagDataNode tagChild = child as TagDataNode; if (tagChild != null && tagChild.NodeName == name) { return(tagChild); } } return(null); }
private void ReplaceCurrent() { TagCompoundDataNode node = _currentFindNode as TagCompoundDataNode; if (node == null) { return; } List <TagDataNode> matches = new List <TagDataNode>(); _findController.Root.Matches(node, matches); List <string> replaceNames = new List <string>(); foreach (DataNode rnode in _replaceController.Root.Nodes) { replaceNames.Add(rnode.NodeName); } foreach (var replNode in matches) { if (_deleteTagsCheckbox.Checked || replaceNames.Contains(replNode.NodeName)) { replNode.DeleteNode(); } } foreach (TagDataNode tag in _replaceController.Root.Nodes) { if (tag == null) { continue; } node.NamedTagContainer.AddTag(tag.Tag, tag.NodeName); node.SyncTag(); } _mainController.RefreshTreeNode(node); }
public bool TestNode(DataNode node) { if (RuleTags == null) { return(false); } TagCompoundDataNode tagNode = node as TagCompoundDataNode; if (tagNode == null) { return(false); } List <TagDataNode> matches = new List <TagDataNode>(); if (!RuleTags.Matches(tagNode, matches)) { return(false); } return(true); }
public virtual bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { return(false); }
public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { TagDataNode childNode = GetChild(container, Name); TagNode tag = container.NamedTagContainer.GetTagNode(Name); if (tag == null) { return(false); } try { switch (tag.GetTagType()) { case TagType.TAG_BYTE: case TagType.TAG_INT: case TagType.TAG_LONG: case TagType.TAG_SHORT: switch (Operator) { case WildcardOperator.Equals: if (long.Parse(Value) != tag.ToTagLong()) { return(false); } break; case WildcardOperator.NotEquals: if (long.Parse(Value) == tag.ToTagLong()) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); case TagType.TAG_FLOAT: case TagType.TAG_DOUBLE: switch (Operator) { case WildcardOperator.Equals: if (double.Parse(Value) != tag.ToTagDouble()) { return(false); } break; case WildcardOperator.NotEquals: if (double.Parse(Value) == tag.ToTagDouble()) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); case TagType.TAG_STRING: switch (Operator) { case WildcardOperator.Equals: if (Value != tag.ToTagString().Data) { return(false); } break; case WildcardOperator.NotEquals: if (Value == tag.ToTagString().Data) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); } } catch { } return(false); }
public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { TagDataNode childNode = GetChild(container, Name); TagNodeString data = LookupTag <TagNodeString>(container, Name); if (data == null) { return(false); } switch (Operator) { case StringOperator.Equals: if (data.ToTagString().Data != Value) { return(false); } break; case StringOperator.NotEquals: if (data.ToTagString().Data == Value) { return(false); } break; case StringOperator.Contains: if (!data.ToTagString().Data.Contains(Value)) { return(false); } break; case StringOperator.NotContains: if (data.ToTagString().Data.Contains(Value)) { return(false); } break; case StringOperator.StartsWith: if (!data.ToTagString().Data.StartsWith(Value)) { return(false); } break; case StringOperator.EndsWith: if (!data.ToTagString().Data.EndsWith(Value)) { return(false); } break; case StringOperator.Any: break; default: return(false); } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); }
protected T LookupTag <T> (TagCompoundDataNode container, string name) where T : TagNode { return(container.NamedTagContainer.GetTagNode(name) as T); }
internal BlockEntity(TagCompoundDataNode nbt) => NBT = nbt.Get <TagListDataNode>("Items");