using System;
namespace Otter {
///
/// Component that counts down and executes a function. After it has executed it removes itself.
///
public class Alarm : Component {
#region Public Fields
///
/// The amount of time that must pass before the function activates.
///
public float Delay;
///
/// The method to call when the timer reaches the set delay.
///
public Action Function;
#endregion
#region Constructors
///
/// Create an Alarm.
///
/// The method to call when the timer reaches the set delay.
/// The amount of time that must pass before the method is called.
public Alarm(Action function, float delay) {
Function = function;
Delay = delay;
}
#endregion
#region Public Methods
///
/// Update the Alarm.
///
public override void Update() {
base.Update();
if (Timer >= Delay) {
if (Function != null) {
Function();
RemoveSelf();
}
}
}
#endregion
}
}