amethyst / evoli

An ecosystem-simulation game made with Amethyst
https://community.amethyst.rs/t/evoli-introduction/770
Other
217 stars 33 forks source link

Initial combat system #21

Closed marotili closed 5 years ago

marotili commented 5 years ago

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.

khskarl commented 5 years ago

@marot I will leave you to commit the suggestion if you agree and merge the PR :).