mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 04:48:22 -08:00
Functions and fields are cached, part names added, part name language support added.
This commit is contained in:
@@ -9,10 +9,11 @@ local rage_UI_entity;
|
||||
local body_part_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
local part_names;
|
||||
|
||||
body_part.list = {};
|
||||
|
||||
function body_part.new(REpart, id)
|
||||
function body_part.new(REpart, name, id)
|
||||
local part = {};
|
||||
|
||||
part.REpart = REpart;
|
||||
@@ -22,7 +23,7 @@ function body_part.new(REpart, id)
|
||||
part.max_health = 99999;
|
||||
part.health_percentage = 0;
|
||||
|
||||
part.name = "??";
|
||||
part.name = name;
|
||||
part.break_count = 0;
|
||||
|
||||
body_part.init_dynamic_UI(part);
|
||||
@@ -90,6 +91,7 @@ function body_part.init_module()
|
||||
body_part_UI_entity = require("MHR_Overlay.UI.UI_Entities.body_part_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
part_names = require("MHR_Overlay.Misc.part_names");
|
||||
end
|
||||
|
||||
return body_part;
|
||||
@@ -9,6 +9,7 @@ local rage_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
local body_part;
|
||||
local part_names;
|
||||
|
||||
large_monster.list = {};
|
||||
|
||||
@@ -213,7 +214,7 @@ local anger_param_get_timer_method = anger_param_type:get_method("get_Timer")
|
||||
local get_timer_anger_method = anger_param_type:get_method("get_TimerAnger")
|
||||
local get_count_anger_method = anger_param_type:get_method("get_CountAnger")
|
||||
|
||||
local get_gameobject_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject")
|
||||
local get_game_object_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject")
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform")
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position")
|
||||
|
||||
@@ -230,7 +231,7 @@ function large_monster.update_position(enemy)
|
||||
-- as these are pretty much guaranteed to stay constant
|
||||
-- as long as the enemy is alive
|
||||
if monster.game_object == nil then
|
||||
monster.game_object = get_gameobject_method:call(enemy)
|
||||
monster.game_object = get_game_object_method:call(enemy)
|
||||
if monster.game_object == nil then
|
||||
customization_menu.status = "No enemy game object";
|
||||
return;
|
||||
@@ -354,10 +355,6 @@ function large_monster.update(enemy)
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if part_health == last_REpart_health then
|
||||
break;
|
||||
end
|
||||
|
||||
local part_max_health = REpart:call("get_Max");
|
||||
if part_max_health == nil or part_max_health <= 0 then
|
||||
goto continue;
|
||||
@@ -365,8 +362,12 @@ function large_monster.update(enemy)
|
||||
|
||||
local part = monster.parts[REpart];
|
||||
if part == nil then
|
||||
part = body_part.new(REpart, part_id);
|
||||
monster.parts[REpart] = part;
|
||||
local part_name = part_names.get_part_name(monster.id, part_id);
|
||||
|
||||
if part_name ~= "" then
|
||||
part = body_part.new(REpart, part_name, part_id);
|
||||
monster.parts[REpart] = part;
|
||||
end
|
||||
end
|
||||
|
||||
body_part.update(part, part_health, part_max_health);
|
||||
@@ -473,7 +474,7 @@ function large_monster.draw_dynamic(monster, position_on_screen, opacity_scale)
|
||||
100 * monster.big_border, 100 * monster.king_border);
|
||||
end
|
||||
|
||||
drawing.draw_label(monster.dynamic_name_label, position_on_screen, opacity_scale, monster_name_text .. " " .. tostring(monster.id));
|
||||
drawing.draw_label(monster.dynamic_name_label, position_on_screen, opacity_scale, monster_name_text);
|
||||
|
||||
health_UI_entity.draw(monster, monster.health_dynamic_UI, position_on_screen, opacity_scale);
|
||||
stamina_UI_entity.draw(monster, monster.stamina_dynamic_UI, position_on_screen, opacity_scale);
|
||||
@@ -550,7 +551,7 @@ function large_monster.draw_static(monster, position_on_screen, opacity_scale)
|
||||
100 * monster.big_border, 100 * monster.king_border);
|
||||
end
|
||||
|
||||
drawing.draw_label(monster.static_name_label, position_on_screen, opacity_scale, monster_name_text .. " " .. tostring(monster.id));
|
||||
drawing.draw_label(monster.static_name_label, position_on_screen, opacity_scale, monster_name_text);
|
||||
|
||||
health_UI_entity.draw(monster, monster.health_static_UI, position_on_screen, opacity_scale);
|
||||
stamina_UI_entity.draw(monster, monster.stamina_static_UI, position_on_screen, opacity_scale);
|
||||
@@ -624,6 +625,7 @@ function large_monster.init_module()
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
part_names = require("MHR_Overlay.Misc.part_names");
|
||||
end
|
||||
|
||||
return large_monster;
|
||||
@@ -5,13 +5,14 @@ local large_monster;
|
||||
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
|
||||
local enemy_character_base_type_def_update_method = enemy_character_base_type_def:get_method("update");
|
||||
|
||||
local is_boss_enemy_method = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"):get_method("get_isBossEnemy");
|
||||
|
||||
sdk.hook(enemy_character_base_type_def_update_method, function(args)
|
||||
monster.update_monster(sdk.to_managed_object(args[2]));
|
||||
end, function(retval)
|
||||
return retval;
|
||||
end);
|
||||
|
||||
local is_boss_enemy_method = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"):get_method("get_isBossEnemy");
|
||||
local tick_count = 0
|
||||
local last_update_tick = 0
|
||||
local recorded_monsters = {}
|
||||
@@ -30,21 +31,18 @@ local MAX_UPDATES_PER_TICK = 2
|
||||
-- the reason for this is that the hooks on all the monsters' update functions
|
||||
-- causes a HUGE performance hit (adds ~3+ ms to UpdateBehavior and frame time)
|
||||
re.on_pre_application_entry("UpdateBehavior", function()
|
||||
tick_count = tick_count + 1
|
||||
updates_this_tick = 0
|
||||
tick_count = tick_count + 1;
|
||||
updates_this_tick = 0;
|
||||
|
||||
if num_known_monsters ~= 0 and
|
||||
num_updated_monsters >= num_known_monsters or
|
||||
tick_count >= num_known_monsters * 2
|
||||
then
|
||||
recorded_monsters = {}
|
||||
updated_monsters = {}
|
||||
known_big_monsters = {}
|
||||
last_update_tick = 0
|
||||
tick_count = 0
|
||||
num_known_monsters = 0
|
||||
num_updated_monsters = 0
|
||||
updates_this_tick = 0
|
||||
if num_known_monsters ~= 0 and num_updated_monsters >= num_known_monsters or tick_count >= num_known_monsters * 2 then
|
||||
recorded_monsters = {};
|
||||
updated_monsters = {};
|
||||
known_big_monsters = {};
|
||||
last_update_tick = 0;
|
||||
tick_count = 0;
|
||||
num_known_monsters = 0;
|
||||
num_updated_monsters = 0;
|
||||
updates_this_tick = 0;
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user