-
-
Notifications
You must be signed in to change notification settings - Fork 1
Custom HUD Best Practices
Interested in creating a custom HUD for the Inventory? Here are some things that should help you.
Avoid calling any PlayerCompanion functions and accessors before the Companion.IsReady property is set to true. This will make sure that all of the external DLLs of other mods are loaded and that we are able to restore the items from the inventory files.
The Companion.Ready event will be triggered once PlayerCompanion is ready to work. You can use this event if you want to avoid constantly checking the Companion.IsReady property.
PlayerCompanion has events for detecting when an Item is Added or Removed. This two events will be triggered from any player inventory, meaning that you can use them to add and remove visible items from your on screen HUD at any time. They are Companion.Inventory.ItemAdded and Companion.Inventory.ItemRemoved.
It is not recommended to use the CountChanged event of Stackable Item's when implementing custom HUDs, unless you need to format a string with the current item count.
A good example is the stock Inventory Menu, where the count is formated in a string like {name} ({count})
.