Skip to content

Instantly share code, notes, and snippets.

@markpapadakis
Created May 13, 2014 13:50
Show Gist options
  • Select an option

  • Save markpapadakis/a6f2cabe8a4b054dc413 to your computer and use it in GitHub Desktop.

Select an option

Save markpapadakis/a6f2cabe8a4b054dc413 to your computer and use it in GitHub Desktop.
struct NPC
{
uint8_t activeScale; // higher => will execute more logic / TICK
void AdjustActivityScale(const float normalizedDistanceFromPC) // Clamped to 0...1
{
activeScale = normalizedDistanceFromPC * 10.0;
}
void OnTick(void)
{
switch (activeScale)
{
case 10:
ConsiderCountryside();
// fall-through
case 9:
ConsiderOtherNPCs();
ConsiderWeather()
//fall-through
case 2:
ConsiderAcceleration();
//fall-through
case 1:
ConsiderNearbyFoes();
ConsiderNearbyFriends();
//fall-through
case 0: // Those area always executed
ConsiderSelfstate();
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment