FIFE forums

FIFE Development => Framework development => Topic started by: prock on March 25, 2013, 07:35:30 am

Title: What about triggers?
Post by: prock on March 25, 2013, 07:35:30 am
Many of you heard me ranting about this last week.  I'm thinking about starting on a trigger system and am putting some thought into it's design.  First I'd like to get some input from you guys.  In order to design a trigger system we have to agree on the definition of a trigger.  What comes to mind for me is something like this:   A trigger is something that waits for a particular event or set of conditions to be met and reports it to the system.  By "reports it to the system" I'm referring to the active listeners that are listening for the trigger to report (yes we should probably conform to our current observer pattern standards).

This of course is a pretty broad definition of a trigger compared to what I was thinking before.  Initially I was thinking a trigger could only listen for particular instance/cell interactions, like when an instance enters/exits a cell.  Now I think by keeping a broader definition of a trigger in mind it might keep the design a bit more flexible.

Here are some ideas I have for requirements of the trigger system:

Thats all I have for now.  Thoughts?

Title: Re: What about triggers?
Post by: vdaras on March 26, 2013, 07:39:59 am
My two cents is that the observer pattern in this situation would be a little bit cumbersome. As a client, especially if I used fife through python, I would like a function callback mechanism instead. We can also support this in C++ clients as well, since most major compilers now support lambda expressions. If C++11x usage is any issue, we could use one of these http://stackoverflow.com/questions/1526912/fast-c-delegates.
Title: Re: What about triggers?
Post by: prock on March 26, 2013, 08:47:51 am
hmm yeah I thought of that, however I dismissed the idea because we don't make use of them elsewhere.  I wanted to try and remain somewhat consistent with what we do in other areas of the engine.  The model I'm looking at might quickly become unmanageable with all the listeners it'll have to manage.  I'll have to do some experimenting perhaps.
Title: Re: What about triggers?
Post by: prock on March 27, 2013, 08:36:31 am
I created a new branch called triggers to start work.  I haven't completely solved all my issues yet but I'm going to start experimenting with them in that branch.  Currently I have a few questions that need answering:


I'm sure a few more questions will pop up as I work on it.