using DoomDeathmatch.Component.MVC.Controller;
using DoomDeathmatch.Component.Util.Collision;

namespace DoomDeathmatch.Component.Util;

public class FireballComponent : Engine.Scene.Component.Component
{
  public float Damage { get; set; }

  public override void Awake()
  {
    var collider = GameObject.GetComponent<AABBColliderComponent>()!;

    ArgumentNullException.ThrowIfNull(collider);

    collider.OnCollision += OnCollision;
  }

  private void OnCollision(AABBColliderComponent parCollider)
  {
    var healthController = parCollider.GameObject.GetComponent<HealthController>();
    healthController?.TakeDamage(Damage);

    GameObject.Scene!.Remove(GameObject);
  }
}