playMaker

Author Topic: Do events queue?[SOLVED]  (Read 2872 times)

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Do events queue?[SOLVED]
« on: March 30, 2016, 02:16:39 AM »
If we use this image as an example


If several fsm's are sending the event "COMMS" event to this fsm-

If this fsm is processing a previous "COMMS" event when this fsm receives a new "COMMS" event will that new event be processed after the current one is finished?

Will events queue if several are sent simultaneously or will they be ignored?

The workaround would be to have a separate queue manager fsm holding the events in an array I imagine-

But if no events will be ignored that would be great  :)

« Last Edit: March 30, 2016, 05:00:47 AM by mdotstrange »
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 714
    • Flashing Lights
Re: Do events queue?
« Reply #1 on: March 30, 2016, 03:10:18 AM »
The COMMS will be fired every time someone will send it, so it will start over from the top regardless if the previous have finished or not.

Yes there could be a event manager fsm, that collects incoming COOMS and check if there are one in progress and wait for it. Together with a int counter to know how many there are in the queue and send the event until int is 0.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Do events queue?
« Reply #2 on: March 30, 2016, 03:29:14 AM »
Thank you for your answer- so they won't queue and they could be overridden/be sent incompletely?

If so, yes then I should create an event queue- thanks!
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 714
    • Flashing Lights
Re: Do events queue?
« Reply #3 on: March 30, 2016, 03:49:31 AM »
Yes an event can not know when is the right time to fire, so it just fires when is sent, they override. You can check a bool or for the state Finished and then do the COMMS from other fsm.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Do events queue?
« Reply #4 on: March 30, 2016, 04:09:23 AM »
Hi,

 I had to implement such "queuing" of events because I was receiving seveal events and the fsm processing this event would take a lot longer to process then the occurences, so I did it this way:

One Fsm "Listener" is receiving this event, it doesn't nothing else than incrementing a number. If you pass event data, either store it into an array, else create a GameObject as a child and have an hashtable defining the properties of that event.

A Second Fsm knows about "Listener" and it knows if it's processing something or not, when it doesn't process it checks on "Listener" if there are pending events, if there is decrease by one the number and execute one process, when the process is done, it comes back to the check routine.

now you'll face another small issue, you don't want to watch constantly the "Listener" using an getFsmInt everyframe, it works, but not pretty ( I do it a lot of time... but here I am just going clean...) on the state that checks if there is a pending event, you'll get stuck if there isn't, and so you can have a transition on that state, that "Listener" can fire, that event, because a transition of a state will only be caught by your fsm if this state is active and so while processing, "Listener" will attempt to wake up your fsm to tell it to process. it may or may not be caught, depending on wether the active state is indeed the one when nothing is being processed.

 Hope that's clear enough :)

Bye,

 Jean
« Last Edit: March 30, 2016, 06:19:00 AM by jeanfabre »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Do events queue?
« Reply #5 on: March 30, 2016, 05:00:36 AM »
Thanks for the detailed explanation Jean  :) Yes, it is very helpful. Thank you.
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!