00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __ASENTITYCOMPONENT_H__
00017 #define __ASENTITYCOMPONENT_H__
00018
00019
00020 #include "../../dependencies.h"
00021
00022 #ifdef __COMPILE_WITH_ANGELSCRIPT__
00023
00024 #include "../../core/EntityComponent.h"
00025 #include "../ScriptHelper.h"
00026
00027
00029 extern void bindEntityComponent(asIScriptEngine *engine);
00030
00033 template<typename T>
00034 void bindEntityComponentBase(asIScriptEngine *engine, const char *type)
00035 {
00036
00037 int r;
00038 std::string sType = type;
00039
00040
00041 r = engine->RegisterObjectBehaviour(type, asBEHAVE_ADDREF, "void f()",
00042 asMETHOD(T, grab), asCALL_THISCALL); assert(r >= 0);
00043 r = engine->RegisterObjectBehaviour(type, asBEHAVE_RELEASE, "void f()",
00044 asMETHOD(T, drop), asCALL_THISCALL); assert(r >= 0);
00045
00046 r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(),
00047 asFUNCTION((asRefCast<EntityComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );
00048 r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("EntityComponent@ f()").c_str(),
00049 asFUNCTION((asRefCast<T,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );
00050
00051
00052 r = engine->RegisterObjectMethod(type, "u32 getID()",
00053 asMETHOD(T, getID), asCALL_THISCALL); assert(r >= 0);
00054
00055 r = engine->RegisterObjectMethod(type, "void setName(const string &in)",
00056 asMETHOD(T, setName), asCALL_THISCALL); assert(r >= 0);
00057 r = engine->RegisterObjectMethod(type, "const string& getName()",
00058 asMETHOD(T, getName), asCALL_THISCALL); assert(r >= 0);
00059
00060 r = engine->RegisterObjectMethod(type, "Entity@ getParent()",
00061 asMETHOD(T, getParent), asCALL_THISCALL); assert(r >= 0);
00062 }
00063
00064 #endif // __COMPILE_WITH_ANGELSCRIPT__
00065
00066 #endif
00067