Original Post
Hello, I'm writing script system for my application. Now I have such entity system:
abstract class Object with default functions (such as update, name, type, etc.).
When I need a new entity I inherit Object class. I also have global map which stores entities this way:
And when I need to add some new entity I do:
Btw, say nothing about managing pointers, this is an example, I'm using shared pointers there.
So, everything works well this way. But it takes a long time to store and compile all my entities.
And if the game will have 100 types of them? So I decided to move object creating into script-system: I don't need to wait a compile time, it's easy to edit settings, etc.
But now I have a problem, how to tell c++ about new type I defined in script? I'm using boost.python. So I exported abstract Object and can make new types in python which inherits it. But how to insert into that map such new object from python. And main question: what to do, if I want to manipulate with some type in c++?
abstract class Object with default functions (such as update, name, type, etc.).
When I need a new entity I inherit Object class. I also have global map which stores entities this way:
std::map< std::string, Object* > mEntitiesAnd when I need to add some new entity I do:
class CoolEntity : Object { };
mEntities["SomeCoolName"] = new CoolEntity();Btw, say nothing about managing pointers, this is an example, I'm using shared pointers there.
So, everything works well this way. But it takes a long time to store and compile all my entities.
And if the game will have 100 types of them? So I decided to move object creating into script-system: I don't need to wait a compile time, it's easy to edit settings, etc.
But now I have a problem, how to tell c++ about new type I defined in script? I'm using boost.python. So I exported abstract Object and can make new types in python which inherits it. But how to insert into that map such new object from python. And main question: what to do, if I want to manipulate with some type in c++?