From 66110441ae1d4aee6dcf1f576904de8ec1981b9c Mon Sep 17 00:00:00 2001 From: DarkPenguin <96709220+DarkPenguin24@users.noreply.github.com> Date: Sat, 5 Feb 2022 05:29:02 +0100 Subject: [PATCH] Fix vent unlocking (#292) * #261: Disable Vent Button for GA * #261: Unlock Vents for Engineers --- appdata/il2cpp-types.h | 1 + hooks/HudManager.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/appdata/il2cpp-types.h b/appdata/il2cpp-types.h index b5858f2f..d18cdcb5 100644 --- a/appdata/il2cpp-types.h +++ b/appdata/il2cpp-types.h @@ -7386,6 +7386,7 @@ namespace app #endif struct AbilityButtonSettings* Ability; struct AudioClip* UseSound; + struct AudioClip* IntroSound; struct PlayerControl* Player; }; diff --git a/hooks/HudManager.cpp b/hooks/HudManager.cpp index e3bd2db8..615a17be 100644 --- a/hooks/HudManager.cpp +++ b/hooks/HudManager.cpp @@ -28,14 +28,16 @@ void dHudManager_Update(HudManager* __this, MethodInfo* method) { //HudManager_SetHudActive(__this, State.ShowHud, NULL); if (IsInGame()) { + auto localData = GetPlayerData(*Game::pLocalPlayer); GameObject* shadowLayerObject = Component_get_gameObject((Component_1*)__this->fields.ShadowQuad, NULL); GameObject_SetActive(shadowLayerObject, - !(State.FreeCam || State.EnableZoom || State.playerToFollow.has_value() || State.Wallhack) && !GetPlayerData(*Game::pLocalPlayer)->fields.IsDead, + !(State.FreeCam || State.EnableZoom || State.playerToFollow.has_value() || State.Wallhack) && !localData->fields.IsDead, NULL); if (!State.InMeeting) { - app::RoleBehaviour *playerRole = GetPlayerData(*Game::pLocalPlayer)->fields.Role; + app::RoleBehaviour *playerRole = localData->fields.Role; + GameObject* ImpostorVentButton = app::Component_get_gameObject((Component_1*)__this->fields.ImpostorVentButton, NULL); if (playerRole->fields.Role == RoleTypes__Enum::Engineer && State.UnlockVents) { @@ -44,10 +46,13 @@ void dHudManager_Update(HudManager* __this, MethodInfo* method) { engineerRole->fields.cooldownSecondsRemaining = 0.01f; //This will be deducted below zero on the next FixedUpdate call engineerRole->fields.inVentTimeRemaining = 30.0f; //Can be anything as it will always be written } + else if(playerRole->fields.Role == RoleTypes__Enum::GuardianAngel) + { + app::GameObject_SetActive(ImpostorVentButton, false, nullptr); + } else { - GameObject* ImpostorVentButton = app::Component_get_gameObject((Component_1*)__this->fields.ImpostorVentButton, NULL); - app::GameObject_SetActive(ImpostorVentButton, State.UnlockVents || PlayerIsImpostor(GetPlayerData(*Game::pLocalPlayer)), nullptr); + app::GameObject_SetActive(ImpostorVentButton, State.UnlockVents || PlayerIsImpostor(localData), nullptr); } } }