Move highlight_id to large_monster from draw function

This commit is contained in:
GreenComfyTea
2023-08-06 12:17:06 +03:00
parent 972d874a99
commit 3e508c0e28
2 changed files with 45 additions and 19 deletions

View File

@@ -54,6 +54,7 @@ local ValueType = ValueType;
local package = package;
this.list = {};
this.higlighted_id = -1;
function this.new(enemy)
local monster = {};
@@ -258,6 +259,12 @@ local core_parts_get_is_active_method = enemy_mystery_core_parts_type_def:get_me
local core_parts_get_dying_vital_threashold_method = enemy_mystery_core_parts_type_def:get_method("get_DyingVitalThreashold");
local on_break_method = enemy_mystery_core_parts_type_def:get_method("onBreak");
local gui_manager_type_def = sdk.find_type_definition("snow.gui.GuiManager");
local get_tg_camera_method = gui_manager_type_def:get_method("get_refGuiHud_TgCamera");
local tg_camera_type_def = get_tg_camera_method:get_return_type();
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
function this.init(monster, enemy)
local enemy_type = enemy_type_field:get_data(enemy);
if enemy_type == nil then
@@ -1128,6 +1135,35 @@ function this.update_anomaly_parts(enemy, monster, mystery_param)
end
end
function this.update_higlighted_id()
if singletons.gui_manager == nil then
error_handler.report("large_monster.update_higlighted_id", "Failed to Access Data: gui_manager");
return;
end
--xy = xy .. tostring(1.2) .. "\n";
--xy = xy .. tostring(get_tg_camera_method) .. "\n";
--xy = xy .. tostring(singletons.gui_manager) .. "\n";
local gui_hud_target_camera = get_tg_camera_method:call(singletons.gui_manager);
--xy = xy .. tostring(1.3) .. "\n";
if gui_hud_target_camera == nil then
error_handler.report("large_monster.update_higlighted_id", "Failed to Access Data: gui_hud_target_camera");
return;
end
--xy = xy .. tostring(1.4) .. "\n";
local highlighted_id = get_targeting_enemy_index_field:get_data(gui_hud_target_camera);
--xy = xy .. tostring(1.5) .. "\n";
if highlighted_id == nil then
-- xy = xy .. tostring(1.6) .. "\n";
error_handler.report("large_monster_UI.update_higlighted_id", "Failed to Access Data: highlighted_id");
return;
end
this.highlighted_id = highlighted_id;
--xy = xy .. tostring(1.8) .. "\n";
end
function this.draw(monster, type, cached_config, position_on_screen, opacity_scale)
local monster_UI;
@@ -1254,6 +1290,7 @@ function this.init_dependencies()
end
function this.init_module()
time.new_timer(this.update_higlighted_id, 1/30);
end
return this;

View File

@@ -69,22 +69,9 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
and (cached_config.highlighted.auto_highlight.mode == "Closest" or cached_config.highlighted.auto_highlight.mode == "Furthest")
);
local highlighted_id = -1;
local monster_id_shift = 0;
local highlighted_monster = nil;
if not cached_config.highlighted.auto_highlight.enabled and singletons.gui_manager ~= nil then
local gui_hud_target_camera = get_tg_camera_method:call(singletons.gui_manager);
if gui_hud_target_camera ~= nil then
highlighted_id = get_targeting_enemy_index_field:get_data(gui_hud_target_camera);
if highlighted_id == nil then
error_handler.report("large_monster_UI.draw", "Failed to Access Data: highlighted_id");
highlighted_id = -1;
end
end
end
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
if enemy_count == nil then
error_handler.report("large_monster_UI.draw", "Failed to Access Data: enemy_count");
@@ -98,12 +85,14 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
goto continue;
end
local monster = large_monster.list[enemy];
local monster = large_monster.get_monster(enemy);
if monster == nil then
error_handler.report("large_monster_UI.draw", "Missing Entry: monster No. " .. tostring(i));
error_handler.report("large_monster_UI.draw", "Failed to Create Large Monster Entry No. " .. tostring(i));
goto continue;
end
large_monster.update_position(enemy, monster);
if update_distance then
monster.distance = (players.myself_position - monster.position):length();
end
@@ -146,7 +135,7 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
monster_id_shift = monster_id_shift + 1;
elseif i == highlighted_id + monster_id_shift then
elseif i == large_monster.highlighted_id + monster_id_shift then
highlighted_monster = monster;
end
end
@@ -168,7 +157,7 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
error_handler.report("large_monster_UI.draw", "Highlighted Large Monster drawing function threw an exception");
end
end
if static_enabled then
local success = pcall(this.draw_static, displayed_monsters, highlighted_monster, cached_config);
if not success then
@@ -212,7 +201,7 @@ function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_confi
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.viewport_offset.x * global_scale_modifier;
@@ -220,7 +209,7 @@ function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_confi
local opacity_scale = 1;
if monster.distance > cached_config.settings.max_distance then
goto continue
goto continue;
end
if cached_config.settings.opacity_falloff then