Example #1
0
        public static SchematicBlock[,,] GetBlocks(RawSchematic rawSchematic)
        {
            //Sorted by height (bottom to top) then length then width -- the index of the block at X,Y,Z is (Y×length + Z)×width + X.
            SchematicBlock[,,] blocks = new SchematicBlock[rawSchematic.XMax, rawSchematic.YMax, rawSchematic.ZMax];
            for (int Y = 0; Y < rawSchematic.YMax; Y++)
            {
                for (int Z = 0; Z < rawSchematic.ZMax; Z++)
                {
                    for (int X = 0; X < rawSchematic.XMax; X++)
                    {
                        int            index = (Y * rawSchematic.ZMax + Z) * rawSchematic.XMax + X;
                        SchematicBlock block = new SchematicBlock();
                        block.BlockID = ((int)rawSchematic.Blocks[index]).ToString();
                        block.Data    = rawSchematic.Data[index];
                        block.X       = X;
                        block.Y       = Y;
                        block.Z       = Z;

                        if (string.IsNullOrEmpty(block.BlockID))
                        {
                            block.BlockID = "0";
                        }

                        blocks[X, Y, Z] = block;
                    }
                }
            }
            return(blocks);
        }
Example #2
0
        public static SchematicBlock[,,] GetCSBlocks(RawSchematic raw, NbtTag csBlockTag, SchematicBlock[,,] list)
        {
            NbtList csBlocks = csBlockTag as NbtList;

            if (csBlocks != null)
            {
                foreach (NbtCompound compTag in csBlocks)
                {
                    NbtTag         xTag  = compTag["x"];
                    NbtTag         yTag  = compTag["y"];
                    NbtTag         zTag  = compTag["z"];
                    NbtTag         idTag = compTag["id"];
                    SchematicBlock block = new SchematicBlock()
                    {
                        X       = xTag.IntValue,
                        Y       = yTag.IntValue,
                        Z       = zTag.IntValue,
                        BlockID = idTag.StringValue,
                        CSBlock = true
                    };

                    if (string.IsNullOrEmpty(block.BlockID))
                    {
                        block.BlockID = "0";
                    }

                    list[xTag.IntValue, yTag.IntValue, zTag.IntValue] = block;
                }
            }

            for (int Y = 0; Y <= raw.YMax; Y++)
            {
                for (int Z = 0; Z <= raw.ZMax; Z++)
                {
                    for (int X = 0; X <= raw.XMax; X++)
                    {
                        if (list[X, Y, Z] == null)
                        {
                            list[X, Y, Z] = new SchematicBlock()
                            {
                                X       = X,
                                Y       = Y,
                                Z       = Z,
                                BlockID = ColonyBuiltIn.ItemTypes.AIR,
                                CSBlock = true
                            }
                        }
                        ;
                    }
                }
            }

            return(list);
        }
Example #3
0
        public SchematicBlock GetBlock(int X, int Y, int Z)
        {
            SchematicBlock block = default(SchematicBlock);

            if (Y < YMax &&
                X < XMax &&
                Z < ZMax)
            {
                block = Blocks[X, Y, Z];
            }

            if (block == default(SchematicBlock))
            {
                block = SchematicBlock.Air;
            }

            return(block);
        }
Example #4
0
        public void Rotate()
        {
            SchematicBlock[,,] newBlocks = new SchematicBlock[ZMax, YMax, XMax];

            for (int y = 0; y <= YMax; y++)
            {
                for (int z = 0; z <= ZMax; z++)
                {
                    for (int x = 0; x <= XMax; x++)
                    {
                        int newX = x;
                        int newZ = ZMax - (z + 1);

                        if (Blocks[x, y, z].ItemID.Contains("z+"))
                        {
                            Blocks[x, y, z].BlockID = Blocks[x, y, z].BlockID.Replace("z+", "x-");
                        }
                        else if (Blocks[x, y, z].ItemID.Contains("z-"))
                        {
                            Blocks[x, y, z].BlockID = Blocks[x, y, z].BlockID.Replace("z-", "x+");
                        }
                        else if (Blocks[x, y, z].ItemID.Contains("x+"))
                        {
                            Blocks[x, y, z].BlockID = Blocks[x, y, z].BlockID.Replace("x+", "z+");
                        }
                        else if (Blocks[x, y, z].ItemID.Contains("x-"))
                        {
                            Blocks[x, y, z].BlockID = Blocks[x, y, z].BlockID.Replace("x-", "z-");
                        }

                        newBlocks[newZ, y, newX] = Blocks[x, y, z];
                    }
                }
            }

            Blocks = newBlocks;

            int tmpSize = XMax;

            XMax = ZMax;
            ZMax = tmpSize;
        }
Example #5
0
 static SchematicBlock()
 {
     Air = new SchematicBlock();
 }