Skip to content

Commit 7da6917

Browse files
authored
Add UpdateCharacterSheet to NwPlayer. (#814)
1 parent 79842c1 commit 7da6917

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

NWN.Anvil/src/main/API/Objects/NwPlayer.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,36 @@ public void UnpossessCreature()
16851685
Player.PossessCreature(NwObject.Invalid, (byte)NWN.Native.API.AssociateType.None);
16861686
}
16871687

1688+
/// <summary>
1689+
/// Refreshes the player's character sheet.
1690+
/// </summary>
1691+
public async Task UpdateCharacterSheet()
1692+
{
1693+
await NwTask.Delay(TimeSpan.FromSeconds(0.5f));
1694+
if (!IsValid)
1695+
{
1696+
return;
1697+
}
1698+
1699+
CNWSPlayerCharSheetGUI? charSheet = Player.m_pCharSheetGUI;
1700+
if (charSheet == null)
1701+
{
1702+
return;
1703+
}
1704+
1705+
uint updatesRequired = charSheet.ComputeCharacterSheetUpdateRequired(Player);
1706+
if (updatesRequired == 0)
1707+
{
1708+
return;
1709+
}
1710+
1711+
CNWSMessage? message = LowLevel.ServerExoApp.GetNWSMessage();
1712+
if (message != null)
1713+
{
1714+
message.WriteGameObjUpdate_CharacterSheet(Player, updatesRequired);
1715+
}
1716+
}
1717+
16881718
/// <summary>
16891719
/// Vibrates the player's device or controller. Does nothing if vibration is not supported.
16901720
/// </summary>

0 commit comments

Comments
 (0)