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

namespace HaloPlugins
{
    public enum HaloEngine
    {
        Neutral,
        Halo1,
        Halo2,
        Halo3
    }

    public enum FieldState
    {
        None,
        Compiled,
        Decompiled
    }

    public interface IMetaNode : ICloneable
    {
        void Read(EndianReader br);
        void Read(EndianReader br, int Magic);
        void Write(EndianWriter bw);

        object GetValue();
        void SetValue(object Value);

        int GetSize();

        void Compile(EndianWriter bw, int Magic);
        void Decompile(EndianWriter bw, int Magic);

        string GetName();
    }

    public abstract class MetaNode : ICloneable
    {
        #region Fields

        /// <summary>
        /// Gets or sets the name of the field.
        /// </summary>
        public virtual string Name { get; set; }
        /// <summary>
        /// Gets or sets the size of the field.
        /// </summary>
        public virtual int Size { get; set; }
        /// <summary>
        /// Gets or sets the engine version this field corresponds to.
        /// </summary>
        public virtual HaloEngine Version { get; set; }
        /// <summary>
        /// Gets or sets the state of the field.
        /// </summary>
        public virtual FieldState State { get; set; }
        /// <summary>
        /// Gets or sets the value of this field.
        /// </summary>
        public virtual object Value { get; set; }

        #endregion

        #region Constructor

        public MetaNode(string Name, HaloEngine Version, FieldState State, object Value)
        {
            // Set fields
            this.Name = Name;
            this.Version = Version;
            this.State = State;
            this.Value = Value;
        }

        #endregion

        #region Functions

        public virtual void Read(EndianReader br, int Magic = 0){}

        #endregion

        #region ICloneable Members

        public virtual object Clone()
        {
            return null;
        }

        #endregion
    }
}
