Devlog: Refactoring Items and TraderActor - Ivan Shyika
Hi! Ivan is here again. I am the Team Leader, Project Manager, and Senior Developer on our game Return to Divinity. Today, I would like to tell you about the refactoring of the item/inventory system for Return to Divinity.
In my previous devlog from last week, I shared the design of the inventory system. In response to my post, my connection Jazmine Chargualaf shared with me the Working with Data in Unreal Engine 5 presentation by Jack Condon. It highlighted various tools Unreal Engine 5 provides for handling data and impressed me so much that I decided to refactor the existing item implementation.
The motivation behind the refactoring was to proactively facilitate working with items for the future stages of development, where having a simple interface for adjusting item stats (and tracking their changes) would be a great time saver.
Overviewing changes
What the designs were:
- Item is a self-contained UObject.
- The catalog of items the trader may offer is defined in a custom GameInstance (which lives "above" the in-game level and persists from application start to application end).
- TraderActor has a list of offered items generated based on the catalog specified in the abovementioned game instance.
What the designs have become:
- Item data is contained in a special structure; the item asset is now an item data wrapper and a Data Asset subclass.
- TraderActor's catalog of items is now specified in TraderActor. No dependency on GameInstance.
Reasons and Benefits
Separating Item Data from Item Asset, and the upgrade from UObject into Data Asset
First, having item data separate from item assets allows the developers to change how the item data is represented without changing what an item actually is. Simply put, I can change the facade however I want without affecting the core. It is like you dressing differently for different occasions but remaining essentially the same human being.
Second, even though presenting items as UObject assets is a valid way, it is logistically inconvenient: every item is essentially a sub-archetype of items, and to get the item data, you would need to create an instance of that archetype with its default data. Even though Unreal Engine has a convenient function UClass::GetDefaultObject() for this exact purpose, I would much prefer to have direct and easy access to item data - because those item assets are meant to be concrete instances in the first place, not archetypes.
Data Assets act as concrete instances rather than archetypes when you work with them, which allows me as a developer to reference the data I need directly.
Furthermore, Unreal Engine has a built-in feature for tracking changes to Data Assets (which allegedly also works with UObjects, too, but it did not support our kind of items).
TraderActor
- The ability to specify the catalog of offered items in the trader actor itself allows the customization of that catalog for every trader in the game. Keeping that catalog in the GameInstance object, which would persist through the entire game, would not allow for that customization.
- There are no reasons for the trader item catalog to be stored in GameInstance. The dependency is unfounded.
Conclusion
Have we added new features to the game? Not necessarily, but refactoring is not about adding features: it is about making their implementation more stable and easier to work with. These changes will save designers time when they are creating and tweaking items later in Alpha and Beta.
Best,
Ivan Shyika
Team Leader, Project Manager, and Senior Developer of Good Faith Team
Get Return to Divinity
Return to Divinity
Strategic combat, tactical formations, and perilous dungeon runs—can you survive the depths?
Status | Released |
Authors | Good Faith Company, VioletJoy, UnmakerOfThoughts, John Ivess, Senia Icethief |
Genre | Adventure, Action, Role Playing |
Tags | Dungeon Crawler, Fantasy, Isometric, Medieval, Perma Death, Real time strategy, Roguelike, Singleplayer |
More posts
- Devlog: Implementing a Status Effects system - Ivan Shyika45 days ago
- Devlog: Technical design of the Inventory System - Ivan Shyika60 days ago
- Devlog: Overhauling Squad Movement and Formations - Keegen Love67 days ago
- Devlog: Hero Classes and Special Abilities - Ivan Shyika68 days ago
- DevLog: Implementing Death (Animations) - Violet Weathersby68 days ago
- Devlog: Preserving squad data across levels - Ivan Shyika73 days ago
- DevLog: Squad Selection Crashes - Violet Weathersby73 days ago
- Devlog: Fixing Squad AI Freezing in Combat: A Deep Dive into Task Instancing and...74 days ago
- DevLog: Camera Issues - Adam Denomme74 days ago
Leave a comment
Log in with itch.io to leave a comment.