예제 #1
0
        protected override bool IsValidEntity(Object entity)
        {
            try
            {
                if (entity == null)
                {
                    return(false);
                }

                //Skip unknowns for now until we get the bugs sorted out with the other types
                Type entityType = entity.GetType();
                if (entityType != CharacterEntity.InternalType &&
                    entityType != CubeGridEntity.InternalType &&
                    entityType != VoxelMap.InternalType &&
                    entityType != FloatingObject.InternalType &&
                    entityType != Meteor.InternalType
                    )
                {
                    return(false);
                }

                //Skip disposed entities
                bool isDisposed = (bool)BaseEntity.InvokeEntityMethod(entity, BaseEntity.BaseEntityGetIsDisposedMethod);
                if (isDisposed)
                {
                    return(false);
                }

                //Skip entities that have invalid physics objects
                if (BaseEntity.GetRigidBody(entity) == null || BaseEntity.GetRigidBody(entity).IsDisposed)
                {
                    return(false);
                }

                //Skip entities that don't have a position-orientation matrix defined
                if (BaseEntity.InvokeEntityMethod(entity, BaseEntity.BaseEntityGetOrientationMatrixMethod) == null)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
                return(false);
            }
        }