From 07842790a9c104934e2c17409fe3e32b9a0e7734 Mon Sep 17 00:00:00 2001 From: GreenComfyTea Date: Wed, 13 Jul 2022 17:58:00 +0300 Subject: [PATCH] Fix Endemic Life not working on Linux --- .../MHR_Overlay/Endemic_Life/env_creature.lua | 28 +++++++++++++------ .../Endemic_Life/env_creature_hook.lua | 16 +++++------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua index 4a4d138..ae16a33 100644 --- a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua +++ b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua @@ -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 diff --git a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua index e8d7f4f..bac3284 100644 --- a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua +++ b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua @@ -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);