# Save/Load Manager

<div align="left"><figure><img src="/files/Pxb9F1D6r6SRb7Q5t5rd" alt=""><figcaption></figcaption></figure></div>

The **Save/Load Manager(AC\_SaveLoadManager)** is a highly versatile component designed to manage all saving and loading operations. It tracks saved data, interacts with the selected save slot stored in the **Game Instance**, and uses **FInstancedStructs** to handle diverse data types. This ensures modularity and flexibility, allowing any type of game data to be saved or loaded seamlessly.

It is added to the **PlayerController** class by default **(PC\_SoulslikeFramework).**

### Functionality

* Works with the **Game Instance** to determine which save slot to handle.
* Utilizes **FInstancedStruct** to save and load any type of data (e.g., stats, inventory, equipment, world state).
  * Converts data into serialized structures for storage and retrieval.
* **Dynamic Save/Load Functionality**:
  * Saves game data dynamically based on the active save slot.
* **Event-Driven Updates**:
  * Dispatches events to notify other components or systems when data is loaded.

### **How It Works**

Main method - **Event UpdateSaveData:** Utilized to add/update our save data. Any type of data can be stored/retrieved in the save file thanks to **Instanced Structures:**

<figure><img src="/files/ZST9zzR3DE1oxSXLZ5hY" alt=""><figcaption></figcaption></figure>

Additionally, helper method - **Event AddToSaveData:** Used to add new data to an existing data entry:

<figure><img src="/files/pCRK5AQzS8WGBTVmeDIm" alt=""><figcaption></figcaption></figure>

These events are triggered from various blueprints. If you'd like to see where, see our page related to [Finding References](/getting-started/finding-references.md).

### Saving Components

Each component has a method of "serializing" their data into a savable structure format:

<figure><img src="/files/o4cYWcOE09DIhujRAwb9" alt=""><figcaption><p>Example from AC_EquipmentManager</p></figcaption></figure>

This method adds the related save data to the main data we have in our save/load component. Each component that has data that needs to be saved implements a similar method.&#x20;

Additionally, **AC\_SaveLoadManager** has methods for serializing all of the components.

When the save data inside **AC\_SaveLoadManager** is updated, data will be saved into file.

### Loading Components

The save/load manager sends a message which **each component that requires loading** listens to:

<figure><img src="/files/kkJXerwIFMhpKdW3ANfY" alt=""><figcaption></figcaption></figure>

When this dispatcher is called, each component that is listening to it will execute a relevant method:

<figure><img src="/files/Uu4huey1u2Zwofcdfdip" alt=""><figcaption><p>Example from AC_InventoryManager</p></figcaption></figure>

### Saving World Actors (Interactables & NPC's)

Actors that need to be saved require a unique identifier. For this, we utilize **GUID's** in Soulslike Framework. Actors without a valid GUID won't be considered for saving:

<figure><img src="/files/i97smrWWjn1Tk3C101yN" alt=""><figcaption></figcaption></figure>

For example, when this container actor (B\_Container) is interacted with, it calls a method to update our save data:

<figure><img src="/files/cjgYZOgLnk4peXlUuPhV" alt=""><figcaption><p>Method screenshot from B_Interactable</p></figcaption></figure>

After our save data has changed/updated, it gets serialized and saved automatically into a file.

### Loading World Actors (Pickup Items, Interactables, NPC's)

Similarly, actors that require loading bind to AC\_SaveLoadManager's **OnDataLoaded()** delegate. This way, when data is loaded, we can execute any desired logic.

<figure><img src="/files/UQ4dDCrXrmBrWTfUcuK1" alt=""><figcaption><p>Load event from B_Interactable</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/components-managers/player-specific-components/save-load-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
