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

Track kills through event bus #33369

Merged
merged 1 commit into from
Aug 22, 2019

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Aug 19, 2019

Summary

SUMMARY: Infrastructure "Track kills through event_bus in new dedicated kill_tracker class"

Purpose of change

To reduce the code bloat in game, to decrease coupling, and to demonstrate the utility of the new event_bus class.

Describe the solution

Note that this change builds on top of #33344 and #32891; a lot of the changes you see here are part of those PRs. Now those are merged, rebased on master.

Create a new class kill_tracker which counts the player's kills. This functionality used to be directly in game. Move all the relevant functions from game to kill_tracker to work with that data.

Also, add an event_bus to game, and make the kill_tracker a subscriber of it.

Communicate information about kills via the event_bus, rather than having dedicated member functions of game for that purpose.

Add suitable (de)serialization code to save this data and migrate the old format.

Describe alternatives you've considered

When a Character is killed, I chose to put the name directly in the event. I could have only provided the character_id, and had the kill_tracker fetch the name itself, but I thought I would mimic the previous interface for now. I was also slightly concerned that the Character might not be loadable any more if they are dead; didn't look into that.

Additional context

This seemed like the simplest functionality that made sense to be built on top of the event_bus to provide a real-world test of its functionality before moving on to more ambitious projects.

Next I would like to make a subscriber that performs all the memorial logging, rather than having that logging code scattered around the codebase.

@jbytheway jbytheway force-pushed the kills_through_event_bus branch from 4da8d99 to c9dc410 Compare August 19, 2019 19:38
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Aug 19, 2019
@Leland
Copy link
Contributor

Leland commented Aug 19, 2019

I think you're on track to finally be the one to claim the $110 bounty on #4173

@jbytheway
Copy link
Contributor Author

I think you're on track to finally be the one to claim the $110 bounty on #4173

Yes, that is indeed my end goal.

This is intended as the first application of the event_bus.

Create a new class kill_tracker which counts the player's kills.  This
functionality used to be directly in game.

Move all the relevant functions from game to kill_tracker to work with
that data.

Also, add an event_bus to game, and make the kill_tracker a subscriber
to it.

Communicate information about kills via the event_bus, rather than
having dedicated member functions of game for that purpose.

Add suitable (de)serialization code to save this data and migrate the
old format.
@jbytheway jbytheway force-pushed the kills_through_event_bus branch from c9dc410 to c67a08b Compare August 21, 2019 13:54
@jbytheway
Copy link
Contributor Author

Now rebased and tests green.

@kevingranade kevingranade merged commit 347bd7d into CleverRaven:master Aug 22, 2019
@jbytheway jbytheway deleted the kills_through_event_bus branch August 22, 2019 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants