Currency&&Shop System

The Generic Inventory System (GIS) provides a complete currency and shop system, laying the foundation for building an in-game economy.

通用库存系统.封面
罗传月武(YueWu)

Author

罗传月武(YueWu)

专注游戏开发和Web技术。

Created: Jul 17, 2025Updated: Sep 15, 2026

Table of contents

Overview

The Generic Inventory System (GIS) provides a complete currency and shop system, laying the foundation for building an in-game economy.

Currency System

Currency System Component

To enable in-game units to hold currency, add the GIS_CurrencySystemcomponent and set the default currency it holds.

货币系统.组件默认设置

Currency Definition

Create a new currency type by creating a GIS_CurrencyDefinition data asset.

货币系统.定义货币

Note

Currency Exchange feature will available in subsequent version of GIS.

Adding Currency to Items

To enable items to be bought or sold in shops, add the "Shoppable Settings" fragment to the item definition, specifying the currency required for purchase and the currency gained from selling.

货币系统.为道具添加货币

Currency System API

These APIs allow you to add, remove, update, or query currency through the currency system. You can access all currency system APIs via GIS|CurrencySystem.

Loading Blueprint

Initializing BlueprintUE renderer...

Currency UI

GIS provides a reusable WB_GIS_CurrencyContainer widget that can:

  • Monitor currency changes for a specified currency on any Actor and display its amount.
  • Support vertical or horizontal display.
  • Show current value, current/maximum value, or static display (e.g., for crafting item costs).
货币系统.UI货币容器

This widget can be used in any widget requiring currency information display.

Shop System

GIS offers a multiplayer-compatible interactive shop system, allowing multiple players to buy and sell with vendors simultaneously.

Shop System Component

To create a tradable NPC in-game, you need:

  • GIS_InventorySystemComponent: Stores all items available for sale in the shop.
  • GIS_CurrencySystemComponent: Holds the shop’s currency for transaction settlements.
  • GIS_ShopSystemComponent: Handles the shop’s buy/sell logic.

The buyer (typically the player) requires:

  • GIS_InventorySystemComponent: To receive purchased items or deduct sold items.
  • GIS_CurrencySystemComponent: To pay for purchases or receive sale proceeds.
商店系统.组件默认设置

The shop system component handle logic with minimal setup. Check the BP_GIS_Vendor in the companion project for a complete setup example.

Shop API

Access all shop APIs via GIS|ShopSystem.

Loading Blueprint

Initializing BlueprintUE renderer...

Typically, you only need to call these APIs in interaction logic related to "trading." See GA_GIS_Interaction_Vendorfor more details.

Price Modifer Mechanism

Each ShopSystem can specify a price modifier, adjusting the overall price for buying or selling items. This enables:

  • Different prices for item types in different regions, supporting a "merchant trading" mechanic.
  • Price variations based on the player’s rapport with a vendor.

For dynamic price modifier , simply implement the relevant function.

cpp
1 /**
2 * Gets the buy price modifier for the buyer.
3 * 获取买家的购买价格浮动。
4 * @param BuyerInventory The buyer's inventory component. 买家的库存组件。
5 * @return The buy price modifier. 购买价格浮动值。
6 * @details Can be overridden to implement a dynamic pricing system based on game mechanics. 可覆写以基于游戏机制实现动态价格系统。
7 */
8 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|ShopSystem")
9 float GetBuyModifierForBuyer(UGIS_InventorySystemComponent* BuyerInventory) const;
10
11 /**
12 * Gets the sell price modifier for the seller.
13 * 获取卖家的出售价格浮动。
14 * @param SellerInventory The seller's inventory component. 卖家的库存组件。
15 * @return The sell price modifier. 出售价格浮动值。
16 * @details Can be overridden to implement a dynamic pricing system based on game mechanics, such as supply shortages. 可覆写以基于游戏机制(如缺货)实现动态价格系统。
17 */
18 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|ShopSystem")
19 float GetSellModifierForSeller(UGIS_InventorySystemComponent* SellerInventory) const;

Shop Menu

The buy and sell menus are variants of WB_GIS_InventoryMenu, with distinct display and logic in the "vendor" context.

GIS also provides WB_GIS_ShopMenu, which functions as a modal ui, allowing secondary confirmation for purchased/sold items and displaying the currency to be gained or paid.

商店系统.商店菜单