An abstract base class representing a node in an NBT tree.
Esempio n. 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;
        }
Esempio n. 2
0
 public override bool DataEqual(Tag tag)
 {
     return (tag is TagFloat) ? Data == (tag as TagFloat).Data : false;
 }
Esempio n. 3
0
 public override bool DataEqual(Tag tag)
 {
     return (tag is TagString) ? Data == (tag as TagString).Data : false;
 }
Esempio n. 4
0
File: Tag.cs Progetto: jaquadro/NNBT
 public virtual bool DataEqual(Tag tag)
 {
     return false;
 }
Esempio n. 5
0
 public ChangeOperation(Tag value)
 {
     _value = value;
 }
Esempio n. 6
0
 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");
         }
     }
 }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
 public override bool DataEqual(Tag tag)
 {
     return((tag is TagByte) ? Data == (tag as TagByte).Data : false);
 }