-
Notifications
You must be signed in to change notification settings - Fork 19
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
Improve event handling #324
Comments
Would be nice to have |
|
|
Phasing out priority
So long as the handlers are called in order of specificity it shouldn't be too difficult. As a stepping stone it might be worth counting the number of wildcard parameters as a psudo priority/depth until that system is in place. It's going to be hard to determine specificity however, knowing that interface "option" > "component" > "id" means the order the options are passed in is important. I suppose a vararg passing these in should be fine, how it's possible to do that with wildcard matching I don't know though. |
* Fix abyssal whip and magic short bow special attacks * Fix npc under_attack not resetting on death * Remove EventHandlerStore.kt and Events.kt in favour of EventStore #324 * Fix load message * Remove bot event queue * Remove onBot in favour of normal script helpers * Version 1.1.6
Approaches: Wildcard triehttps://gist.github.com/GregHib/90baabe67092f0acdc5cd6250ad6eac5 Have a character trie which contains all the wildcards, recursive search for the wildcard at runtime to get a list of handlers to execute. Pros:
Cons:
Id trieLoad all ids for each definition (npcs, objs, items) into trie's and use that to get list of wildcard matches before inserting into map Pros:
Cons:
Filter allOn startup get definition and filter by wildcards to insert all into map Pros:
Cons:
Handler and subscribersHave a single handler and a bunch of subscribers to cover most scenarios Pros:
Cons:
Handler trie?Have several roots for each type which get the correct handler? |
Make the naming consistent so |
#471 removed priority and added a trie system in place with most content converted. It's not as perfect as I would like but it shall do for now. I would be good to phase out overriding and introduce something truely 1:1 but it's not a priority at the moment. |
Different indexes per type:
Interface [id, component, option]
Object [id, option]
Player [index, option]
ItemOnItem [id, option, id2]
handlers.getOrDefault(entity.id, handlers.getOrDefault("_${entity.category}", handlers.get("_"))))
No need to store per entity. It currently uses 170MB to store them all!Will still need event bus for some things (prob just for player?)
itemOnItem() {
}
on(ItemOnItem::class, "bowl_of_water", "pot_of_flour") { player: Player ->
}
useOnItem("bowl_of_water", "pot_of_flour") { player: Player ->
}
useOnObject("bones", "altar") { player: Player ->
}
use("category.bones", "object.altar") { player: Player ->
}
use("item.bones", "object.altar") { player: Player ->
}
cast("earth[a-z]+", "_") { player: Player ->
}
on("shop", "sample", "Take *") { player: Player ->
}
The text was updated successfully, but these errors were encountered: