I currently have an entity component system with messaging. The messages are delivered to each subscriber, but each subscriber gets their own copy, basically meaning that altering a message doesn't affect any other subscriber. While this works fine for now, I was wondering how I would add an invulnerable state.
I have a combat system that solves combat. It takes a combat event (an intent to attack something) and emits a resolved combat event. This event contains information of who attacked whom and what kind of damage they took. It also has a bool which gives the status of whether or not the defending entity is alive after the attack. It also controls the the HP and deletes the entity if it was killed.
I do not have a problem breaking down this system. A system that calculates damage, a system that applies the damage, and a system that kills the entity. But where do I add my invulnerability? If I simply make it a component, then it has to be handled by the system that applies damage. What if I want to add something else later? I have to build up and up the damage system and it has to handle all the little edge cases and intricacies. What if I want to add an attack that goes through invulnerability?
Clearly this is an exponential nightmare, which is exactly what I hoped to avoid with an ECS. How should I handle invulnerability?
Event
to anDeclinableEvent
orCancelableEvent
or even allow subscribers to alter things. This would mean that the input-system creates a move-event which contains the new coordinates, the physics-event may alter those coordinates or cancel the event and after calling all subscribers you had to update the entities position based on the outcome of the event. \$\endgroup\$buff
where the buff-system subscribes to the event-system and just cancels damage-events at all or a50% more armor
buff may only change the damage-value inside the event. \$\endgroup\$