scripthook.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __SCRIPTHOOK_H
  2. #define __SCRIPTHOOK_H
  3. #include <api/script/vcputypes.h>
  4. #include <bfc/dispatch.h>
  5. #include <bfc/ptrlist.h>
  6. class ScriptObject;
  7. class ScriptObjectController;
  8. // ----------------------------------------------------------------------------------------------------------
  9. class ScriptHook : public Dispatchable {
  10. protected:
  11. ScriptHook() {};
  12. public:
  13. int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams);
  14. enum {
  15. EVENTCALLBACK = 100,
  16. };
  17. };
  18. inline int ScriptHook::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  19. return _call(EVENTCALLBACK, 0, object, dlfid, params, nparams);
  20. }
  21. class ScriptHookI : public ScriptHook {
  22. public:
  23. ScriptHookI();
  24. virtual ~ScriptHookI();
  25. virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams)=0;
  26. void addMonitorObject(ScriptObject *o, const GUID *hookedclass=NULL); // NULL = all classes of object o
  27. void addMonitorClass(ScriptObject *o);
  28. protected:
  29. RECVS_DISPATCH;
  30. PtrList<ScriptObjectController> controllers;
  31. };
  32. #endif