Ejemplo n.º 1
0
    public IEnumerable <GeneratedVoxelDesignation> GetUniqueVariants()
    {
        GeneratedVoxelDesignation rotated      = GetRotated(1, false);
        GeneratedVoxelDesignation rotatedTwice = rotated.GetRotated(2, false);

        GeneratedVoxelDesignation flipped             = GetFlipped();
        GeneratedVoxelDesignation flippedRotated      = flipped.GetRotated(1, true);
        GeneratedVoxelDesignation flippedRotatedTwice = flippedRotated.GetRotated(2, true);

        GeneratedVoxelDesignation[] rawVariants = new GeneratedVoxelDesignation[]
        {
            rotated,
            rotatedTwice,
            rotatedTwice.GetRotated(3, false),

            flipped,
            flippedRotated,
            flippedRotatedTwice,
            flippedRotatedTwice.GetRotated(3, true)
        };

        HashSet <string> uniquenessCheck = new HashSet <string>
        {
            ToString()
        };

        foreach (GeneratedVoxelDesignation rawVariant in rawVariants)
        {
            if (uniquenessCheck.Add(rawVariant.ToString()))
            {
                yield return(rawVariant);
            }
        }
    }
Ejemplo n.º 2
0
    public GeneratedVoxelDesignation GetFlipped()
    {
        GeneratedVoxelDesignation ret = new GeneratedVoxelDesignation(true, 0);

        for (int y = 0; y < 2; y++)
        {
            for (int z = 0; z < 2; z++)
            {
                bool left  = Description[0, y, z];
                bool right = Description[1, y, z];
                ret.Description[0, y, z] = right;
                ret.Description[1, y, z] = left;
            }
        }
        return(ret);
    }
Ejemplo n.º 3
0
    public GeneratedVoxelDesignation GetRotated(int rotationCount, bool wasFlipped)
    {
        GeneratedVoxelDesignation ret = new GeneratedVoxelDesignation(wasFlipped, rotationCount);

        for (int y = 0; y < 2; y++)
        {
            bool one   = Description[0, y, 0];
            bool two   = Description[1, y, 0];
            bool three = Description[1, y, 1];
            bool four  = Description[0, y, 1];

            ret.Description[0, y, 0] = two;
            ret.Description[1, y, 0] = three;
            ret.Description[1, y, 1] = four;
            ret.Description[0, y, 1] = one;
        }
        return(ret);
    }