/// <summary> /// Adds block to compound (should be used for clients). /// </summary> /// <returns>true if the block has been addded, otherwise false</returns> public bool Add(ushort id, MySlimBlock block) { if (!CanAddBlock(block)) { return(false); } Debug.Assert(block.BlockDefinition.Size == Vector3I.One, "Only blocks with size=1 are supported inside compound block!"); Debug.Assert(block.BlockDefinition.CubeSize == MyCubeSize.Large, "Only large blocks are supported inside compound block!"); if (m_mapIdToBlock.ContainsKey(id)) { Debug.Fail("Cannot add block with existing id to compound block!"); return(false); } m_mapIdToBlock.Add(id, block); m_blocks.Add(block); Debug.Assert(m_mapIdToBlock.Count == m_blocks.Count); MatrixD parentWorldMatrix = this.Parent.WorldMatrix; MatrixD blockLocalMatrix = MatrixD.Identity; GetBlockLocalMatrixFromGridPositionAndOrientation(block, ref blockLocalMatrix); MatrixD worldMatrix = blockLocalMatrix * parentWorldMatrix; block.FatBlock.PositionComp.SetWorldMatrix(worldMatrix, this, true); // Set parent before OnAddedToScene otherwise chhild block will be added to pruning structure block.FatBlock.Hierarchy.Parent = Hierarchy; block.FatBlock.OnAddedToScene(this); CubeGrid.UpdateBlockNeighbours(SlimBlock); RefreshTemplates(); if (block.IsMultiBlockPart) { CubeGrid.AddMultiBlockInfo(block); } return(true); }