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

namespace Halo3Map.Data
{
    public class StringID : Chunk
    {
        #region Layout
        public int Index;
        #endregion

        public StringID(EndianReader br, Map.Map Map)
        {
            Read(br);
        }

        public override void Read(EndianReader br)
        {
            base.Read(br);
        }
    }
    /// <summary>
    /// Provides functions to Read and Write Halo 3 Tag References
    /// </summary>
    public class TagReference : Chunk
    {
        //Specifies the layout of a Halo3 TagReference we can read it
        #region Layout
        /// <summary>
        /// Specifies type of tag being referenced
        /// </summary>
        public string TagClass;
        /// <summary>
        /// Unknown 8 Byte block of data
        /// </summary>
        [Size(8)]
        public byte[] Unknown;
        /// <summary>
        /// Specifies Identifier used to identify Tag being referenced
        /// </summary>
        public short Ident;
        /// <summary>
        /// Specifies the Index in the Tag table of the tag being referenced
        /// </summary>
        public short Index;
        #endregion
        /// <summary>
        /// Creates a new instance of TagReference
        /// </summary>
        public TagReference() { }
        /// <summary>
        /// Creates a new instance of TagReference and reads chunk structure
        /// </summary>
        /// <param name="br">Stream to read from</param>
        public TagReference(EndianReader br)
        {
            Read(br);
        }
        /// <summary>
        /// Reads TagReference Chunk structure from stream
        /// </summary>
        /// <param name="br">Stream to read from</param>
        public override void Read(EndianReader br)
        {
            //Read Tag Class as char array and create a new string
            TagClass = new string(br.ReadChars(4));
            //Read Unknown Data
            Unknown = br.ReadBytes(8);
            //Read Ident
            Ident = br.ReadInt16();
            //Read Index
            Index = br.ReadInt16();
        }
        /// <summary>
        /// Writes TagReference Chunk structure to stream
        /// </summary>
        /// <param name="bw">Stream to write to</param>
        public void Write(EndianWriter bw)
        {
            //Write Tag Class as a Char Array
            bw.Write(TagClass.ToCharArray());
            //Write Unknown Data
            bw.Write(Unknown);
            //Write Ident
            bw.Write(Ident);
            //Write Index
            bw.Write(Index);
        }
    }
}