public UnsupportedGrhDataTypeException(GrhData grhData) : base( grhData, string.Format("GrhData `{0}` is of derived type `{1}`, which is not supported by this operation.", grhData, grhData.GetType())) { }
public UnsupportedGrhDataTypeException(GrhData grhData) : base( grhData, string.Format("GrhData `{0}` is of derived type `{1}`, which is not supported by this operation.", grhData, grhData.GetType())) { }
/// <summary> /// Performs a detailed check to ensure the Grh can be drawn without problem. This should be called before /// any drawing is done! /// </summary> /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param> /// <returns>True if it is safe for the Grh to draw to the <paramref name="spriteBatch"/>, else false.</returns> bool CanDrawGrh(ISpriteBatch spriteBatch) { // Invalid GrhData if (GrhData == null) { const string errmsg = "Failed to render Grh - GrhData is null!"; if (log.IsWarnEnabled) { log.Warn(errmsg); } return(false); } // Invalid texture if (Texture == null) { if (log.IsWarnEnabled) { var sgd = GrhData as StationaryGrhData; if (sgd == null) { const string errmsg = "Failed to render Grh `{0}` - GrhData `{1}` is of type `{2}` instead of the expected type `{3}`!"; log.ErrorFormat(errmsg, this, GrhData, GrhData.GetType(), typeof(StationaryGrhData)); } else { const string errmsg = "Failed to render Grh `{0}` - GrhData returning null texture for `{1}`!"; log.WarnFormat(errmsg, this, sgd.TextureName); } } return(false); } // Invalid SpriteBatch if (spriteBatch == null) { const string errmsg = "Failed to render Grh `{0}` - SpriteBatch is null!"; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, this); } return(false); } if (spriteBatch.IsDisposed) { const string errmsg = "Failed to render Grh `{0}` - SpriteBatch is disposed!"; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, this); } return(false); } // All is good return(true); }