FactionsSave and Load
Last modified: 15 September 2024If you are using Reputations in your project, then you probably need to save and load the player's memberships.
This mechanism was designed using multiple layers, so you can perform the entire save and load operations with the Faction Manager, or use parts of it with your own save system.
Faction Save Game
The Faction System provides the NinjaFactionSaveGame
class, which can be used to serialize and deserialize membership information from a Faction Manager component.
This means you can create a dedicated Faction Save File using Unreal Engine's default save game mechanism.
Saving Memberships
You can save all Memberships into a save file by calling the Save Factions function in the Save Game object, passing the Faction Component that should be saved.
Loading Memberships
You can load all Memberships from a save file by calling the Load Factions function in the Save Game Object, passing the Faction Component that should receive them.
tip
Loading Factions overrides current entries
The load operation will always reset all current memberships and load the ones from file. If you need to handle that scenario, listen to the Faction Removed delegate and perform any necessary clean up.
note
Loading Factions is also asynchronous
You might not get data right after calling
LoadFactions
, since this function must run asynchronous code, to load Data Assets for incoming Factions. If you need to react right away, the use the * Faction Added delegate.
Other Save Systems
You can also integrate the save mechanism with other save systems. In that case you need to look into the following functions provided by the Faction Manager:
Function | Description |
---|---|
| Provides a consolidated Record of the Faction component. |
| Provides a list of Membership Records from the component. |
| Adds a Faction/Reputation from a Membership. |