Economy Fragment
The Economy fragment enables an item to be bought or sold by inventory owners. It defines both unitary prices and total prices, calculated based on stack size, if applicable.
The system handles wealth validation, Gameplay Effect application, and memory transfer during transactions.
Fragment Tags
This fragment does not contribute any tags by default. However, it interacts with the Wealth attribute (or another attribute set), and may broadcast events based on inventory changes (such as adding/removing items).
Properties
This fragment has the following property.
Property | Description |
|---|---|
| Whether the item can be bought by a target inventory manager. |
| If |
| Price for one unit of the item (if |
| Whether the item can be sold to a target inventory manager. |
| Price for one unit of the item (if |
| Gameplay attribute used to read and apply wealth during purchases. |
| Determines if wealth is changed using a Gameplay Effect or directly modifying the Gameplay Attribute. |
| Gameplay Effect class applied when wealth changes occur. |
While deciding the best WealthChangeMode for your project, please consider the following table with pros and cons, so you can consider them against your design requirements.
Gameplay Effect
✅ Supports Gameplay Effect prediction systems.
✅ Integrates with Attribute Set pre-change and post-change hooks.
✅ Allows extensions via tags, conditions, and custom calculations.
❌ Slightly more expensive in terms of performance.
Direct Attribute
✅ Simple and efficient; applies changes directly.
✅ Requires no additional assets or setup.
❌ Bypasses modifiers and other GAS mechanics.
❌ Does not trigger attribute gameplay events or tag-based effects.
Use Gameplay Effect when you want rich GAS integration and modifiers. Use Direct Attribute when you need quick, lightweight transactions without complex behavior.
Operations
This fragment exposes the following operations.
Function | Description |
|---|---|
| Returns |
| Returns |
| Checks if the target manager has enough wealth to buy the item. |
| Checks if the item can be sold by the source manager to the target. |
| Returns the unitary buy price. |
| Returns the unitary sell price. |
| Returns total buy price considering stack. |
| Returns total sell price considering stack. |
| Transfers item to the target and deducts wealth, if valid. |
| Transfers item to the target and adds wealth to source, if valid. |
Memory
This fragment does not define or use a memory struct. Instead, it interacts with other systems such as the Stack fragment and the inventory manager's wealth state.
Event Payload
This fragment does not define its own event or payload structure. However, events may be triggered indirectly through:
Inventory item additions and removals.
Wealth changes via Gameplay Effects.
Stack size changes when items are split or merged during transactions.