TileQuadTexture.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 readonly VertexPositionTexture[] _cache;
  11. private bool _enabled;
  12. #endregion Fields
  13. #region Constructors
  14. public TileQuadTexture(Tile tile, TextureHandler texture, float scale)
  15. {
  16. _enabled = true;
  17. GetTile = tile;
  18. _cache = tile.GetQuad(scale);
  19. Texture = texture;
  20. }
  21. #endregion Constructors
  22. #region Properties
  23. public byte AnimationID => GetTile.AnimationID;
  24. public byte AnimationState => GetTile.AnimationState;
  25. /*
  26. public BlendMode BlendMode => _tile.BlendMode;
  27. */
  28. public bool Enabled => _enabled && Texture != null;
  29. public Tile GetTile { get; }
  30. public TextureHandler Texture { get; }
  31. #endregion Properties
  32. #region Methods
  33. public static explicit operator Tile(TileQuadTexture @in) => @in.GetTile;
  34. public static implicit operator Texture2D(TileQuadTexture @in) => (Texture2D)@in.Texture;
  35. public static implicit operator VertexPositionTexture[] (TileQuadTexture @in) => @in._cache;
  36. public void Hide() => _enabled = false;
  37. public void Show() => _enabled = true;
  38. #endregion Methods
  39. }
  40. #endregion Classes
  41. // TODO: uncomment the following line if the finalizer is overridden above.// GC.SuppressFinalize(this);
  42. }
  43. }