(You may skip the entire part and jump down to the question: It only explains why I think I need this, however if you can think of a much better way to implement this, then please tell me).
I've settled with the one-module approach, depending if it works or not. Furthermore I've implemented a small entity system like supposed in these forums a few months (or years) ago:
class entity {};class component {};class component_system{ hash_map<entity*,component*> components};
I've implemented some components in c++ and had to write quite alot code to make them as flexible as possible. I figured stuff would be easier if I would expose the component interface to angelscript and implement those components in angelscript anways, since they don't do heavy stuff (they're simple wrappers around RenderNode, PhysicsActor, etc...). Ofcourse there must be an ai_component that contains the logic for the agents.
//c++void ai_component_system::update(){ for(auto i = components.begin(); i != components.end(); ++i) { // interesting part }}
Now to the interesting part. I imagine that within angelscript I create an actor at some point and add an ai_component to it. The ai_component gets added to the sequence of components and every frame the script calls ai_component_system::update() (indirectly by updating the engine once a frame).
(Actual question)
Is it possible that I return control to the same asIScriptContext that called my function in the first place? I do know the pointer to the object I want to call a method on (which I also know).
What I don't know is if angelscript supports this or not.
// interesting partasIScriptContext* context = (the current context);ai_component* comp = static_cast<ai_component*>(i->second);context->prepare(my_function_id);context->setObject(comp);context->execute();
Second question: Is this a good way to implement what I want to achieve? Maybe I'm looking at this in the wrong way.