Save & Restore
CrimsonEquipment provides a save-friendly struct and two component methods. The plugin does not depend on CrimsonSaveSystem - wire these however your project persists data.
FCrimsonEquipmentSaveData
A plain struct containing one FCrimsonEquipmentSaveEntry per equipped item. Both structs are BlueprintType with all fields marked UPROPERTY(SaveGame) so they serialize cleanly via any archive.
| Field (FCrimsonEquipmentSaveEntry) | Type | Description |
|---|---|---|
| EquipmentDefinition | TSubclassOf<UCrimsonEquipmentDefinition> | The definition class that was equipped. |
| SlotTag | FGameplayTag | The slot type it occupied. |
| AssignedSlotIndex | int32 | The slot index within that type. |
| SourceObjectPath | FSoftObjectPath | Optional soft path to the source UObject. Only meaningful for loadable data assets. Leave empty for transient inventory items and handle restoration in a subclass. |
Gathering Save Data
// In your ICrimsonSaveableSystem::GatherSaveData_ImplementationUCrimsonEquipmentManagerComponent* EqMgr =Pawn->FindComponentByClass<UCrimsonEquipmentManagerComponent>();UMyEquipmentFragment* Frag = NewObject<UMyEquipmentFragment>(this);Frag->EquipmentSaveData = EqMgr->GatherSaveData(); // FCrimsonEquipmentSaveDatareturn Frag;
Restoring Equipment
// In ICrimsonSaveableSystem::RestoreFromSaveData_Implementationconst UMyEquipmentFragment* Frag = Cast<UMyEquipmentFragment>(Fragment);if (!Frag) return;UCrimsonEquipmentManagerComponent* EqMgr =Pawn->FindComponentByClass<UCrimsonEquipmentManagerComponent>();EqMgr->RestoreFromSaveData(Frag->EquipmentSaveData);// If the ASC is not ready yet, data is cached automatically.// Call TryFlushPendingRestore() once the ASC is initialized:// EqMgr->TryFlushPendingRestore();
Deferred Restore
In PS-owns-ASC setups, the pawn may be initialized before the PlayerState (and thus the ASC) is available. If RestoreFromSaveData is called before the ASC is ready, the data is cached inside the component. Nothing breaks - call TryFlushPendingRestore() once you know the ASC is initialized.
// Example: called from your HeroComponent's InitializeAbilitySystemvoid UMyHeroComponent::InitializeAbilitySystem(UAbilitySystemComponent* ASC){// ... initialize GAS ...// Flush any equipment that was waiting for the ASCif (UCrimsonEquipmentManagerComponent* EqMgr =GetPawn<APawn>()->FindComponentByClass<UCrimsonEquipmentManagerComponent>())EqMgr->TryFlushPendingRestore();}
Runtime Source Objects
SourceObjectPath Only Works for Loadable Assets
FCrimsonEquipmentSaveEntry::SourceObjectPath only survives save/load if the source is a loadable UObject (e.g. a Data Asset). For runtime-created inventory item instances, the path will be empty on restore. Override GatherSaveData and RestoreFromSaveData in your UCrimsonEquipmentManagerComponent subclass to handle the mapping between your inventory system's item IDs and the equipment entries.