You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
8 years ago
|
using UnityEngine;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
8 years ago
|
/// <summary>
|
||
|
/// Contains a list of game objects whose state will be saved for each Save Point.
|
||
|
/// </summary>
|
||
8 years ago
|
public class SaveData : MonoBehaviour
|
||
8 years ago
|
{
|
||
8 years ago
|
[Tooltip("A list of Flowchart objects whose variables will be encoded in the save data. Boolean, Integer, Float and String variables are supported.")]
|
||
8 years ago
|
[SerializeField] protected List<Flowchart> flowcharts = new List<Flowchart>();
|
||
|
|
||
|
#region Public methods
|
||
|
|
||
8 years ago
|
/// <summary>
|
||
8 years ago
|
/// Encodes the list of Flowcharts and adds it to a Save Point Data object.
|
||
8 years ago
|
/// </summary>
|
||
8 years ago
|
public void Encode(SavePointData savePointData)
|
||
|
{
|
||
|
for (int i = 0; i < flowcharts.Count; i++)
|
||
|
{
|
||
|
var flowchart = flowcharts[i];
|
||
|
var flowchartData = FlowchartData.Encode(flowchart);
|
||
|
savePointData.FlowchartDatas.Add(flowchartData);
|
||
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
/// <summary>
|
||
|
/// Decodes the Flowchart data from the save point data.
|
||
|
/// </summary>
|
||
|
public void Decode(SavePointData savePointData)
|
||
|
{
|
||
|
for (int i = 0; i < savePointData.FlowchartDatas.Count; i++)
|
||
|
{
|
||
|
var flowchartData = savePointData.FlowchartDatas[i];
|
||
|
FlowchartData.Decode(flowchartData);
|
||
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
#endregion
|
||
|
}
|
||
|
}
|