Optimize small monster UI drawing function

This commit is contained in:
GreenComfyTea
2023-08-08 13:04:40 +03:00
parent e1d3754733
commit e09c82278d
10 changed files with 49 additions and 73 deletions

View File

@@ -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 large_monster_UI_config = config.current_config.large_monster_UI;
local dynamic_enabled = large_monster_UI_config.dynamic.enabled and local dynamic_enabled = large_monster_UI_config.dynamic.enabled and module_visibility_config.large_monster_dynamic_UI;
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 static_enabled = large_monster_UI_config.static.enabled and local highlighted_enabled = large_monster_UI_config.highlighted.enabled and module_visibility_config.large_monster_highlighted_UI;
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 if dynamic_enabled or static_enabled or highlighted_enabled then
local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled); local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled);

View File

@@ -282,7 +282,7 @@ function this.update_servant_otomos()
local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i); local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i);
if servant_otomo == nil then if servant_otomo == nil then
error_handler.report("non_players.update_servant_otomos", "Failed to access Data: servant_otomo No. " .. tostring(i)); error_handler.report("non_players.update_servant_otomos", "Failed to access Data: servant_otomo No. " .. tostring(i));
goto continue goto continue;
end end
local otomo_create_data = servant_otomo:call("get_OtCreateData"); local otomo_create_data = servant_otomo:call("get_OtCreateData");

View File

@@ -56,24 +56,24 @@ function this.draw(monster, ailment_buildup_UI, cached_config, ailment_buildups_
for id, ailment in pairs(monster.ailments) do for id, ailment in pairs(monster.ailments) do
if id == ailments.stun_id then if id == ailments.stun_id then
if not cached_config.filter.stun then if not cached_config.filter.stun then
goto continue goto continue;
end end
elseif id == ailments.poison_id then elseif id == ailments.poison_id then
if not cached_config.filter.poison then if not cached_config.filter.poison then
goto continue goto continue;
end end
elseif id == ailments.blast_id then elseif id == ailments.blast_id then
if not cached_config.filter.blast then if not cached_config.filter.blast then
goto continue goto continue;
end end
else else
goto continue goto continue;
end end
if cached_config.settings.time_limit ~= 0 and if cached_config.settings.time_limit ~= 0 and
time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit then time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit then
goto continue goto continue;
end end
@@ -154,7 +154,7 @@ function this.draw(monster, ailment_buildup_UI, cached_config, ailment_buildups_
end end
if total_buildup == 0 then if total_buildup == 0 then
goto continue goto continue;
end end
if cached_config.sorting.type == "Normal" then if cached_config.sorting.type == "Normal" then

View File

@@ -147,7 +147,7 @@ function this.stock_damage()
local damage_param = get_damage_param_method:call(enemy); local damage_param = get_damage_param_method:call(enemy);
if damage_param == nil then if damage_param == nil then
error_handler.report("ailment_hook.stock_damage", "Failed to access Data: small_monster -> damage_param"); error_handler.report("ailment_hook.stock_damage", "Failed to access Data: small_monster -> damage_param");
goto continue goto continue;
end end
local poison_param = poison_param_field:get_data(damage_param); local poison_param = poison_param_field:get_data(damage_param);

View File

@@ -312,13 +312,13 @@ function this.update_ailments(enemy, monster)
for id = 0, condition_param_array_length - 1 do 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 if id == this.stun_id or id == this.poison_id or id == this.blast_id then
goto continue goto continue;
end end
local ailment_param = get_value_method:call(condition_param_array, id); local ailment_param = get_value_method:call(condition_param_array, id);
if ailment_param == nil then if ailment_param == nil then
error_handler.report("ailments.update_ailments", "Failed to access Data: ailment_param No. " .. tostring(id)); error_handler.report("ailments.update_ailments", "Failed to access Data: ailment_param No. " .. tostring(id));
goto continue goto continue;
end end
this.update_ailment(monster, ailment_param, id); 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 for id, ailment in pairs(monster.ailments) do
if id == this.paralyze_id then if id == this.paralyze_id then
if not cached_config.filter.paralysis then if not cached_config.filter.paralysis then
goto continue goto continue;
end end
elseif id == this.sleep_id then elseif id == this.sleep_id then
if not cached_config.filter.sleep then if not cached_config.filter.sleep then
goto continue goto continue;
end end
elseif id == this.stun_id then elseif id == this.stun_id then
if not cached_config.filter.stun then if not cached_config.filter.stun then
goto continue goto continue;
end end
elseif id == this.flash_id then elseif id == this.flash_id then
if not cached_config.filter.flash then if not cached_config.filter.flash then
goto continue goto continue;
end end
elseif id == this.poison_id then elseif id == this.poison_id then
if not cached_config.filter.poison then if not cached_config.filter.poison then
goto continue goto continue;
end end
elseif id == this.blast_id then elseif id == this.blast_id then
if not cached_config.filter.blast then if not cached_config.filter.blast then
goto continue goto continue;
end end
elseif id == this.exhaust_id then elseif id == this.exhaust_id then
if not cached_config.filter.exhaust then if not cached_config.filter.exhaust then
goto continue goto continue;
end end
elseif id == this.ride_id then elseif id == this.ride_id then
if not cached_config.filter.ride then if not cached_config.filter.ride then
goto continue goto continue;
end end
elseif id == this.water_id then elseif id == this.water_id then
if not cached_config.filter.waterblight then if not cached_config.filter.waterblight then
goto continue goto continue;
end end
elseif id == this.fire_id then elseif id == this.fire_id then
if not cached_config.filter.fireblight then if not cached_config.filter.fireblight then
goto continue goto continue;
end end
elseif id == this.ice_id then elseif id == this.ice_id then
if not cached_config.filter.iceblight then if not cached_config.filter.iceblight then
goto continue goto continue;
end end
elseif id == this.thunder_id then elseif id == this.thunder_id then
if not cached_config.filter.thunderblight then if not cached_config.filter.thunderblight then
goto continue goto continue;
end end
elseif id == this.fall_trap_id then elseif id == this.fall_trap_id then
if not cached_config.filter.fall_trap then if not cached_config.filter.fall_trap then
goto continue goto continue;
end end
elseif id == this.shock_trap_id then elseif id == this.shock_trap_id then
if not cached_config.filter.shock_trap then if not cached_config.filter.shock_trap then
goto continue goto continue;
end end
elseif id == this.capture_id then elseif id == this.capture_id then
if not cached_config.filter.tranq_bomb then if not cached_config.filter.tranq_bomb then
goto continue goto continue;
end end
elseif id == this.koyashi_id then elseif id == this.koyashi_id then
if not cached_config.filter.dung_bomb then if not cached_config.filter.dung_bomb then
goto continue goto continue;
end end
elseif id == this.steel_fang_id then elseif id == this.steel_fang_id then
if not cached_config.filter.steel_fang then if not cached_config.filter.steel_fang then
goto continue goto continue;
end end
elseif id == this.fall_quick_sand_id then elseif id == this.fall_quick_sand_id then
if not cached_config.filter.quick_sand then if not cached_config.filter.quick_sand then
goto continue goto continue;
end end
elseif id == this.fall_otomo_trap_id then elseif id == this.fall_otomo_trap_id then
if not cached_config.filter.fall_otomo_trap then if not cached_config.filter.fall_otomo_trap then
goto continue goto continue;
end end
elseif id == this.shock_otomo_trap_id then elseif id == this.shock_otomo_trap_id then
if not cached_config.filter.shock_otomo_trap then if not cached_config.filter.shock_otomo_trap then
goto continue goto continue;
end end
else else
goto continue goto continue;
end end
if cached_config.settings.hide_ailments_with_zero_buildup 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.buildup_limit ~= 0
and ailment.activate_count == 0 and ailment.activate_count == 0
and not ailment.is_active then and not ailment.is_active then
goto continue goto continue;
end end
if cached_config.settings.hide_inactive_ailments_with_no_buildup_support if cached_config.settings.hide_inactive_ailments_with_no_buildup_support
and ailment.buildup_limit == 0 and ailment.buildup_limit == 0
and not ailment.is_active then and not ailment.is_active then
goto continue goto continue;
end end
if cached_config.settings.hide_all_inactive_ailments and not ailment.is_active then if cached_config.settings.hide_all_inactive_ailments and not ailment.is_active then
goto continue goto continue;
end end
if cached_config.settings.hide_all_active_ailments and ailment.is_active then if cached_config.settings.hide_all_active_ailments and ailment.is_active then
goto continue goto continue;
end end
if cached_config.settings.hide_disabled_ailments and not ailment.is_enable then if cached_config.settings.hide_disabled_ailments and not ailment.is_enable then
goto continue goto continue;
end end
if cached_config.settings.time_limit ~= 0 if cached_config.settings.time_limit ~= 0
and time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit and time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit
and not ailment.is_active then and not ailment.is_active then
goto continue goto continue;
end end
table.insert(displayed_ailments, ailment); table.insert(displayed_ailments, ailment);

View File

@@ -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.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.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 and ((part.anomaly_health == part.anomaly_max_health) or not anomaly_supported) then
goto continue goto continue;
end end
if (not part_UI.flinch_visibility or not health_supported) 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.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.loss_visibility or not sever_supported or part.is_severed)
and (not part_UI.anomaly_visibility or not anomaly_supported) then and (not part_UI.anomaly_visibility or not anomaly_supported) then
goto continue goto continue;
end end
if cached_config.settings.time_limit ~= 0 and if cached_config.settings.time_limit ~= 0 and
time.total_elapsed_script_seconds - part.last_change_time > cached_config.settings.time_limit then time.total_elapsed_script_seconds - part.last_change_time > cached_config.settings.time_limit then
goto continue goto continue;
end end
table.insert(displayed_parts, part); table.insert(displayed_parts, part);

View File

@@ -129,7 +129,7 @@ function this.update_large_monster(enemy)
-- this is the VERY LEAST thing we should do all the time -- this is the VERY LEAST thing we should do all the time
-- so the position doesn't lag all over the place -- so the position doesn't lag all over the place
-- due to how infrequently we update the monster(s). -- 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 if not config.current_config.global_settings.performance.prioritize_large_monsters and updated_monsters[enemy] then
return; return;
@@ -174,7 +174,7 @@ function this.update_small_monster(enemy)
-- this is the VERY LEAST thing we should do all the time -- this is the VERY LEAST thing we should do all the time
-- so the position doesn't lag all over the place -- so the position doesn't lag all over the place
-- due to how infrequently we update the monster(s). -- 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 if updated_monsters[enemy] then
return; return;

View File

@@ -52,6 +52,7 @@ function this.draw()
local cached_config = config.current_config.endemic_life_UI; local cached_config = config.current_config.endemic_life_UI;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier; local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
for REcreature, creature in pairs(env_creature.list) do for REcreature, creature in pairs(env_creature.list) do
if cached_config.settings.max_distance == 0 then if cached_config.settings.max_distance == 0 then
break; break;

View File

@@ -91,8 +91,6 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
goto continue; goto continue;
end end
large_monster.update_position(enemy, monster);
if update_distance then if update_distance then
monster.distance = (players.myself_position - monster.position):length(); monster.distance = (players.myself_position - monster.position):length();
end end

View File

@@ -56,31 +56,11 @@ function this.draw()
local displayed_monsters = {}; local displayed_monsters = {};
local enemy_count = get_zako_enemy_count_method:call(singletons.enemy_manager); for enemy, monster in pairs(small_monster.list) do
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
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
goto continue; goto continue;
end; end;
small_monster.update_position(enemy, monster);
table.insert(displayed_monsters, monster); table.insert(displayed_monsters, monster);
::continue:: ::continue::
end end
@@ -147,7 +127,7 @@ function this.draw()
position_on_screen = draw.world_to_screen(monster.position + world_offset); position_on_screen = draw.world_to_screen(monster.position + world_offset);
if position_on_screen == nil then if position_on_screen == nil then
goto continue goto continue;
end end
position_on_screen.x = position_on_screen.x + cached_config.dynamic_positioning.viewport_offset.x; position_on_screen.x = position_on_screen.x + cached_config.dynamic_positioning.viewport_offset.x;
@@ -169,7 +149,7 @@ function this.draw()
end end
if monster.distance > cached_config.dynamic_positioning.max_distance then if monster.distance > cached_config.dynamic_positioning.max_distance then
goto continue goto continue;
end end
if cached_config.dynamic_positioning.opacity_falloff then if cached_config.dynamic_positioning.opacity_falloff then