I wouldn’t take that approach for the simple reason that it it is needlessly complex.
Why not this:
curNeed = Needs.wander;
highestNeed = 0.3f; // min before we stop wandering
if (stats.Hunger > highestNeed)
{
curNeed = Needs.food;
highestNeed = stats.Hunger;
}
if (stats.Thirst > highestNeed)
{
curNeed = Needs.water;
highestNeed = stats.Thirst;
}
if (stats.Urge > highestNeed)
{
curNeed = Needs.mate;
highestNeed = stats.Urge;
}
That seems far more understandable to me, and if I did me bits right, would result in the same output. Correct me if I’m wrong… I didn’t run the above code.
Finally I leave you with a quote from the band Devo:
Got an urge, got a surge and it’s outta control
Got an urge I want to purge 'cause I’m losing control
Uncontrollable urge I want to tell you all about it
Got an uncontrollable urge, it makes me scream and shout it