Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
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

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

Member Function Documentation

abstract bool essentials.Systems.Triggers.AbstractTrigger.CheckTrigger ( )
protectedpure virtual
void essentials.Systems.Triggers.AbstractTrigger.Dispose ( )
58  {
59  if (!_disposed)
60  {
61  _task.Stop();
62  _task = null;
63  _disposed = true;
64  }
65  }
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
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

int essentials.Systems.Triggers.AbstractTrigger.TriggerCount
get
Action<ITrigger> essentials.Systems.Triggers.AbstractTrigger.Triggered
addremove

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