An abstract base class representing a node in an NBT tree.
예제 #1
0
        public override bool DataEqual(Tag tag)
        {
            TagByteArray tagArray = tag as TagByteArray;
            if (tagArray == null)
                return false;

            byte[] arr1 = Data;
            byte[] arr2 = tagArray.Data;

            if (arr1 == arr2)
                return true;
            if (arr1 == null || arr2 == null)
                return false;

            if (arr1.Length != arr2.Length)
                return false;

            for (int i = 0, n = arr1.Length; i < n; i++)
                if (arr1[i] != arr2[i])
                    return false;

            return true;
        }
예제 #2
0
파일: TagFloat.cs 프로젝트: jaquadro/NNBT
 public override bool DataEqual(Tag tag)
 {
     return (tag is TagFloat) ? Data == (tag as TagFloat).Data : false;
 }
예제 #3
0
파일: TagString.cs 프로젝트: jaquadro/NNBT
 public override bool DataEqual(Tag tag)
 {
     return (tag is TagString) ? Data == (tag as TagString).Data : false;
 }
예제 #4
0
파일: Tag.cs 프로젝트: jaquadro/NNBT
 public virtual bool DataEqual(Tag tag)
 {
     return false;
 }
예제 #5
0
파일: NbtMerge.cs 프로젝트: jaquadro/NNBT
 public ChangeOperation(Tag value)
 {
     _value = value;
 }
예제 #6
0
파일: NbtMerge.cs 프로젝트: jaquadro/NNBT
 private static DiffOperation DiffValue(Tag first, Tag second)
 {
     if (first == null && second == null)
         return null;
     else if (second == null)
         return new RemoveOperation();
     else if (first == null)
         return new ChangeOperation(second);
     else if (first.TagType != second.TagType)
         return new ChangeOperation(second);
     else {
         switch (first.TagType) {
             case TagType.Byte:
             case TagType.Short:
             case TagType.Int:
             case TagType.Long:
             case TagType.Float:
             case TagType.Double:
             case TagType.String:
             case TagType.ByteArray:
             case TagType.IntArray:
                 return first.DataEqual(second) ? null : new ChangeOperation(second);
             case TagType.Compound:
                 CompoundDiff compDiff = Diff(first as TagCompound, second as TagCompound);
                 return compDiff.IsEmpty ? null : new ChangeObjectOperation(compDiff);
             case TagType.List:
                 if (AreIdArrays(first as TagList, second as TagList)) {
                     CompoundDiff subDiff = IdDiff(first as TagList, second as TagList);
                     return subDiff.IsEmpty ? null : new ChangeIdArrayOperation(subDiff);
                 }
                 else {
                     ListDiff subDiff = PositionDiff(first as TagList, second as TagList);
                     return subDiff.IsEmpty ? null : new ChangePositionArrayOperation(subDiff);
                 }
             default:
                 throw new Exception("Unexpected tag type");
         }
     }
 }
예제 #7
0
파일: NbtMerge.cs 프로젝트: jaquadro/NNBT
        public static Tag GetId(Tag tag)
        {
            if (tag is TagCompound) {
                TagCompound ctag = tag as TagCompound;
                foreach (var kv in ctag) {
                    if (_pattern.IsMatch(kv.Key))
                        return kv.Value;
                }
            }
            if (tag is TagString)
                return tag;

            return null;
        }
예제 #8
0
 public override bool DataEqual(Tag tag)
 {
     return((tag is TagByte) ? Data == (tag as TagByte).Data : false);
 }