transition_function #7

Closed
doylet wants to merge 2 commits from transition_function into main
Showing only changes of commit ca63d3b4bb - Show all commits

View File

@ -725,17 +725,35 @@ static bool FP_Game_CanEntityAttack(FP_GameEntity *entity, uint64_t current_time
static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity, uint32_t desired_state) static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity, uint32_t desired_state)
{ {
switch (desired_state) { switch (entity->type) {
case FP_EntityClingerState_Attack: { case FP_EntityType_Terry: {
if (entity->type == FP_EntityType_ClubTerry) { if (desired_state == FP_EntityTerryState_Attack) {
break;
}
if (!FP_Game_CanEntityAttack(entity, game->clock_ms)) { if (!FP_Game_CanEntityAttack(entity, game->clock_ms)) {
// NOTE: Cooldown not met do not transition // NOTE: Cooldown not met do not transition
return; return;
} }
entity->last_attack_timestamp = game->clock_ms; entity->last_attack_timestamp = game->clock_ms;
}
} break;
case FP_EntityType_Smoochie: {
if (desired_state == FP_EntitySmoochieState_Attack) {
if (!FP_Game_CanEntityAttack(entity, game->clock_ms)) {
// NOTE: Cooldown not met do not transition
return;
}
entity->last_attack_timestamp = game->clock_ms;
}
} break;
case FP_EntityType_Clinger: {
if (desired_state == FP_EntityClingerState_Attack) {
if (!FP_Game_CanEntityAttack(entity, game->clock_ms)) {
// NOTE: Cooldown not met do not transition
return;
}
entity->last_attack_timestamp = game->clock_ms;
}
} break; } break;
} }
// NOTE: If no returns are hit above we proceed with the state change // NOTE: If no returns are hit above we proceed with the state change