Example #1
0
    public static void AddBlockRepresentation(IPlanable s, Plane basement, ref Block myBlock, bool checkPlanes)
    {
        var      chunk = basement.myChunk;
        ChunkPos cpos  = basement.pos;

        switch (basement.faceIndex)
        {
        case Block.FWD_FACE_INDEX: cpos = cpos.OneBlockForward(); break;

        case Block.RIGHT_FACE_INDEX: cpos = cpos.OneBlockRight(); break;

        case Block.BACK_FACE_INDEX: cpos = cpos.OneBlockBack(); break;

        case Block.LEFT_FACE_INDEX: cpos = cpos.OneBlockLeft(); break;

        case Block.UP_FACE_INDEX: cpos = cpos.OneBlockHigher(); break;

        case Block.DOWN_FACE_INDEX: cpos = cpos.OneBlockDown(); break;
        }
        myBlock = chunk.AddBlock(cpos, s, false, checkPlanes);
        if (myBlock == null)
        {
            s.Delete(true, true, false);
            return;
        }
        else
        {
            chunk.RecalculateVisibilityAtPoint(myBlock.pos, s.GetAffectionMask());
        }
    }
Example #2
0
    public static void AddBlockRepresentation(IPlanable s, Plane basement, ref Block myBlock, bool checkPlanes)
    {
        var      chunk = basement.myChunk;
        ChunkPos cpos  = basement.pos;

        switch (basement.faceIndex)
        {
        case Block.FWD_FACE_INDEX: cpos = cpos.OneBlockForward(); break;

        case Block.RIGHT_FACE_INDEX: cpos = cpos.OneBlockRight(); break;

        case Block.BACK_FACE_INDEX: cpos = cpos.OneBlockBack(); break;

        case Block.LEFT_FACE_INDEX: cpos = cpos.OneBlockLeft(); break;

        case Block.UP_FACE_INDEX: cpos = cpos.OneBlockHigher(); break;

        case Block.DOWN_FACE_INDEX: cpos = cpos.OneBlockDown(); break;
        }
        myBlock = chunk.AddBlock(cpos, s, false, checkPlanes);
        if (myBlock == null)
        {
            s.Delete(BlockAnnihilationOrder.ManualCreationError);
            Debug.LogException(new System.Exception("new IPlanable block cannot be created"));
            return;
        }
        else
        {
            chunk.RecalculateVisibilityAtPoint(myBlock.pos, s.GetAffectionMask());
        }
    }