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

User defined events #113

Closed
quancore opened this issue May 26, 2019 · 3 comments
Closed

User defined events #113

quancore opened this issue May 26, 2019 · 3 comments

Comments

@quancore
Copy link

Higher goal
As a part of my analyzer, I would like to check some pre and post status of the game related an event. For example, I need to check whether player C still alive 2 seconds after player B has been killed. Or Is there any team member near the place just 1 second before player C has been hurt.

Describe the solution you'd like
A very naive way to implement the need is that every pre and post-event entity can be stored in a list and every time tickEnd event triggered, we can check the list whether there is any post/pre entity to proses. This solution will be very slow.
Describe alternatives you've considered
Instead, providing a way to dispatch this user-defined pre/post entities (can be formed as custom events as well) like other events such as playerDeath, kill, etc. Here, I am assuming that I already collected the exact tick number of pre/post events, so the parser only emits these pre/post events like other default events when the tick number has occurred.

@markus-wa
Copy link
Owner

markus-wa commented May 26, 2019

Thanks for the suggestion, but unfortunately I don't understand what you mean.
(The higher goal makes sense but I don't see how your intended solution would look like right now).

Can you rephrase it and/or post the current, slow solution?

@quancore
Copy link
Author

Aim: As I said, I need to make some game situation checking before or after an event has been occurred (lets named pre/post checking events). Let's say, there is a feature named first kill, which the total number of first kills made by a player each round. In order to a first kill being valid, the killer needs to be survived after 2 seconds of kill event. So, I need to schedule a post checking event 2 seconds after this kill event.
Naive solution: A very naive solution will be a scheduler implementation. There would be a list of pre/post checking events already specified in which ticks they will be executed. On each tickEnd, the scheduler iterates all event list and checks whether an event is needed to be executed. However, the solution will be slow that's because, on each tickEnd, you need to check all listed pre/post checking events.
Proposed solution: What I suggest is that instead, Is there any way to implement these pre/post checking events using generic event you implemented and adding/inserting the parser parsing path. So, when the tick occurs, the parser will dispatch these events just like any other events like kill, death, etc. This will provide enormous flexibility to the user to implement own custom events and these events can be triggered when they are supposed to occur. Another benefit is that the user can use his / her own custom events only registering an event handler (For all ideas, I suppose, I have already known in which tick each pre/post checking event should occur).

@markus-wa
Copy link
Owner

I'm not sure if there would really be a too big performance improvement. We could skip the reflection calls needed for TickEnd but that's about it, the rest would be the same implementation as the 'naive' version, just inside the library. It would have the same speed as if you did it yourself.

Or am I missing something?

The lib also used to support custom events in a different way but it wasn't really useful and got removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants