using DoomDeathmatch.Component.MVC.Model;
using DoomDeathmatch.Component.MVC.View;

namespace DoomDeathmatch.Component.MVC.Controller;

public class ScoreController : Engine.Scene.Component.Component
{
  public int Score => _scoreModel.Score;

  private readonly ScoreModel _scoreModel = new();
  private ScoreView _scoreView = null!;

  public override void Awake()
  {
    _scoreView = GameObject.GetComponent<ScoreView>()!;
    _scoreView.UpdateView(_scoreModel);
    _scoreModel.ScoreChanged += _scoreView.UpdateView;
  }

  public void AddScore(int parScore)
  {
    _scoreModel.Score += parScore;
  }
}