[SOLVED] Why am I not able to cast this enum to an int?

I have this Enum outside class / namespace declaration:

public enum Element
{
        None = 0,
        Fire = 1,
        Ice = 2,
        Earth = 3,
        Dark = 4,
        Light = 5
}

Then I have an interface which makes use of that enum:

public interface IStats
{       
        float health { get; set; }
        float damage { get; set; }
        Element element { get; set; }

        void Damage (float damage, int source);
   
}

Then I have a projectile class that implements interface IStats:

public Element element { get; set ; }
                public void Damage (float sourceDamage, int source)
                {
                        damage -= sourceDamage * Globals.elementDamage [(int)source.element, (int)element];
}

The problem is the line above. It tells me “int does not contain a definition for element”.

You have source as an int value…
Perhaps you meant to pass a class or a struct

1 Like

Look at your argument “source” in Damage, its an int.

Your trying to get member element of integer source, and then trying to cast the result of that to an int.

1 Like

Thanks guys… I spent 20 minutes on this and missed that…