The existing on event listening has a O(N) lookup complexity, where N is the total number of listeners in use.
This is fine for the majority of event's which will have very few listeners, however the most commonly used listeners might see performance hits as content grows.
Fortunantley a lot of content has fixed preconditions for execution, allowing conditions to be hashed and stored in a map for N(1) lookup.
Proposal
Initially thought that due to the limited number of Option Types that applied, they could all be stored in a single location Map<Type, Map<String, Map<Long, () -> Unit>>>. However it's not apparent that using having a String Option and Hash separate is necessary for all Types and so they should be done on an individual basis.
Both option and id can be represented by one of three ways:
int
exact string
containing string
But a conditional can be obtained many different ways depending on type:
interface id + component id + string option
Types
Player
NPC
Object
Interface (Including but not limited to Item options)
Floor Item
Interface on Player
Interface on NPC
Interface on Object
Interface on Interface
Interface on Floor Item
Scenarios
Attacking any player
Trade with any NPC with the exact name "Shop assistant"
Talking to a NPC with the id 637
Trade with any NPC with a name which contains "Shop"
Talk to any NPC in a list of Ids
Use any Object with a name which is in a list of names ["Counter", "Bank booth"]
Description
The existing
on
event listening has aO(N)
lookup complexity, where N is the total number of listeners in use.This is fine for the majority of event's which will have very few listeners, however the most commonly used listeners might see performance hits as content grows.
Fortunantley a lot of content has fixed preconditions for execution, allowing conditions to be hashed and stored in a map for
N(1)
lookup.Proposal
Initially thought that due to the limited number of Option Types that applied, they could all be stored in a single location
Map<Type, Map<String, Map<Long, () -> Unit>>>
. However it's not apparent that using having a String Option and Hash separate is necessary for all Types and so they should be done on an individual basis.Both
option
andid
can be represented by one of three ways:But a conditional can be obtained many different ways depending on type:
Types
Scenarios
Examples
Questions
How will data be passed if not via
EntityAction
? E.g "Talk-to" "Hans" would need index of interacted npc.