import { Entity, EntityNames } from ".";
import { Grid, Sprite } from "../components";
import { IMAGES, SPRITE_SPECS, SpriteSpec, Sprites } from "../config";
import { Coord2D } from "../interfaces";

export class Grass extends Entity {
  private static spriteSpec = SPRITE_SPECS.get(Sprites.GRASS) as SpriteSpec;

  constructor(gridPosition: Coord2D) {
    super(EntityNames.Grass);

    this.addComponent(new Grid(gridPosition));

    this.addComponent(
      new Sprite(
        IMAGES.get(Grass.spriteSpec.sheet)!,
        { x: 0, y: 0 },
        {
          width: Grass.spriteSpec.width,
          height: Grass.spriteSpec.height,
        },
        Grass.spriteSpec.msPerFrame,
        Grass.spriteSpec.frames
      )
    );
  }
}
