Allow name billboards to be toggled (#1026)

* Allow name billboards to be toggled

* Allow name billboards to be toggled

* Add comments

* Move logic to Character

* Use Entity in Character instead
This commit is contained in:
David Markowitz
2023-03-23 07:49:31 -07:00
committed by GitHub
parent 7671cc6865
commit b967cc57d1
8 changed files with 77 additions and 0 deletions

View File

@@ -621,3 +621,21 @@ void Character::SendMuteNotice() const {
ChatPackets::SendSystemMessage(GetEntity()->GetSystemAddress(), u"You are muted until " + timeStr);
}
void Character::SetBillboardVisible(bool visible) {
if (m_BillboardVisible == visible) return;
m_BillboardVisible = visible;
GameMessages::SendSetNamebillboardState(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID());
if (!visible) return;
// The GameMessage we send for turning the nameplate off just deletes the BillboardSubcomponent from the parent component.
// Because that same message does not allow for custom parameters, we need to create the BillboardSubcomponent a different way
// This workaround involves sending an unrelated GameMessage that does not apply to player entites,
// but forces the client to create the necessary SubComponent that controls the billboard.
GameMessages::SendShowBillboardInteractIcon(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID());
// Now turn off the billboard for the owner.
GameMessages::SendSetNamebillboardState(m_OurEntity->GetSystemAddress(), m_OurEntity->GetObjectID());
}