using UnityEngine;
using System.Collections;
using Framework.Entities;

public class JournalTrigger : CoreBehaviour
{
    public string entryFile;
    private int actualDay;
    public int activationDay;

    protected override void InnerAwake()
    {
        AddGlobalActionHandler<DayDirector.NewDayAction>(this, NewDay);
    }

    protected override void InnerUpdate()
    {

    }

    private void NewDay(DayDirector.NewDayAction action)
    {
        this.actualDay = action.dayNumber;
    }

    void OnTriggerEnter(Collider collider)
    {
        if (collider.GetComponent<AlchemistPlayerInput>() != null && actualDay >= activationDay)
        {
            Announce(new Journal.AddEntryAction(Journal.LoadText(entryFile)[0]));
            Destroy(this.gameObject);
        }
    }
}
