19 std::string m_sFilename;
24 ScriptCallback(
int type,
const std::string& script): func_type(type), m_nLastTick(0){
32 const std::string& GetCode(){
return m_sCode;}
33 const std::string& GetFileName(){
return m_sFilename;}
34 const std::string& GetScriptFunc(){
return script_func;}
36 unsigned int GetLastTick()
const {
return m_nLastTick;}
37 void SetLastTick(
unsigned int nTick) {m_nLastTick = nTick;}
44 typedef std::vector<ScriptCallback> ObjectCallbackPool_Type;
46 #ifndef DEFINE_SCRIPT_EVENT 47 #define DEFINE_SCRIPT_EVENT(clsName, name) \ 48 ATTRIBUTE_METHOD1(clsName, Get##name##_s, const char**){\ 49 ScriptCallback* pCallBack = cls->GetScriptCallback(Type_##name);\ 50 *p1 = (pCallBack!=NULL) ? pCallBack->script_func.c_str() : CGlobals::GetString(G_STR_EMPTY).c_str();\ 53 ATTRIBUTE_METHOD1(clsName, Set##name##_s, const char*) {cls->AddScriptCallback(Type_##name, p1); return S_OK;} 56 #ifndef DEFINE_SCRIPT_EVENT_GET 57 #define DEFINE_SCRIPT_EVENT_GET(clsName, name) \ 58 ATTRIBUTE_METHOD1(clsName, Get##name##_s, const char**){\ 59 ScriptCallback* pCallBack = cls->GetScriptCallback(Type_##name);\ 60 *p1 = (pCallBack!=NULL) ? pCallBack->script_func.c_str() : CGlobals::GetString(G_STR_EMPTY).c_str();\ int ActivateLocalNow(const std::string &script)
activate the script callback locally now.
Definition: IObjectScriptingInterface.cpp:87
the game object will keep a list of script call backs.
Definition: IObjectScriptingInterface.h:12
int func_type
function type
Definition: IObjectScriptingInterface.h:15
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual bool AddScriptCallback(int func_type, const string &script_func)
add a new call back handler.
Definition: IObjectScriptingInterface.cpp:24
virtual bool RemoveScriptCallback(int func_type)
remove a call back handler
Definition: IObjectScriptingInterface.cpp:58
ObjectCallbackPool_Type m_callback_scripts
the NPL script handlers
Definition: IObjectScriptingInterface.h:82
std::string script_func
the NPL file and function to be activated.
Definition: IObjectScriptingInterface.h:18
unsigned int m_nLastTick
last time this function is called.
Definition: IObjectScriptingInterface.h:22
int ActivateAsync(const std::string &code)
activate the script callback with the given code.
Definition: IObjectScriptingInterface.cpp:79
Definition: inftrees.h:24
Definition: IObjectScriptingInterface.h:6
virtual ScriptCallback * GetScriptCallback(int func_type)
return NULL if there is no associated script.
Definition: IObjectScriptingInterface.cpp:46
void SetScriptFunc(const std::string &script)
set the script function
Definition: IObjectScriptingInterface.cpp:71