Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a new TextureID based on a byte array representation of another TextureID.
        /// Generate byte array by using TextureID.ToBytes().
        /// </summary>
        /// <param name="textureIdBytes">Byte array to convert to new TextureID.</param>
        public TextureID(byte[] textureIdBytes)
        {
            Folder  = TextureID.Parse(textureIdBytes).Folder;
            CardNum = TextureID.Parse(textureIdBytes).CardNum;

            if ((Folder.Length > 4) || (Folder.Length < 1))
            {
                throw new ArgumentOutOfRangeException("Folder id is out of range. Must be of length (0,4]");
            }
            if (CardNum > 999 || CardNum < 0)
            {
                throw new ArgumentOutOfRangeException("CardNum is out of range. Must be in [0,999]");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a new TextureID based on a raw byte array representation of a NetWrapper (Action object).
        /// </summary>
        /// <param name="raw">Raw byte array to convert to new TextureID.</param>
        /// <param name="startingIndex">The (0-based) position in the array of the first byte of the payload.</param>
        public TextureID(byte[] raw, int startingIndex)
        {
            byte[] textureIdBytes = new byte[7];
            Array.Copy(raw, startingIndex, textureIdBytes, 0, textureIdBytes.Length);

            Folder  = TextureID.Parse(textureIdBytes).Folder;
            CardNum = TextureID.Parse(textureIdBytes).CardNum;

            if ((Folder.Length > 4) || (Folder.Length < 1))
            {
                throw new ArgumentOutOfRangeException("Folder id is out of range. Must be of length (0,4]");
            }
            if (CardNum > 999 || CardNum < 0)
            {
                throw new ArgumentOutOfRangeException("CardNum is out of range. Must be in [0,999]");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a new TextureID object generated from a byte array representation of a TextureID.
        /// </summary>
        /// <param name="textureIdBytes">Byte array to convert to new TextureID.</param>
        /// <returns>Returns a new TextureID object generated from a byte array representation of a TextureID.</returns>
        public static TextureID Parse(byte[] textureIdBytes)
        {
            ASCIIEncoding encoder = new ASCIIEncoding();

            return(TextureID.Parse(encoder.GetString(textureIdBytes)));
        }