Exemplo n.º 1
0
        public BuildingBlocks(AnvilWorld world, ModelData md, BuildingType buildingType)
        {
            BlockManager bm = world.GetBlockManager();
            ModelDataModel mdm = md.GetModelByTypeId((int)buildingType);

            if (mdm == null)
            {
                // This can happen until we have models for everything in the config file
                Height = 0;
                GroundLevelOffset = 0;
                return;
            }

            GroundLevelOffset = mdm.GroundLevelOffset;

            IntVector3 corner1 = new IntVector3();
            corner1.X = mdm.Corner1[0].x;
            corner1.Y = mdm.Corner1[0].y;
            corner1.Z = mdm.Corner1[0].z;

            IntVector3 corner2 = new IntVector3();
            corner2.X = mdm.Corner2[0].x;
            corner2.Y = mdm.Corner2[0].y;
            corner2.Z = mdm.Corner2[0].z;

            // Handle rotation
            /*
                * Block entities aren't drawing right.  We're flipping the Z-axis here which might be the cause..
                *
            blocks = new AlphaBlock[Math.Abs(corner1.X - corner2.X) + 1, Math.Abs(corner1.Y - corner2.Y) + 1, Math.Abs(corner1.Z - corner2.Z) + 1];

            for (int x = corner1.X; x <= corner2.X; x++)
            {
                for (int y = corner1.Y; y <= corner2.Y; y++)
                {
                    for (int z = 0; z <= Math.Abs(corner2.Z - corner1.Z); z++)
                    {
                        blocks[x - corner1.X, y - corner1.Y, z] = bm.GetBlock(x, y, corner2.Z - z);
                    }
                }
            }
            */

            blocks = new AlphaBlock[Math.Abs(corner1.X - corner2.X) + 1, Math.Abs(corner1.Y - corner2.Y) + 1, Math.Abs(corner1.Z - corner2.Z) + 1];

            for (int x = corner1.X; x <= corner2.X; x++)
            {
                for (int y = corner1.Y; y <= corner2.Y; y++)
                {
                    for (int z = corner1.Z; z <= corner2.Z; z++)
                    {
                        blocks[x - corner1.X, y - corner1.Y, z - corner1.Z] = bm.GetBlock(x, y, z);
                    }
                }
            }

            Height = Math.Abs(corner1.Y - corner2.Y) + 1;
        }