4. Replicated message related interfaces (3.2)
For event systems, it is a good way to decouple class references.
Question 1: So when should I use it?
I think the event system should be applied between modules, not within the same module. For this, I will use the contents of several of the systems I am developing as examples.
Interactive system. This is a good example of using the event system. For the objects that the character needs to interact with, in most cases I don’t need to know what object is being interacted with. I just need to tell the other party that I am interacting with it now, and it may do something like Character conversations, giving tasks to characters, or telling characters a task clue, or some items, etc., can all be notified using the event system.
Attribute system. This is a classic example of why the event system should not be used. Within the attribute system, we may have attribute components, attribute objects, and extended attribute objects (such as reproducible attributes). We should not use the event system to do any notification behavior for them because it belongs to the same submodule.
Damage system. For the same reason as the property system, inside it, we should not use the event system, but a submodule. But for the interaction between the damage system and the attribute system, we can use the event system to handle it. For example, if I hit the enemy and then cause damage, we can send a notification to the attribute system to tell him that I caused damage and need to execute it. Blood volume is deducted, or blocking deducts stamina (or other) and so on.