using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic;
using IO;

namespace HaloPlugins
{
    public class Tag : IMetaNode
    {
        string Name = "Tag", TagType = "";

        public Tag(string Name)
        {
            this.Name = Name;
        }

        #region MetaNode Members

        public void Read(EndianReader br)
        {
            TagType = Strings.StrReverse(new string(br.ReadChars(4)));
        }

        public void Read(EndianReader br, int Magic)
        {
            TagType = Strings.StrReverse(new string(br.ReadChars(4)));
        }

        public void Write(EndianWriter bw)
        {
            bw.Write(Strings.StrReverse(TagType).ToCharArray());
        }

        public object GetValue()
        {
            return TagType;
        }

        public void SetValue(object Value)
        {
            TagType = (string)Value;
        }

        public int GetSize()
        {
            return 4;
        }

        public void Compile(EndianWriter bw, int Magic)
        {
            bw.Write(Strings.StrReverse(TagType).ToCharArray());
        }

        public void Decompile(EndianWriter bw, int Magic)
        {
            bw.Write(Strings.StrReverse(TagType).ToCharArray());
        }

        public string GetName()
        {
            return Name;
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            Tag t = new Tag(this.Name);
            t.TagType = this.TagType;
            return t;
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            return "Tag: " + Name + ", Tag: " + TagType;
        }

        #endregion
    }
}
