From 558767628dd472c0af3c1c64c9eaca045a854b00 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 30 Nov 2024 17:51:40 +0100 Subject: close #23 --- src/world.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index 5da8ba8..c23205b 100644 --- a/src/world.c +++ b/src/world.c @@ -1,6 +1,6 @@ #include -static void world_assign_new_job_offers(world* world); +static void world_assign_new_job_offers(world* world, bool force); static double distance_between_location(world_location* location1, world_location* location2); static void world_payout_salaries(world* world); static void enable_insights_for_current_month(world* world); @@ -96,7 +96,6 @@ static world_location world_create_location(u8 size, double latitude, double lon location.resumes = array_create(sizeof(resume)); location.id = assets_hash_path(location.name); - location.reliability = 1.0f; location.score = 0.0f; return location; @@ -617,7 +616,7 @@ world* world_create_new() return 0; } - world_assign_new_job_offers(new_world); + world_assign_new_job_offers(new_world, true); enable_insights_for_current_month(new_world); return new_world; @@ -719,7 +718,7 @@ static s32 world_get_max_depth_for_location(world_location* location) return location_depth; } -static void world_assign_new_job_offers(world* world) +static void world_assign_new_job_offers(world* world, bool force) { for (s32 i = 0; i < world->locations.length; i++) { @@ -728,10 +727,10 @@ static void world_assign_new_job_offers(world* world) if (location->job_offers.length >= MAX_JOBOFFER_COUNT) continue; float rand_offer_chance = (1/10.0f); // 1 in 10 change of getting a job offer by default - rand_offer_chance += ((world->investments.human_resources / INVESTMENT_INCREMENT)*0.005f); // 100 eur = 0.5% increase in job offers. + rand_offer_chance += ((world->investments.marketing / INVESTMENT_INCREMENT)*0.005f); // 100 eur = 0.5% increase in job offers. if (rand_offer_chance > 0.4f) rand_offer_chance = 0.4f; // Cap investment influence at 40%. rand_offer_chance += (location->score / 4.0f); - if (get_random_number(0, 100) > rand_offer_chance*100.0f) continue; + if (!force && get_random_number(0, 100) > rand_offer_chance*100.0f) continue; s32 company_id = get_random_number(0, world->companies.length); company* company = array_at(&world->companies, company_id); @@ -815,14 +814,12 @@ static void world_assign_resumes_to_locations(world* world) world_location* location = array_at(&world->locations, i); if (!location->is_owned) continue; - // 0.5 reliability = 0% - // 1.0 reliability = 10% - // 1.5 reliability = 20% - // etc. - // % = change of a new resume being submitted per day. - #if 1 - if (get_random_number(0, 10) >= ceil(location->reliability)) continue; - #endif + float rand_offer_chance = (1/20.0f); // 1 in 20 change of getting a new resume submission. + rand_offer_chance += ((world->investments.human_resources / INVESTMENT_INCREMENT)*0.005f); // 100 eur = 0.5% increase in submissions. + if (rand_offer_chance > 0.4f) rand_offer_chance = 0.4f; // Cap investment influence at 40%. + rand_offer_chance += (location->score / 4.0f); + if (get_random_number(0, 100) > rand_offer_chance*100.0f) continue; + resume new_resume; new_resume.animation = animation_create(RESUME_FADEOUT_MS); new_resume.expire_date = world->simulation_time+DAYS(10); @@ -1300,16 +1297,13 @@ static void world_run_simulation_tick(world* world) world_remove_expired_job_offers(world); world_assign_resumes_to_locations(world); world_start_random_events(world); + world_assign_new_job_offers(world, false); if (curr_time->tm_mday <= 28) { world_payout_salaries(world); // Pay salary first 28 days of month. world_pay_investments(world); } } - - if (prev_time->tm_wday != curr_time->tm_wday) { // Run once per day - world_assign_new_job_offers(world); - } if (curr_time->tm_hour >= WORK_HOUR_START && curr_time->tm_hour < WORK_HOUR_END) { // Run every 15min s32 hour_part = 60 / TIME_SLOTS_PER_HOUR; @@ -1416,7 +1410,7 @@ world_update_result world_render(platform_window* window, world* world) s32 circle_x = location->map_position_x - dotsize/2; s32 circle_y = location->map_position_y - dotsize/2; bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize); - location->is_accessible = true;//world_check_location_accessibility(location, location, 1, 0); + location->is_accessible = world_check_location_accessibility(location, location, 1, 0); location->is_hovered = hovered; if (hovered && location->is_accessible) { @@ -1436,10 +1430,11 @@ world_update_result world_render(platform_window* window, world* world) tint = COLOR_LOCATION_DOT_UNACCESSIBLE; } + renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, tint); + if (!world_map_location_is_in_sun(map_pos)) { - tint = rgb(255, 255, 0); + renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, rgba(255, 255, 0, 110)); } - renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, tint); } renderer->set_render_depth(2); -- cgit v1.2.3-70-g09d2