From e09c82278d23c18ee9c1dd27dc4cd0075538da3d Mon Sep 17 00:00:00 2001 From: GreenComfyTea Date: Tue, 8 Aug 2023 13:04:40 +0300 Subject: [PATCH] Optimize small monster UI drawing function --- reframework/autorun/MHR_Overlay.lua | 9 +-- .../MHR_Overlay/Damage_Meter/non_players.lua | 2 +- .../MHR_Overlay/Monsters/ailment_buildup.lua | 12 ++-- .../MHR_Overlay/Monsters/ailment_hook.lua | 2 +- .../autorun/MHR_Overlay/Monsters/ailments.lua | 58 +++++++++---------- .../MHR_Overlay/Monsters/body_part.lua | 6 +- .../MHR_Overlay/Monsters/monster_hook.lua | 4 +- .../UI/Modules/env_creature_UI.lua | 1 + .../UI/Modules/large_monster_UI.lua | 2 - .../UI/Modules/small_monster_UI.lua | 26 +-------- 10 files changed, 49 insertions(+), 73 deletions(-) diff --git a/reframework/autorun/MHR_Overlay.lua b/reframework/autorun/MHR_Overlay.lua index bc6ec16..4c1d2d8 100644 --- a/reframework/autorun/MHR_Overlay.lua +++ b/reframework/autorun/MHR_Overlay.lua @@ -247,12 +247,9 @@ local function draw_modules(module_visibility_config, flow_state_name) local large_monster_UI_config = config.current_config.large_monster_UI; - local dynamic_enabled = large_monster_UI_config.dynamic.enabled and - module_visibility_config.large_monster_dynamic_UI; - local static_enabled = large_monster_UI_config.static.enabled and - module_visibility_config.large_monster_static_UI; - local highlighted_enabled = large_monster_UI_config.highlighted.enabled and - module_visibility_config.large_monster_highlighted_UI; + local dynamic_enabled = large_monster_UI_config.dynamic.enabled and module_visibility_config.large_monster_dynamic_UI; + local static_enabled = large_monster_UI_config.static.enabled and module_visibility_config.large_monster_static_UI; + local highlighted_enabled = large_monster_UI_config.highlighted.enabled and module_visibility_config.large_monster_highlighted_UI; if dynamic_enabled or static_enabled or highlighted_enabled then local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled); diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua index 5611319..673698a 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua @@ -282,7 +282,7 @@ function this.update_servant_otomos() local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i); if servant_otomo == nil then error_handler.report("non_players.update_servant_otomos", "Failed to access Data: servant_otomo No. " .. tostring(i)); - goto continue + goto continue; end local otomo_create_data = servant_otomo:call("get_OtCreateData"); diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua b/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua index e020768..aa15b1c 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua @@ -56,24 +56,24 @@ function this.draw(monster, ailment_buildup_UI, cached_config, ailment_buildups_ for id, ailment in pairs(monster.ailments) do if id == ailments.stun_id then if not cached_config.filter.stun then - goto continue + goto continue; end elseif id == ailments.poison_id then if not cached_config.filter.poison then - goto continue + goto continue; end elseif id == ailments.blast_id then if not cached_config.filter.blast then - goto continue + goto continue; end else - goto continue + goto continue; end if cached_config.settings.time_limit ~= 0 and time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit then - goto continue + goto continue; end @@ -154,7 +154,7 @@ function this.draw(monster, ailment_buildup_UI, cached_config, ailment_buildups_ end if total_buildup == 0 then - goto continue + goto continue; end if cached_config.sorting.type == "Normal" then diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua index 821fe5a..c7530ec 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua @@ -147,7 +147,7 @@ function this.stock_damage() local damage_param = get_damage_param_method:call(enemy); if damage_param == nil then error_handler.report("ailment_hook.stock_damage", "Failed to access Data: small_monster -> damage_param"); - goto continue + goto continue; end local poison_param = poison_param_field:get_data(damage_param); diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua index d3a2679..ef250ab 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua @@ -312,13 +312,13 @@ function this.update_ailments(enemy, monster) for id = 0, condition_param_array_length - 1 do if id == this.stun_id or id == this.poison_id or id == this.blast_id then - goto continue + goto continue; end local ailment_param = get_value_method:call(condition_param_array, id); if ailment_param == nil then error_handler.report("ailments.update_ailments", "Failed to access Data: ailment_param No. " .. tostring(id)); - goto continue + goto continue; end this.update_ailment(monster, ailment_param, id); @@ -559,86 +559,86 @@ function this.draw(monster, ailment_UI, cached_config, ailments_position_on_scre for id, ailment in pairs(monster.ailments) do if id == this.paralyze_id then if not cached_config.filter.paralysis then - goto continue + goto continue; end elseif id == this.sleep_id then if not cached_config.filter.sleep then - goto continue + goto continue; end elseif id == this.stun_id then if not cached_config.filter.stun then - goto continue + goto continue; end elseif id == this.flash_id then if not cached_config.filter.flash then - goto continue + goto continue; end elseif id == this.poison_id then if not cached_config.filter.poison then - goto continue + goto continue; end elseif id == this.blast_id then if not cached_config.filter.blast then - goto continue + goto continue; end elseif id == this.exhaust_id then if not cached_config.filter.exhaust then - goto continue + goto continue; end elseif id == this.ride_id then if not cached_config.filter.ride then - goto continue + goto continue; end elseif id == this.water_id then if not cached_config.filter.waterblight then - goto continue + goto continue; end elseif id == this.fire_id then if not cached_config.filter.fireblight then - goto continue + goto continue; end elseif id == this.ice_id then if not cached_config.filter.iceblight then - goto continue + goto continue; end elseif id == this.thunder_id then if not cached_config.filter.thunderblight then - goto continue + goto continue; end elseif id == this.fall_trap_id then if not cached_config.filter.fall_trap then - goto continue + goto continue; end elseif id == this.shock_trap_id then if not cached_config.filter.shock_trap then - goto continue + goto continue; end elseif id == this.capture_id then if not cached_config.filter.tranq_bomb then - goto continue + goto continue; end elseif id == this.koyashi_id then if not cached_config.filter.dung_bomb then - goto continue + goto continue; end elseif id == this.steel_fang_id then if not cached_config.filter.steel_fang then - goto continue + goto continue; end elseif id == this.fall_quick_sand_id then if not cached_config.filter.quick_sand then - goto continue + goto continue; end elseif id == this.fall_otomo_trap_id then if not cached_config.filter.fall_otomo_trap then - goto continue + goto continue; end elseif id == this.shock_otomo_trap_id then if not cached_config.filter.shock_otomo_trap then - goto continue + goto continue; end else - goto continue + goto continue; end if cached_config.settings.hide_ailments_with_zero_buildup @@ -646,31 +646,31 @@ function this.draw(monster, ailment_UI, cached_config, ailments_position_on_scre and ailment.buildup_limit ~= 0 and ailment.activate_count == 0 and not ailment.is_active then - goto continue + goto continue; end if cached_config.settings.hide_inactive_ailments_with_no_buildup_support and ailment.buildup_limit == 0 and not ailment.is_active then - goto continue + goto continue; end if cached_config.settings.hide_all_inactive_ailments and not ailment.is_active then - goto continue + goto continue; end if cached_config.settings.hide_all_active_ailments and ailment.is_active then - goto continue + goto continue; end if cached_config.settings.hide_disabled_ailments and not ailment.is_enable then - goto continue + goto continue; end if cached_config.settings.time_limit ~= 0 and time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit and not ailment.is_active then - goto continue + goto continue; end table.insert(displayed_ailments, ailment); diff --git a/reframework/autorun/MHR_Overlay/Monsters/body_part.lua b/reframework/autorun/MHR_Overlay/Monsters/body_part.lua index 75c2a53..e92b4fc 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/body_part.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/body_part.lua @@ -316,19 +316,19 @@ function this.draw(monster, part_UI, cached_config, parts_position_on_screen, op and ((part.break_health == part.break_max_health and part.break_count == 0) or not break_supported) and ((part.loss_health == part.loss_max_health and not part.is_severed) or not sever_supported) and ((part.anomaly_health == part.anomaly_max_health) or not anomaly_supported) then - goto continue + goto continue; end if (not part_UI.flinch_visibility or not health_supported) and (not part_UI.break_visibility or not break_supported or part.break_count >= part.break_max_count) and (not part_UI.loss_visibility or not sever_supported or part.is_severed) and (not part_UI.anomaly_visibility or not anomaly_supported) then - goto continue + goto continue; end if cached_config.settings.time_limit ~= 0 and time.total_elapsed_script_seconds - part.last_change_time > cached_config.settings.time_limit then - goto continue + goto continue; end table.insert(displayed_parts, part); diff --git a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua index 2655138..9e6be56 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua @@ -129,7 +129,7 @@ function this.update_large_monster(enemy) -- this is the VERY LEAST thing we should do all the time -- so the position doesn't lag all over the place -- due to how infrequently we update the monster(s). - --large_monster.update_position(enemy, monster); + large_monster.update_position(enemy, monster); if not config.current_config.global_settings.performance.prioritize_large_monsters and updated_monsters[enemy] then return; @@ -174,7 +174,7 @@ function this.update_small_monster(enemy) -- this is the VERY LEAST thing we should do all the time -- so the position doesn't lag all over the place -- due to how infrequently we update the monster(s). - --small_monster.update_position(enemy, monster); + small_monster.update_position(enemy, monster); if updated_monsters[enemy] then return; diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua index b526a7f..5cd33fc 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua @@ -52,6 +52,7 @@ function this.draw() local cached_config = config.current_config.endemic_life_UI; local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier; + for REcreature, creature in pairs(env_creature.list) do if cached_config.settings.max_distance == 0 then break; diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua index fb70dc4..b23650b 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua @@ -91,8 +91,6 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled) goto continue; end - large_monster.update_position(enemy, monster); - if update_distance then monster.distance = (players.myself_position - monster.position):length(); end diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua index cfcc7fa..a925291 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua @@ -56,31 +56,11 @@ function this.draw() local displayed_monsters = {}; - local enemy_count = get_zako_enemy_count_method:call(singletons.enemy_manager); - if enemy_count == nil then - error_handler.report("small_monster_UI.draw", "Failed to access Data: enemy_count"); - return; - end - - for i = 0, enemy_count - 1 do - local enemy = get_zako_enemy_method:call(singletons.enemy_manager, i); - if enemy == nil then - error_handler.report("small_monster_UI.draw", "Failed to access Data: enemy No. " .. tostring(i)); - goto continue; - end - - local monster = small_monster.get_monster(enemy); - if monster == nil then - error_handler.report("small_monster_UI.draw", "Failed to create Small Monster Entry No. " .. tostring(i)); - goto continue; - end - + for enemy, monster in pairs(small_monster.list) do if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then goto continue; end; - small_monster.update_position(enemy, monster); - table.insert(displayed_monsters, monster); ::continue:: end @@ -147,7 +127,7 @@ function this.draw() position_on_screen = draw.world_to_screen(monster.position + world_offset); if position_on_screen == nil then - goto continue + goto continue; end position_on_screen.x = position_on_screen.x + cached_config.dynamic_positioning.viewport_offset.x; @@ -169,7 +149,7 @@ function this.draw() end if monster.distance > cached_config.dynamic_positioning.max_distance then - goto continue + goto continue; end if cached_config.dynamic_positioning.opacity_falloff then