class LuaEntityFactory : public IEntityFactory { public: static register( const char *pClassName ) { EntityFactoryDictionary()->InstallFactory( this, pClassName ); } IServerNetworkable *Create( const char *pClassName ) { luabind::object obj = call_function( g_LuaState, pClassName ); if ( !obj ) { // deal with it return NULL; } IServerNetworkable* pEnt; try { IServerNetworkable* pEnt = luabind::object_cast(obj); } catch ( const luabind::cast_failed& e ) { // deal with it return NULL; } pEnt->PostConstructor(); return pEnt->NetworkProp(); } void Destroy( IServerNetworkable *pNetworkable ) { if ( pNetworkable ) { pNetworkable->Release(); } } virtual size_t GetEntitySize() { return 0; // TODO: we could dispatch this to Lua somehow.... } };