wavelength 1.0.0
Loading...
Searching...
No Matches
triggeraction.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/debug.h"
4#include "rnd/rndmanager.h"
5#include "script/dataarray.h"
6
16public:
28 static TriggerAction *New(DataArray *pAction);
29
36 virtual ~TriggerAction() {
37 }
38
42 virtual void Exec() = 0;
43
53 virtual bool Poll() {
54 return true;
55 }
56
65 void Start();
66
68 float GetDelay() const {
69 return mDelay;
70 }
71
77 void SetDelay(float fDelay) {
78 mDelay = fDelay;
79 }
80
82 int GetClock() const {
83 return mClock;
84 }
85
91 void SetClock(int nClock) {
92 mClock = nClock;
93 }
94
95protected:
105 template <class T>
106 static T *FindObject(DataArray *pAction, const char *pszName) {
107 T *pObject = dynamic_cast<T *>(TheManager.Find(pszName));
108 if (pObject == nullptr) {
109 DebugWarn("Couldn't find '%s' object (file %s, line %d)",
110 pszName,
111 pAction->GetFile(),
112 pAction->GetLine());
113 }
114 return pObject;
115 }
116
117private:
118 float mDelay;
119 int mClock;
120};
Reference-counted array of script data nodes.
Definition dataarray.h:20
const char * GetFile() const
Definition dataarray.h:437
short GetLine() const
Definition dataarray.h:442
Something a trigger does when its conditions hold.
Definition triggeraction.h:15
virtual void Exec()=0
Run the action.
virtual ~TriggerAction()
Release the action.
Definition triggeraction.h:36
static T * FindObject(DataArray *pAction, const char *pszName)
Find a renderer object of a class by name, warning when there is none.
Definition triggeraction.h:106
static TriggerAction * New(DataArray *pAction)
Build the action a node describes.
int GetClock() const
Definition triggeraction.h:82
void SetDelay(float fDelay)
Set the time on the clock of the action before Exec() runs.
Definition triggeraction.h:77
void Start()
Run the action now, or schedule it when it has a delay.
float GetDelay() const
Definition triggeraction.h:68
virtual bool Poll()
Advance an action that TriggerMgr::AddRunning() received.
Definition triggeraction.h:53
void SetClock(int nClock)
Set the TriggerMgr::Clock the action runs on.
Definition triggeraction.h:91
void DebugWarn(const char *pszFormat,...)
Format a warning that the shipped build discards.
RndManager TheManager
The renderer's registry.