パッケージ simulation.event

クラス SimpleTimerEvent

java.lang.Object
simulation.event.SimpleTimerEvent
すべての実装されたインタフェース:
TimerEvent

public abstract class SimpleTimerEvent extends Object implements TimerEvent
Convenience base class for recurring TimerEvent implementations with a fixed interval. Subclasses only need to implement onTick(simulation.CombatSimulator) and optionally call finish() to stop the event early. The next tick time is automatically advanced by interval after each tick unless the event is already finished.

Example use: a periodic buff refresh that fires every 2.0 seconds until finish() is called.

  • フィールド詳細

    • nextTickTime

      protected double nextTickTime
      The simulation time at which the next tick will fire.
    • interval

      protected double interval
      The fixed interval in seconds between successive ticks.
    • finished

      protected boolean finished
      Whether the event has been marked complete via finish().
  • コンストラクタの詳細

    • SimpleTimerEvent

      public SimpleTimerEvent(double startTime, double interval)
      Constructs a new recurring event.
      パラメータ:
      startTime - the simulation time of the first tick
      interval - the interval in seconds between consecutive ticks
  • メソッドの詳細

    • getNextTickTime

      public double getNextTickTime()
      Returns the simulation time at which this event's next TimerEvent.tick(simulation.CombatSimulator) should fire.
      定義:
      getNextTickTime インタフェース内 TimerEvent
      戻り値:
      next tick time in seconds
    • isFinished

      public boolean isFinished(double currentTime)
      Returns true once finish() has been called.
      定義:
      isFinished インタフェース内 TimerEvent
      パラメータ:
      currentTime - current simulation time (unused by this implementation)
      戻り値:
      true if the event is finished
    • finish

      public void finish()
      Marks this event as complete. After this call, isFinished(double) will return true and the event will not be re-queued after its next tick.
    • tick

      public void tick(CombatSimulator sim)
      Delegates to onTick(simulation.CombatSimulator) and then advances nextTickTime by interval if the event has not been finished.
      定義:
      tick インタフェース内 TimerEvent
      パラメータ:
      sim - the CombatSimulator managing this event
    • onTick

      public abstract void onTick(CombatSimulator sim)
      Subclass hook called on every tick. Implement this to define the event's periodic behavior.
      パラメータ:
      sim - the CombatSimulator managing this event