I'm trying to create a kind of event-system (in lack of a better definition) for a game I'm making. What I need to do, is to have a set of (hardcoded) 'core' functions, which I can link together in a arbitrary way and define as an "event", which I can then execute with some arbitrary parameters.
These "events" would be relatively simple if they were hardcoded, f.ex.
hardcodedEvent(int this, int that){
coreFunc1(this);
coreFunc2(that);
coreFunc3(coreFunc4(this + that));
//etc...
}
But the entire point is that they need to be dynamic and modular, so that you would be able to, in theory, construct and represent these events in a flow-chart/diagram like way (example: flow-chart editor from 3d software)
Eventually, I would need these events to be serializable, so that I could save and load them as a file or to/from a database.
I've looked at Callback, Command, Observer and State machine patterns, but I don't know which one(s) would best suited for something like this, and I havn't worked much with any of them before.
Aucun commentaire:
Enregistrer un commentaire