Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

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

Open
agluszak opened this issue Jul 23, 2019 · 1 comment
Open

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

agluszak opened this issue Jul 23, 2019 · 1 comment

Comments

@agluszak
Copy link

pub type CreatureType = String;

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:

if creature_type == "Carnivore" || creature_type == "Herbivore" {

@sunreef
Copy link
Collaborator

sunreef commented Jul 24, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants