Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
fixed crash & added role under name
Browse files Browse the repository at this point in the history
  • Loading branch information
kotae4 committed Nov 21, 2021
1 parent f461e3d commit cb1b462
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions appdata/il2cpp-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ DO_APP_FUNC(bool, EOSManager_IsFreechatAllowed, (EOSManager* __this, MethodInfo*

DO_APP_FUNC(void, TextMeshPro_SetFaceColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetFaceColor(UnityEngine.Color32)");
DO_APP_FUNC(void, TextMeshPro_SetOutlineColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetOutlineColor(UnityEngine.Color32)");
DO_APP_FUNC(void, TMP_Text_set_text, (TMP_Text* __this, String* value, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TMP_Text::set_text(System.String)");
DO_APP_FUNC(Color32, Color32_op_Implicit, (Color c, MethodInfo* method), "UnityEngine.CoreModule, UnityEngine.Color32 UnityEngine.Color32::op_Implicit(UnityEngine.Color)");

DO_APP_FUNC(void, RoleManager_AssignRolesForTeam, (List_1_GameData_PlayerInfo_* players, RoleOptionsData* opts, RoleTeamTypes__Enum team, int32_t teamMax, Nullable_1_RoleTypes_ defaultRole, MethodInfo* method), "Assembly-CSharp, System.Void RoleManager::AssignRolesForTeam(System.Collections.Generic.List<GameData.PlayerInfo>, RoleOptionsData, RoleTeamTypes, System.Int32, System.Nullable<RoleTypes>)");
Expand Down
2 changes: 1 addition & 1 deletion gui/radar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Radar {
ImU32 GetRadarPlayerColorStatus(GameData_PlayerInfo* playerData) {
if (playerData->fields.IsDead)
return ImGui::ColorConvertFloat4ToU32(AmongUsColorToImVec4(app::Palette__TypeInfo->static_fields->HalfWhite));
else if (State.RevealRoles && playerData->fields.Role->fields.StringName != StringNames__Enum::Crewmate)
else if (State.RevealRoles && playerData->fields.Role != nullptr && playerData->fields.Role->fields.StringName != StringNames__Enum::Crewmate)
return ImGui::ColorConvertFloat4ToU32(AmongUsColorToImVec4(GetRoleColor(playerData->fields.Role)));
else
return ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, 0));
Expand Down
4 changes: 4 additions & 0 deletions hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
if (State.RevealRoles || PlayerIsImpostor(localData)) {
Color32 c = app::Color32_op_Implicit(GetRoleColor(playerData->fields.Role), NULL);

std::string playerName = convert_from_string(GetPlayerOutfit(playerData)->fields._playerName);
playerName += "\n(" + GetRoleName(playerData->fields.Role) + ")";
String* playerNameStr = convert_to_string(playerName);
app::TMP_Text_set_text((app::TMP_Text*)nameTextTMP, playerNameStr, NULL);

app::TextMeshPro_SetFaceColor(nameTextTMP, c, NULL);
app::TextMeshPro_SetOutlineColor(nameTextTMP, faceColor, NULL);
Expand Down
2 changes: 1 addition & 1 deletion user/gitparams.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define GIT_CUR_COMMIT 6e947b3dd8cd233548f0f53125783fc89e91dd47
#define GIT_CUR_COMMIT f461e3dc6034da2d0e8179086ec67e01f31a7579
#define GIT_BRANCH 2021.11.9.5e
8 changes: 8 additions & 0 deletions user/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,18 @@ GameData_PlayerOutfit* GetPlayerOutfit(GameData_PlayerInfo* player) {
}

bool PlayerIsImpostor(GameData_PlayerInfo* player) {

if (player->fields.Role == nullptr) return false;

RoleBehaviour* role = player->fields.Role;
return role->fields.Role == RoleTypes__Enum::Impostor;
}


Color GetRoleColor(RoleBehaviour* roleBehaviour) {

if (roleBehaviour == nullptr) return Palette__TypeInfo->static_fields->White;

app::Color c;
switch (roleBehaviour->fields.Role) {
case RoleTypes__Enum::Engineer:
Expand Down Expand Up @@ -638,6 +644,8 @@ Color GetRoleColor(RoleBehaviour* roleBehaviour) {

std::string GetRoleName(RoleBehaviour* roleBehaviour)
{
if (roleBehaviour == nullptr) return "Unknown";

switch (roleBehaviour->fields.Role)
{
case RoleTypes__Enum::Engineer:
Expand Down

0 comments on commit cb1b462

Please sign in to comment.