using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class TM_CombatComponent : MonoBehaviour
{
    List<Func<TM_Projectile, bool>> listOnHitByProjectile;

    void Awake()
    {
        listOnHitByProjectile = new List<Func<TM_Projectile, bool>>();
    }

    public void AddOnHitFunction(Func<TM_Projectile, bool> func)
    {
        if( !listOnHitByProjectile.Contains(func))
            listOnHitByProjectile.Add(func);
    }

    public bool OnHitByProjectile(TM_Projectile proj)
    {
        bool bProjectileShouldDestroy = true;

        for (int t = 0; t < listOnHitByProjectile.Count; t++)
        {
            Func<TM_Projectile, bool> f = listOnHitByProjectile[t];
            if (!f(proj))
                bProjectileShouldDestroy = false;
        }

        return bProjectileShouldDestroy;
    }
}