using DoomDeathmatch.Component.MVC.Model;
using DoomDeathmatch.Component.MVC.Model.Weapon;
using Engine.Graphics.Texture;
using Engine.Scene.Component.BuiltIn.Renderer;

namespace DoomDeathmatch.Component.MVC.View;

public class WeaponView : Engine.Scene.Component.Component
{
  private readonly TextRenderer _weaponName;
  private readonly TextRenderer _weaponAmmo;
  private readonly Box2DRenderer _weaponSprite;

  public WeaponView(TextRenderer parWeaponName, TextRenderer parWeaponAmmo, Box2DRenderer parWeaponSprite)
  {
    _weaponName = parWeaponName;
    _weaponAmmo = parWeaponAmmo;
    _weaponSprite = parWeaponSprite;
  }

  public void UpdateView(WeaponData parWeaponData)
  {
    UpdateAmmoView(parWeaponData);
    _weaponName.Text = $"Оружие: {parWeaponData.Name}";
    _weaponSprite.Texture = Engine.Engine.Instance.AssetResourceManager.Load<Texture>(parWeaponData.Texture);
  }

  public void UpdateAmmoView(WeaponData parWeaponData)
  {
    _weaponAmmo.Text = $"Патроны: {parWeaponData.Ammo}/{parWeaponData.MaxAmmo}";
  }
}