Hello,
I have problems deciding some design questions.
About the game: It's like Anno 1404 but multiplayer only
1) Accessing GUI directly (Object interaction)
Should the Notifier has some kind of queue or should I call it directly, because the player expects immediate response.
A queue would maybe overkill in things of performance, if it's processor has its loop in the render method/loop.
As of writing these lines I doesn't even know why I would have even considert choosing a queue. Searching for a solution to my problems, I came across this article http://gameprogrammingpatterns.com/event-queue.html and it made me thought if it is a good practice or needed for my problems how to wire objects and handle asynchronous tasks and object communication.
I don't know, if its a good idea/programming style to let the ActionController do everything as a central station or to let objects do their own eventchain, like trigger a request from the ActionController, the RequestBuilder sends its request directly to the NetworkManager and the NetworkManager can directly call on the GUI.
2) Observe game objects
From time to time the client sends a request (carrying the actions done by the player) to the server to get a new update of the gamestate and if the actions are allowed and possible. The server calculates end send back the "cleaned" gamestate. The client receives the approved gamestate from the server and transition/interpolate from it's current state to the ones of the server, like undo not allowed actions with a message in the players notification feed, what was reverted. (not the ones shown in the image above, but an extra one)
So there is one observer to observe the overall gamestate and little ones that observe game objects like buildings on the grid, that produce items. Is it good to use a observer pattern here?
Can't say why, but my intuition says:
Observers for states the player doesn't initiate directly (burning fuel, producing units over time, ...)
Listeners for direct actions the player does (pressing a button to login, build a building, move a item on the map, pay for something, trade)
A better example: The player wants to research "Ironswords". So he presses the button for this research. The listener notice the event and creates an observer (or subscribe that event to an existing research-observer) which observes the progress over time. If the research is finished after a certain amount of time, a notification is added to the players feed and the event unsubscribes from the observer or the observer is getting killed.