Fix Endemic Life not working on Linux

This commit is contained in:
GreenComfyTea
2022-07-13 17:58:00 +03:00
parent 61756068f7
commit 07842790a9
2 changed files with 26 additions and 18 deletions

View File

@@ -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

View File

@@ -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);