csharp/1upD/Nails/NailsLib/Data/NailsCube.cs

NailsCube.cs
using System.Collections.Generic;

namespace NailsLib.Data
{
    /*
     * 
     * The NailsCube clast models a single data point in a Nails map. It contains information about the style being used in at that space in the map as well as what instances are to be inserted.
     * Walls, ceilings, and floors will be stored separately from other instances so that they can be more quickly rebuilt using convolution.
     * 1upD
     * 
     */
    public clast NailsCube
    {
        public string StyleName { get { return this._styleName; } set { this._styleName = value; } }
        private string _styleName;
        private int _faces;
        private int _x;
        private int _y;
        private int _z;

        public int X { get { return this._x; } }
        public int Y { get { return this._y; } }
        public int Z { get { return this._z; } }

        /**
         * Constructor takes three arguments for the position.
         * 1upD
         */
        public NailsCube(int x, int y, int z)
        {
            this._x = x;
            this._y = y;
            this._z = z;
        }



        /**
        * 
        * Applies a style to this cube.
        * 1upD
        * 
        */
        public void ApplyStyle(string styleName)
        {
            this._styleName = styleName;
        }

        /**
         * 
         * RebuildFaces takes a NailsMap and looks at the cubes adjacent to this cube
         * to determine which faces of the cube need to be 'filled in'.
         * 1upD
         * 
         */
        public void RebuildFaces(NailsMap nailsMap)
        {
            this._faces = 0;

            if(nailsMap.GetCube(this._x, this._y, this._z - 1) != null)
            {
                this._faces += (int)NailsCubeFace.Floor;   
            }

            if (nailsMap.GetCube(this._x + 1, this._y, this._z) != null)
            {
                this._faces += (int)NailsCubeFace.Front;
            }

            if (nailsMap.GetCube(this._x, this._y + 1, this._z) != null)
            {
                this._faces += (int)NailsCubeFace.Left;
            }

            if (nailsMap.GetCube(this._x - 1, this._y, this._z) != null)
            {
                this._faces += (int)NailsCubeFace.Back;
            }

            if (nailsMap.GetCube(this._x, this._y - 1, this._z) != null)
            {
                this._faces += (int)NailsCubeFace.Right;
            }

            if (nailsMap.GetCube(this._x, this._y, this._z + 1) != null)
            {
                this._faces += (int)NailsCubeFace.Ceiling;
            }

        }

        /**
         * 
         * Return a list of enumerated values representing the faces of the cube that should be 'filled in'.
         * 1upD
         * 
         */
        public List GetFaces()
        {
            List newList = new List();
            for(int i = 1; i