mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-23 20:08:05 -08:00
Add Endemic Life Head Tracking
This commit is contained in:
@@ -53,6 +53,29 @@ this.creature_ids = {
|
|||||||
gold_wirebug = 63,
|
gold_wirebug = 63,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local environment_creature_base_type_def = sdk.find_type_definition("snow.envCreature.EnvironmentCreatureBase");
|
||||||
|
local creature_type_field = environment_creature_base_type_def:get_field("_Type");
|
||||||
|
local creature_is_inactive_field = environment_creature_base_type_def:get_field("<Muteki>k__BackingField");
|
||||||
|
|
||||||
|
local message_manager_type_def = sdk.find_type_definition("snow.gui.MessageManager");
|
||||||
|
local get_env_creature_name_message_method = message_manager_type_def:get_method("getEnvCreatureNameMessage");
|
||||||
|
|
||||||
|
local get_pos_method = environment_creature_base_type_def:get_method("get_Pos");
|
||||||
|
|
||||||
|
local get_ref_mesh_method = environment_creature_base_type_def:get_method("getMesh");
|
||||||
|
|
||||||
|
local mesh_type_def = get_ref_mesh_method:get_return_type();
|
||||||
|
local get_game_object_method = mesh_type_def:get_method("get_GameObject");
|
||||||
|
|
||||||
|
local game_object_type_def = get_game_object_method:get_return_type();
|
||||||
|
local get_transform_method = game_object_type_def:get_method("get_Transform");
|
||||||
|
|
||||||
|
local transform_type_def = get_transform_method:get_return_type();
|
||||||
|
local get_joint_by_name_method = transform_type_def:get_method("getJointByName");
|
||||||
|
|
||||||
|
local joint_type_def = get_joint_by_name_method:get_return_type();
|
||||||
|
local get_position_method = joint_type_def:get_method("get_Position");
|
||||||
|
|
||||||
function this.new(REcreature)
|
function this.new(REcreature)
|
||||||
local creature = {};
|
local creature = {};
|
||||||
|
|
||||||
@@ -81,15 +104,6 @@ function this.get_creature(REcreature)
|
|||||||
return this.list[REcreature];
|
return this.list[REcreature];
|
||||||
end
|
end
|
||||||
|
|
||||||
local environment_creature_base_type_def = sdk.find_type_definition("snow.envCreature.EnvironmentCreatureBase");
|
|
||||||
local creature_type_field = environment_creature_base_type_def:get_field("_Type");
|
|
||||||
local creature_is_inactive_field = environment_creature_base_type_def:get_field("<Muteki>k__BackingField");
|
|
||||||
|
|
||||||
local message_manager_type_def = sdk.find_type_definition("snow.gui.MessageManager");
|
|
||||||
local get_env_creature_name_message_method = message_manager_type_def:get_method("getEnvCreatureNameMessage");
|
|
||||||
|
|
||||||
local get_pos_method = environment_creature_base_type_def:get_method("get_Pos");
|
|
||||||
|
|
||||||
function this.init(creature, REcreature)
|
function this.init(creature, REcreature)
|
||||||
local creature_type = creature_type_field:get_data(REcreature);
|
local creature_type = creature_type_field:get_data(REcreature);
|
||||||
if creature_type == nil then
|
if creature_type == nil then
|
||||||
@@ -105,6 +119,8 @@ function this.init(creature, REcreature)
|
|||||||
|
|
||||||
creature.name = creature_name;
|
creature.name = creature_name;
|
||||||
creature.id = creature_type;
|
creature.id = creature_type;
|
||||||
|
|
||||||
|
this.update_head_joint(REcreature, creature)
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.init_UI(creature)
|
function this.init_UI(creature)
|
||||||
@@ -131,6 +147,8 @@ function this.update_position(REcreature, creature)
|
|||||||
end
|
end
|
||||||
|
|
||||||
creature.position = position;
|
creature.position = position;
|
||||||
|
|
||||||
|
this.update_head_position(REcreature, creature);
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.update(REcreature, creature)
|
function this.update(REcreature, creature)
|
||||||
@@ -150,6 +168,70 @@ function this.update(REcreature, creature)
|
|||||||
creature.is_inactive = is_inactive;
|
creature.is_inactive = is_inactive;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.update_head_joint(REcreature, creature)
|
||||||
|
local mesh = get_ref_mesh_method:call(REcreature);
|
||||||
|
if mesh == nil then
|
||||||
|
error_handler.report("env_creature.update_head_joint", "Failed to Access Data: Mesh");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local game_object = get_game_object_method:call(mesh);
|
||||||
|
if game_object == nil then
|
||||||
|
error_handler.report("env_creature.update_head_joint", "Failed to Access Data: GameObject");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local transform = get_transform_method:call(game_object);
|
||||||
|
if transform == nil then
|
||||||
|
error_handler.report("env_creature.update_head_joint", "Failed to Access Data: Transform");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local head_joint = get_joint_by_name_method:call(transform, "Head_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "Head")
|
||||||
|
or get_joint_by_name_method:call(transform, "Head_01")
|
||||||
|
or get_joint_by_name_method:call(transform, "Spine_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "Body_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "body_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "Cog")
|
||||||
|
or get_joint_by_name_method:call(transform, "Cog_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "head")
|
||||||
|
or get_joint_by_name_method:call(transform, "root");
|
||||||
|
|
||||||
|
if head_joint == nil then
|
||||||
|
-- local out = "";
|
||||||
|
-- local joints = transform:get_Joints();
|
||||||
|
|
||||||
|
-- for i = 0, joints:get_Length() - 1 do
|
||||||
|
-- local joint = joints[i];
|
||||||
|
-- local joint_name = joint:get_Name();
|
||||||
|
|
||||||
|
-- out = out .. joint_name .. "\n";
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- error_handler.report(creature.name, out);
|
||||||
|
|
||||||
|
error_handler.report("small_monster.update_head_joint", "Failed to Access Data: HeadJoint");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
creature.head_joint = head_joint;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.update_head_position(REcreature, creature)
|
||||||
|
if creature.head_joint == nil then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local head_position = get_position_method:call(creature.head_joint);
|
||||||
|
if head_position == nil then
|
||||||
|
error_handler.report("env_creature.update_head_position", "Failed to Access Data: HeadPosition");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
creature.head_position = head_position;
|
||||||
|
end
|
||||||
|
|
||||||
function this.draw(creature, position_on_screen, opacity_scale)
|
function this.draw(creature, position_on_screen, opacity_scale)
|
||||||
if d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available then
|
if d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||||
local text_width, text_height = drawing.font:measure(creature.name);
|
local text_width, text_height = drawing.font:measure(creature.name);
|
||||||
|
|||||||
@@ -7457,6 +7457,7 @@ function this.init_default()
|
|||||||
enabled = false,
|
enabled = false,
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
|
head_tracking = true,
|
||||||
hide_inactive_creatures = true,
|
hide_inactive_creatures = true,
|
||||||
max_distance = 300,
|
max_distance = 300,
|
||||||
opacity_falloff = true
|
opacity_falloff = true
|
||||||
|
|||||||
@@ -526,7 +526,9 @@ function this.update_head_joint(enemy, monster)
|
|||||||
|
|
||||||
local head_joint = get_joint_by_name_method:call(transform, "Head_00")
|
local head_joint = get_joint_by_name_method:call(transform, "Head_00")
|
||||||
or get_joint_by_name_method:call(transform, "Head")
|
or get_joint_by_name_method:call(transform, "Head")
|
||||||
|
or get_joint_by_name_method:call(transform, "Head_01")
|
||||||
or get_joint_by_name_method:call(transform, "Spine_00")
|
or get_joint_by_name_method:call(transform, "Spine_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "Cog")
|
||||||
or get_joint_by_name_method:call(transform, "head")
|
or get_joint_by_name_method:call(transform, "head")
|
||||||
or get_joint_by_name_method:call(transform, "root");
|
or get_joint_by_name_method:call(transform, "root");
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,9 @@ function this.update_head_joint(enemy, monster)
|
|||||||
|
|
||||||
local head_joint = get_joint_by_name_method:call(transform, "Head_00")
|
local head_joint = get_joint_by_name_method:call(transform, "Head_00")
|
||||||
or get_joint_by_name_method:call(transform, "Head")
|
or get_joint_by_name_method:call(transform, "Head")
|
||||||
|
or get_joint_by_name_method:call(transform, "Head_01")
|
||||||
or get_joint_by_name_method:call(transform, "Spine_00")
|
or get_joint_by_name_method:call(transform, "Spine_00")
|
||||||
|
or get_joint_by_name_method:call(transform, "Cog")
|
||||||
or get_joint_by_name_method:call(transform, "head")
|
or get_joint_by_name_method:call(transform, "head")
|
||||||
or get_joint_by_name_method:call(transform, "root");
|
or get_joint_by_name_method:call(transform, "root");
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,12 @@ function this.draw()
|
|||||||
cached_config.world_offset.z
|
cached_config.world_offset.z
|
||||||
);
|
);
|
||||||
|
|
||||||
local position_on_screen = draw.world_to_screen(creature.position + world_offset);
|
local position_on_screen;
|
||||||
|
if cached_config.settings.head_tracking then
|
||||||
|
position_on_screen = draw.world_to_screen(creature.head_position + world_offset);
|
||||||
|
else
|
||||||
|
position_on_screen = draw.world_to_screen(creature.position + world_offset);
|
||||||
|
end
|
||||||
|
|
||||||
if position_on_screen == nil then
|
if position_on_screen == nil then
|
||||||
goto continue;
|
goto continue;
|
||||||
|
|||||||
@@ -2310,6 +2310,11 @@ function this.draw_endemic_life_UI()
|
|||||||
config_changed = config_changed or changed;
|
config_changed = config_changed or changed;
|
||||||
|
|
||||||
if imgui.tree_node(language.current_language.customization_menu.settings) then
|
if imgui.tree_node(language.current_language.customization_menu.settings) then
|
||||||
|
changed, cached_config.settings.head_tracking = imgui.checkbox(
|
||||||
|
language.current_language.customization_menu.head_tracking, cached_config.settings.head_tracking);
|
||||||
|
|
||||||
|
config_changed = config_changed or changed;
|
||||||
|
|
||||||
changed, cached_config.settings.hide_inactive_creatures = imgui.checkbox(
|
changed, cached_config.settings.hide_inactive_creatures = imgui.checkbox(
|
||||||
language.current_language.customization_menu.hide_inactive_creatures, cached_config.settings.hide_inactive_creatures);
|
language.current_language.customization_menu.hide_inactive_creatures, cached_config.settings.hide_inactive_creatures);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user