amethyst / evoli

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

Why is CreatureType a String instead of an enum? #100

Open agluszak opened 5 years ago

agluszak commented 5 years ago

https://github.com/amethyst/evoli/blob/2e3b15965b31178e266dc1df3923c275b6afab60/src/components/creatures.rs#L18

Why is CreatureType defined to be a String instead of an enum? An enum would be more typesafe. As far as I can see, it's only used for an enum-like comparison here: https://github.com/amethyst/evoli/blob/2e3b15965b31178e266dc1df3923c275b6afab60/src/systems/spawner.rs#L105

sunreef commented 5 years ago

The reason for this is that this way we can keep adding more creatures without modifying the code at all. All you need is to define a prefab with a Named component.