TiledMapAnimatedLayerModel.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. using Microsoft.Xna.Framework.Graphics;
  2. using System;
  3. namespace MonoGame.Extended.Tiled.Renderers
  4. {
  5. public sealed class TiledMapAnimatedLayerModel : TiledMapLayerModel
  6. {
  7. public TiledMapAnimatedLayerModel(GraphicsDevice graphicsDevice, Texture2D texture, VertexPositionTexture[] vertices, ushort[] indices, TiledMapTilesetAnimatedTile[] animatedTilesetTiles, TiledMapTileFlipFlags[] animatedTilesetTileFlipFlags)
  8. : base(graphicsDevice, texture, vertices, indices)
  9. {
  10. Vertices = vertices;
  11. AnimatedTilesetTiles = animatedTilesetTiles;
  12. _animatedTilesetFlipFlags = animatedTilesetTileFlipFlags;
  13. }
  14. public VertexPositionTexture[] Vertices { get; }
  15. public TiledMapTilesetAnimatedTile[] AnimatedTilesetTiles { get; }
  16. private readonly TiledMapTileFlipFlags[] _animatedTilesetFlipFlags;
  17. public ReadOnlySpan<TiledMapTileFlipFlags> AnimatedTilesetFlipFlags => _animatedTilesetFlipFlags;
  18. protected override VertexBuffer CreateVertexBuffer(GraphicsDevice graphicsDevice, int vertexCount)
  19. {
  20. return new DynamicVertexBuffer(graphicsDevice, VertexPositionTexture.VertexDeclaration, vertexCount, BufferUsage.WriteOnly);
  21. }
  22. protected override IndexBuffer CreateIndexBuffer(GraphicsDevice graphicsDevice, int indexCount)
  23. {
  24. return new DynamicIndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, indexCount, BufferUsage.WriteOnly); ;
  25. }
  26. }
  27. }