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

namespace HaloPlugins
{
    public class Point2d : IMetaNode
    {
        short x = 0, y = 0;
        string Name = "Point2d";

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

        #region MetaNode Members

        public void Read(EndianReader br)
        {
            x = br.ReadInt16();
            y = br.ReadInt16();
        }

        public void Read(EndianReader br, int Magic)
        {
            x = br.ReadInt16();
            y = br.ReadInt16();
        }

        public void Write(EndianWriter bw)
        {
            bw.Write(x);
            bw.Write(y);
        }

        public object GetValue()
        {
            return new object[] { x, y };
        }

        public void SetValue(object Value)
        {
            x = (short)((object[])Value)[0];
            y = (short)((object[])Value)[1];
        }

        public int GetSize()
        {
            return 4;
        }

        public void Compile(EndianWriter bw, int Magic)
        {
            bw.Write(x);
            bw.Write(y);
        }

        public void Decompile(EndianWriter bw, int Magic)
        {
            bw.Write(x);
            bw.Write(y);
        }

        public string GetName()
        {
            return Name;
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            Point2d p = new Point2d(this.Name);
            p.x = this.x;
            p.y = this.y;
            return p;
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            return "Point2d: " + Name + ", X: " + x.ToString() + ", Y: " + y.ToString();
        }

        #endregion
    }
}
