示例#1
0
        /// <summary>
        /// Check if the given block is a "live" existing block, or a "zombie" reference left after a dead and removed block.
        /// </summary>
        /// <param name="StrictCheck">Performs strict check (checks if block in same place is of same typeid+subtypeid). Generates 2 object builders.</param>
        public static bool IsLive(this IMyCubeBlock Block, bool StrictCheck = false)
        {
            if (Block == null)
            {
                return(false);
            }
            if (Block.Closed)
            {
                return(false);
            }
            if (Block.SlimBlock?.IsDestroyed != false)
            {
                return(false);
            }
            var ThereBlock = Block.CubeGrid.GetCubeBlock(Block.Position);

            if (ThereBlock == null)
            {
                return(false);
            }
            var Builder      = Block.GetObjectBuilder();
            var ThereBuilder = ThereBlock.GetObjectBuilder();

            return(Builder.TypeId == ThereBuilder.TypeId && Builder.SubtypeId == ThereBuilder.SubtypeId);
        }