EPC Event-driven Process Chain II

posted in Event-driven engine for project Hangman
Published September 09, 2021
Advertisement

I was working on the Editor for my game engine and I found some trouble to implement some event-action sequences.
That's why I have decided to share my experience about how to manage the limitations of my game engine.

I was implementing the camera scroll for the editor. I decided to use the drag&drop option to move the camera. The problem was that I was already using the drag&drop to move the shapes (event/actions).
So letting the event to trigger both actions, both actions are done. If you remember, by default, my engine uses AND as output after events. (OR as input before actions)
So both diagrams are the same in my engine.

The problem is that I need an OR connector after the event, so only one action is triggered. It seems so easy on a peace of paper…
Just replace the AND connection by an OR connection ?

But that supposes to add new features in the deep core of the engine. The part that can break all the engine.
The first temptation was avoiding the issue.
All my proposals ended in some type of state, somewhere I need to save which is the target, shapes or camera, and then do the drag.
But the events/actions do not have any type of state. The state must be saved elsewhere.
The candidate was clear, “I need a System”.
It made sense, because the mouse events must be shared/discarded/consumed between all the elements that share the Mouse, but that was only a solution for the particular issue at the moment.

Also I found a second problem…
My first idea was using the Mouse wheel for zoom in/out, scroll left/right, and scroll up/down. I decided using Ctrl, Shift and Alt to differentiate which action was needed.
So the actions must be triggered only if both events are fired.
And that is an AND connection between two events. And my engine does an OR, any of them fires the actions…


So I needed to modify the core engine (the main loop) to accept AND and OR where it uses by default OR and AND. And save the state of those connectors somewhere, and clear the status after each cycle….

My EPC diagrams are stored in Event-Action-Event pieces. But that is not enough to store the new requirements.

- One idea was to extend the small piece. For example allow list for each f them
List(EventIn)-List(Action)-List(EventOut)

  • The OR operation needed to drag only Shapes or the camera could be
    leftPointerDragged-(dragCamera, draqShapes)-(cameraDragged,shapeDragged)
  • The CtrlPressed+wheelMoved needed for the zoom can be
    (CtrlPressed,wheelMoved)-zoom-zoomChanged

But it has a major problem, in the case of two or more events needed to execute the action, one of them could be not yet triggered in the cycle, not yet present in the event queue. And the action will not be run.

- Finally I decided to implement the AND and OR connection as an independent class, that can be used to save the state of the connection and do more advanced tasks. During all the coding process I cannot get the behavior tree diagrams out of my mind when I thought about the connectors. Because in some way I think that connectors can be extended to do similar things like a random selector.

So even I was quite happy with my engine, finally I have needed to extend it to implement all types of connections between Events and Actions.

Again let me share the complete option list.

Connection rules for Event-driven process chain

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement