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)TypeDescription
EquipmentDefinitionTSubclassOf<UCrimsonEquipmentDefinition>The definition class that was equipped.
SlotTagFGameplayTagThe slot type it occupied.
AssignedSlotIndexint32The slot index within that type.
SourceObjectPathFSoftObjectPathOptional 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

cpp
// In your ICrimsonSaveableSystem::GatherSaveData_Implementation
UCrimsonEquipmentManagerComponent* EqMgr =
Pawn->FindComponentByClass<UCrimsonEquipmentManagerComponent>();
UMyEquipmentFragment* Frag = NewObject<UMyEquipmentFragment>(this);
Frag->EquipmentSaveData = EqMgr->GatherSaveData(); // FCrimsonEquipmentSaveData
return Frag;

Restoring Equipment

cpp
// In ICrimsonSaveableSystem::RestoreFromSaveData_Implementation
const 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.

cpp
// Example: called from your HeroComponent's InitializeAbilitySystem
void UMyHeroComponent::InitializeAbilitySystem(UAbilitySystemComponent* ASC)
{
// ... initialize GAS ...
// Flush any equipment that was waiting for the ASC
if (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.