My take on the combat system. This implements #9 and #8, since they are closely related.
The components should be self-explanatory, except for HasFaction and FactionEnemies. They are used to determine which entities can attack each other. I decided to implement it that way to avoid switching on the tags (HerbivoreTag, CarnivoreTag, PlantTag). Another idea I had was to use an enum, but that would be closed and thus unflexible.
There are three systems for attacking. One to determine if an attack happens after a collision FindAttackSystem, one to perform the attack PerformDefaultAttackSystem. They communicate with each other using events. The last one is CooldownSystem to remove Cooldown components after the cooldown finished.
My take on the combat system. This implements #9 and #8, since they are closely related.
The components should be self-explanatory, except for
HasFaction
andFactionEnemies
. They are used to determine which entities can attack each other. I decided to implement it that way to avoid switching on the tags (HerbivoreTag
,CarnivoreTag
,PlantTag
). Another idea I had was to use an enum, but that would be closed and thus unflexible.There are three systems for attacking. One to determine if an attack happens after a collision
FindAttackSystem
, one to perform the attackPerformDefaultAttackSystem
. They communicate with each other using events. The last one isCooldownSystem
to removeCooldown
components after the cooldown finished.