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

public struct CombustibleNeighbour
{
    public CombustibleNeighbour(Combustible o, float contrib)
    {
        other = o;
        effectiveContribution = contrib;
    }
    public Combustible other;
    public float effectiveContribution;

}

public class Combustible : MonoBehaviour {

    // Tuning Variables
    public float FuelBurnRate = 1.0f; // Burn Rate per second per degree over ignition
    public float CombustionTemperature = 100.0f;
    public float MaximumTemperature = 120.0f;
    public float SpreadRange = 1.5f;
    public float TemperatureOutputPerSecondPerDegree = 0.02f;
    public float CoolingRatePerSecond = 1.0f;

    public float SuppressedUntil = 0.0f;
    
    // Suppression means your temperature doesn't rise
    public bool IsSuppressed
    {
        get { return Time.time < SuppressedUntil; }
    }

    // Dynamic Variables
    public float Fuel = 100.0f;
    public float CurrentTemperature = 0.0f;
    public bool IsBurning
    {
        get { return CurrentTemperature >= CombustionTemperature;  }
    }

    public event System.EventHandler Destroyed;

    public List<CombustibleNeighbour> Neighbours = new List<CombustibleNeighbour>();

    Combustible()
    {
        CombustibleProcessor.AddCombustible(this);
    }

    private void OnDestroy()
    {
        Destroyed?.Invoke(this, null);
    }

    public void SetOnFire()
    {
        CurrentTemperature = MaximumTemperature;
        Fuel = 200;
    }
}
