Esempio n. 1
0
        public bool AddGrid(MyCubeGrid grid)
        {
            //TODO: create static list
            List<Vector3I> lst = new List<Vector3I>();

            foreach (var block in grid.GetBlocks())
            {
                if (block.FatBlock is MyCompoundCubeBlock)
                {
                    bool added = false;
                    foreach (var subb in (block.FatBlock as MyCompoundCubeBlock).GetBlocks())
                    {
                        if (AddBlock(subb))
                        {
                            if (!added)
                                lst.Add(block.Position);

                            added = true;
                        }
                    }
                }
                else
                {
                    if (AddBlock(block))
                    {
                        lst.Add(block.Position);
                    }
                }
            }

            if (lst.Count > 0)
            {
                grid.RazeBlocks(lst);
                return true;
            }

            return false;
        }
Esempio n. 2
0
        public bool AddGrid(MyCubeGrid grid)
        {
            HashSet<Sandbox.Game.Entities.Cube.MySlimBlock> lst = new HashSet<Sandbox.Game.Entities.Cube.MySlimBlock>();

            foreach (var block in grid.GetBlocks())
            {
                if (block.FatBlock is MyCompoundCubeBlock)
                {
                    bool added = false;
                    foreach (var subb in (block.FatBlock as MyCompoundCubeBlock).GetBlocks())
                    {
                        if (AddBlock(subb))
                        {
                            added = true;
                        }
                    }
                    if (added)
                    {
                        lst.Add(block);
                    }
                }
                else
                {
                    if (AddBlock(block))
                    {
                        lst.Add(block);
                    }
                }
            }


            foreach (var b in lst)
            {
                Vector3I pos = b.Position;
                Vector3UByte size = new Vector3UByte(1, 1, 1);
                grid.RazeBlocks(ref pos, ref size);
                //   grid.RemoveBlock(b, true); not synced
            }

            return lst.Count > 0;
        }