Empeld
Empeld plugin documentation.
essentials.Systems.Triggers.AbstractTrigger Class Referenceabstract
Inheritance diagram for essentials.Systems.Triggers.AbstractTrigger:
essentials.Systems.Triggers.ITrigger essentials.Systems.Triggers.EntityAreaTrigger essentials.Systems.Triggers.SimpleTrigger

Public Member Functions

void Listen ()
 
void Dispose ()
 

Protected Member Functions

 AbstractTrigger (TimeSpan checkFrequency)
 
 AbstractTrigger ()
 
TaskResult HandleTriggerCheck ()
 
abstract bool CheckTrigger ()
 

Properties

int TriggerCount [get]
 
Action< ITriggerTriggered
 
- Properties inherited from essentials.Systems.Triggers.ITrigger
int TriggerCount [get]
 

Additional Inherited Members

- Events inherited from essentials.Systems.Triggers.ITrigger
Action< ITriggerTriggered
 

Constructor & Destructor Documentation

◆ AbstractTrigger() [1/2]

essentials.Systems.Triggers.AbstractTrigger.AbstractTrigger ( TimeSpan  checkFrequency)
protected
38  {
39  this.InjectDependencies();
40  this._checkFrequency = checkFrequency;
41  }

◆ AbstractTrigger() [2/2]

essentials.Systems.Triggers.AbstractTrigger.AbstractTrigger ( )
protected
44  :this(TimeSpan.FromSeconds(2))
45  {}

Member Function Documentation

◆ CheckTrigger()

abstract bool essentials.Systems.Triggers.AbstractTrigger.CheckTrigger ( )
protectedpure virtual

◆ Dispose()

void essentials.Systems.Triggers.AbstractTrigger.Dispose ( )
58  {
59  if (!_disposed)
60  {
61  _task.Stop();
62  _task = null;
63  _disposed = true;
64  }
65  }

◆ HandleTriggerCheck()

TaskResult essentials.Systems.Triggers.AbstractTrigger.HandleTriggerCheck ( )
protected
68  {
69  if (_disposed) //Just in case
70  return TaskResult.Remove;
71 
72  if (CheckTrigger())
73  {
74  _triggered.Invoke(d => d(this));
75  _hitCount++;
76  }
77 
78  return _triggered.Count > 0 ? TaskResult.Continue : TaskResult.Remove;
79  }
TaskResult
The result of a scheduled task
Definition: TaskResult.cs:8

◆ Listen()

void essentials.Systems.Triggers.AbstractTrigger.Listen ( )
48  {
49  if (_disposed)
50  throw new ObjectDisposedException("Trigger");
51  if (_task != null)
52  throw new Exception("Already listening");
53 
54  _task = _scheduler.ScheduleRecurringTask(HandleTriggerCheck, _checkFrequency);
55  }
TaskResult HandleTriggerCheck()
Definition: AbstractTrigger.cs:67

Property Documentation

◆ TriggerCount

int essentials.Systems.Triggers.AbstractTrigger.TriggerCount
get

◆ Triggered

Action<ITrigger> essentials.Systems.Triggers.AbstractTrigger.Triggered
addremove

The documentation for this class was generated from the following file: