if (同行检测) {
// 获取当前玩家的UID
std::string currentPlayerUID = Player->PlayerUID. ToString();
// 检查是否是同行玩家
bool isPeer = !playerUIDs.empty() &&
(std::find(playerUIDs.begin(), playerUIDs.end(), currentPlayerUID) != playerUIDs.end());
if (isPeer) {
// 设置文本内容和颜色
std::string displayText = "[同行] " + currentPlayerUID;
ImColor textColor = ImColor(255, 50, 50, 255); // 红色
// 计算文本尺寸
ImVec2 textSize = ImGui::CalcTextSize(displayText.c_str());
// 计算绘制位置(角色头顶上方)
float boxWidth = textSize.x + 10.0f;
float boxHeight = textSize.y + 4.0f;
float xPos = HeadPosSC.x - boxWidth/2.0f; // 水平居中
float yPos = HeadPosSC.y - 50.0f; // 头顶上方50像素
// 绘制背景框(半透明黑底)
draw->AddRectFilled(
{xPos, yPos},
{xPos + boxWidth, yPos + boxHeight},
ImColor(0, 0, 0, 180), // 半透明黑色
3.0f // 圆角
);
// 绘制边框(红色)
draw->AddRect(
{xPos, yPos},
{xPos + boxWidth, yPos + boxHeight},
ImColor(255, 0, 0, 255), // 红色边框
3.0f, // 圆角
0, // 无特殊标志
1.5f // 边框粗细
);
// 绘制文本(居中)
draw->AddText(
nullptr, // 使用默认字体
14.0f, // 字体大小
{xPos + 5.0f, yPos + 2.0f}, // 文本位置(带边距)
textColor,
displayText.c_str()
);
sprintf(extraa, "附近有同行!!!");
ImGui::GetForegroundDrawList()->AddText(NULL ,35,{glWidth ,115}, ImColor(0,0,0), extraa);
draw->AddRectFilled({glWidth,120},{glHeight,150},ImColor(255,0,0,255),100,0);//
}
}