mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Fix Endemic Life not working on Linux
This commit is contained in:
@@ -14,8 +14,6 @@ function env_creature.new(REcreature)
|
||||
creature.name = "Env Creature";
|
||||
creature.is_inactive = true;
|
||||
|
||||
creature.game_object = nil;
|
||||
creature.transform = nil;
|
||||
creature.position = Vector3f.new(0, 0, 0);
|
||||
creature.distance = 0;
|
||||
|
||||
@@ -68,29 +66,41 @@ function env_creature.init_UI(creature)
|
||||
creature.name_label.offset.y = creature.name_label.offset.y * global_scale_modifier;
|
||||
end
|
||||
|
||||
function env_creature.update(REcreature)
|
||||
function env_creature.update_position(REcreature, creature)
|
||||
if not config.current_config.endemic_life_UI.enabled then
|
||||
return;
|
||||
end
|
||||
|
||||
local creature = env_creature.get_creature(REcreature);
|
||||
|
||||
if creature == nil then
|
||||
creature = env_creature.get_creature(REcreature);
|
||||
end
|
||||
|
||||
local position = get_pos_method:call(REcreature);
|
||||
if position ~= nil then
|
||||
creature.position = position;
|
||||
end
|
||||
end
|
||||
|
||||
function env_creature.update(REcreature, creature)
|
||||
if not config.current_config.endemic_life_UI.enabled then
|
||||
return;
|
||||
end
|
||||
|
||||
if creature == nil then
|
||||
creature = env_creature.get_creature(REcreature);
|
||||
end
|
||||
|
||||
local is_inactive = creature_is_inactive_field:get_data(REcreature);
|
||||
if is_inactive ~= nil then
|
||||
creature.is_inactive = is_inactive;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function env_creature.draw(creature, position_on_screen, opacity_scale)
|
||||
local text_width, text_height = drawing.font:measure(creature.name);
|
||||
|
||||
position_on_screen.x = position_on_screen.x - text_width / 2;
|
||||
if d2d ~= nil then
|
||||
local text_width, text_height = drawing.font:measure(creature.name);
|
||||
position_on_screen.x = position_on_screen.x - text_width / 2;
|
||||
end
|
||||
|
||||
drawing.draw_label(creature.name_label, position_on_screen, opacity_scale, creature.name);
|
||||
end
|
||||
|
||||
@@ -4,14 +4,12 @@ local config;
|
||||
local time;
|
||||
|
||||
local environment_creature_base_type_def = sdk.find_type_definition("snow.envCreature.EnvironmentCreatureBase");
|
||||
local environment_creature_base_update_method = environment_creature_base_type_def:get_method("update");
|
||||
local update_method = environment_creature_base_type_def:get_method("update");
|
||||
|
||||
function env_creature_hook.update_env_creature(REcreature)
|
||||
if not config.current_config.endemic_life_UI.enabled then
|
||||
return;
|
||||
end
|
||||
|
||||
env_creature.update(REcreature);
|
||||
function env_creature_hook.update(REcreature)
|
||||
local creature = env_creature.get_creature(REcreature);
|
||||
env_creature.update(REcreature, creature);
|
||||
env_creature.update_position(REcreature, creature);
|
||||
end
|
||||
|
||||
function env_creature_hook.init_module()
|
||||
@@ -19,8 +17,8 @@ function env_creature_hook.init_module()
|
||||
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
|
||||
time = require("MHR_Overlay.Game_Handler.time");
|
||||
|
||||
sdk.hook(environment_creature_base_update_method, function(args)
|
||||
pcall(env_creature_hook.update_env_creature, sdk.to_managed_object(args[2]));
|
||||
sdk.hook(update_method, function(args)
|
||||
pcall(env_creature_hook.update, sdk.to_managed_object(args[2]));
|
||||
end, function(retval)
|
||||
return retval;
|
||||
end);
|
||||
|
||||
Reference in New Issue
Block a user