fp: Add waves to mob spawner

This commit was merged in pull request #27.
This commit is contained in:
2023-10-02 08:42:23 +11:00
parent 4212fe8452
commit 20da505f2e
3 changed files with 41 additions and 14 deletions
+18 -1
View File
@@ -1414,7 +1414,16 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
link = FP_SentinelList_Erase(&entity->spawn_list, link, game->chunk_pool);
}
if (entity->spawn_list.size < entity->spawn_cap) { // NOTE: Spawn new entities
if (entity->enemies_spawned_this_wave >= entity->enemies_per_wave) {
// NOTE: If all enemies for the current wave have been spawned,
// wait for the cooldown period before starting next wave
if (input->timer_s >= entity->wave_cooldown_timestamp_s) {
entity->current_wave++;
entity->enemies_per_wave *= 2; // NOTE: Double the enemies for the next wave
entity->enemies_spawned_this_wave = 0;
}
} else if (entity->spawn_list.size < entity->spawn_cap) { // NOTE: Spawn new entities
if (input->timer_s >= entity->next_spawn_timestamp_s) {
entity->next_spawn_timestamp_s = DQN_CAST(uint64_t)(input->timer_s + 5.f);
@@ -1442,6 +1451,14 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
waypoint->data.arrive = FP_GameWaypointArrive_WhenWithinEntitySize;
waypoint->data.value = 1.5f;
}
entity->enemies_spawned_this_wave++;
// NOTE: If all enemies for the current wave have been spawned
// set the cooldown time for the next wave
if (entity->enemies_spawned_this_wave >= entity->enemies_per_wave) {
entity->wave_cooldown_timestamp_s = DQN_CAST(uint64_t)(input->timer_s + 30.f); // NOTE: 30s cooldown
}
}
}
}