TileQuadTexture.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Microsoft.Xna.Framework.Graphics;
  2. namespace OpenVIII.Fields
  3. {
  4. public partial class Background
  5. {
  6. #region Classes
  7. private class TileQuadTexture
  8. {
  9. #region Fields
  10. private VertexPositionTexture[] cache;
  11. private bool enabled;
  12. private TextureHandler texture;
  13. private Tile tile;
  14. #endregion Fields
  15. #region Constructors
  16. public TileQuadTexture(Tile tile, TextureHandler texture, float scale)
  17. {
  18. this.enabled = true;
  19. this.tile = tile;
  20. this.cache = tile.GetQuad(scale);
  21. this.texture = texture;
  22. }
  23. #endregion Constructors
  24. #region Properties
  25. public byte AnimationID => tile.AnimationID;
  26. public byte AnimationState => tile.AnimationState;
  27. public BlendMode BlendMode => tile.BlendMode;
  28. public bool Enabled => enabled && texture != null;
  29. public Tile GetTile => tile;
  30. #endregion Properties
  31. #region Methods
  32. public static explicit operator Tile(TileQuadTexture @in) => @in.tile;
  33. public static implicit operator Texture2D(TileQuadTexture @in) => (Texture2D)@in.texture;
  34. public static implicit operator VertexPositionTexture[] (TileQuadTexture @in) => @in.cache;
  35. public void Hide() => enabled = false;
  36. public void Show() => enabled = true;
  37. #endregion Methods
  38. }
  39. #endregion Classes
  40. // TODO: uncomment the following line if the finalizer is overridden above.// GC.SuppressFinalize(this);
  41. }
  42. }