From 315fae0968c0a786a23a1dc6f94bab7056ac6668 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 10:58:23 +0100 Subject: close #35 --- src/world.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/world.c b/src/world.c index 7f7252c..1969193 100644 --- a/src/world.c +++ b/src/world.c @@ -1438,6 +1438,22 @@ static void world_update_location_scores(world* world) } } +static void world_age_employee(world* world) +{ + for (s32 i = 0; i < world->locations.length; i++) + { + world_location* location = array_at(&world->locations, i); + if (!location->is_owned) continue; + + for (s32 x = 0; x < location->employees.length; x++) + { + employee* em = *(employee**)array_at(&location->employees, x); + em->age += 1; + em->experience += 1; + } + } +} + static void world_run_simulation_tick(world* world) { s32 elapsed_sec = MINUTES(world->simulation_speed); @@ -1453,6 +1469,10 @@ static void world_run_simulation_tick(world* world) struct tm* curr_time = &curr_time_buf; world->current_time = curr_time_buf; + if (prev_time->tm_year != curr_time->tm_year) { // Run once per year + world_age_employee(world); + } + if (prev_time->tm_wday != curr_time->tm_wday) { // Run once per day world_remove_expired_job_offers(world); world_assign_resumes_to_locations(world); -- cgit v1.2.3-70-g09d2