From f7179fb7e6b740ddc7f6260d592e3c343f60d512 Mon Sep 17 00:00:00 2001
From: praydog <praydog@praydog.com>
Date: Sat, 20 Jul 2024 21:00:11 -0700
Subject: [PATCH] VR (Kunitsu-Gami): Fix some world space icons

---
 src/mods/VR.cpp | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp
index 5970f2e3..1e5e1374 100644
--- a/src/mods/VR.cpp
+++ b/src/mods/VR.cpp
@@ -2721,12 +2721,16 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
                         static auto mhrise_speech_balloon_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonNpcSpeechBalloon"));
                         static auto mhrise_head_message_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonHeadMessage"));
                         static auto mhrise_otomo_head_message_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonOtomoHeadMessage"));
+                        static auto kg_float_icon_behavior = sdk::find_type_definition("app.FloatIconBehavior");
+                        static auto kg_general_vital_gauge_behavior = sdk::find_type_definition("app.GeneralVitalGaugeBehavior");
 
                         static auto gameobject_elements_list = {
                             mhrise_npc_head_message_typedef,
                             mhrise_speech_balloon_typedef,
                             mhrise_head_message_typedef,
-                            mhrise_otomo_head_message_typedef
+                            mhrise_otomo_head_message_typedef,
+                            kg_float_icon_behavior,
+                            kg_general_vital_gauge_behavior
                         };
                         
                         // Fix position of interaction icons
@@ -2769,6 +2773,8 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
                                 if (parent != nullptr) {
                                     Vector4f offset{};
 
+                                    std::optional<float> custom_ui_scale = std::nullopt;
+
                                     if (element_type == mhrise_speech_balloon_typedef) {
                                         static auto pos_data_field = mhrise_speech_balloon_typedef->get_field("posData");
                                         static auto npc_message_pos = pos_data_field->get_type()->get_field("NpcMessagePos");
@@ -2800,9 +2806,33 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
                                         offset = Vector4f{0.0f, y_offset, 0.0f, 0.0f};
                                     } else if (element_type == mhrise_otomo_head_message_typedef) { //airou and dog
                                         offset = Vector4f{0.0, 1.0f, 0.0f, 0.0f};
+                                    } else if (element_type == kg_float_icon_behavior) {
+                                        static auto param_field = kg_float_icon_behavior->get_field("_Param");
+                                        static auto world_pos_field = param_field != nullptr ? param_field->get_type()->get_field("WorldPos") : nullptr;
+
+                                        if (world_pos_field != nullptr) {
+                                            auto param = param_field->get_data<::REManagedObject*>(element_comp);
+
+                                            if (param != nullptr) {
+                                                offset = world_pos_field->get_data<Vector4f>(param);
+                                                custom_ui_scale = 5.0f;
+                                            }
+                                        }
+                                    } else if (element_type == kg_general_vital_gauge_behavior) {
+                                        static auto param_field = kg_general_vital_gauge_behavior->get_field("_OpenParam");
+                                        static auto world_pos_field = param_field != nullptr ? param_field->get_type()->get_field("WorldPos") : nullptr;
+
+                                        if (world_pos_field != nullptr) {
+                                            auto param = param_field->get_data<::REManagedObject*>(element_comp);
+
+                                            if (param != nullptr) {
+                                                offset = world_pos_field->get_data<Vector4f>(param);
+                                                custom_ui_scale = 5.0f;
+                                            }
+                                        }
                                     }
 
-                                    fix_2d_position(sdk::get_transform_position(parent) + offset);
+                                    fix_2d_position(sdk::get_transform_position(parent) + offset, true, custom_ui_scale);
                                 } else {
                                     fix_2d_position(original_game_object_pos);
                                 }