Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: implementation of the Observer pattern [incomplete] #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

redv
Copy link
Collaborator

@redv redv commented Jan 23, 2018

The Observer pattern is a possible replacement for the StateRefMap + StateRef.

I.e. ObservableLinkedMap contains agents:
ObservableLinkedMap<Agent> agents;

The Lab is Observer for the agents map.
class Lab : ObserverLinkedMap<Agent>

If agent died (during battle or even if the agents map destroyed during the game's quitting) the lab will receive the event "removed" and remove the agent from its own list.

The vehicles horizontal list could be observer for the vehicles map.
horizontallist_vehicles
If the player sold or buy a vehicle then the list updates automatically after receive an event. If a vehicle change its state (i.e. enter to building) then the list receives the "changed" event and changes picture of the vehicle accordingly.

The same for agents horizontal list (in battle mode too) and for the organisations list.

Main idea is forget about dereference hell of the StateRef and use the event-driven programming.
So, at this stage it is just an idea and the code is not ready for merging.

The observer.h contains the Observer and the Observable base classes.
The ObserverLinkedMap is a template of abstract class derived from the Observer.
The ObservableLinkedMap is a template class derived from the Observable.
The map is linked because the class contains hashmap and linked list to keep order of inserting.

@makus82
Copy link
Contributor

makus82 commented Jan 24, 2018

Hey redv i send you invites to get to slack
but now we in discord so here invite if you want its easy
https://discord.gg/0nS950g1olwDxzXB
there many ppl already

@JonnyH JonnyH added the WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add? label Jan 30, 2018
@FilmBoy84 FilmBoy84 added the STALLED Work In Progress but for whatever reason, nothing's been done for a while. New coders may be needed! label Jan 15, 2019
@FilmBoy84 FilmBoy84 removed the WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add? label Feb 9, 2019
@FilmBoy84 FilmBoy84 added Not Yet Implemented This fix or feature is not yet implemented or merged with trunk WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add? Better Design Required The current implementation is not ideal. We'd be better off with a new design for a solution. labels Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Better Design Required The current implementation is not ideal. We'd be better off with a new design for a solution. Not Yet Implemented This fix or feature is not yet implemented or merged with trunk STALLED Work In Progress but for whatever reason, nothing's been done for a while. New coders may be needed! WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants