public virtual void Load(string filename, WorldSaveData saveData) { _context.SetStore(nameof(World), this); _context.SetStore(nameof(Player), Player.Instance); if (AudioManager.Instance && World.BackgroundMusic) { AudioManager.Instance.Push(World.BackgroundMusic, 0.0f, 1.0f, 0.0f); } _variables.LoadFrom(saveData.PersistentVariables, VariableDefinition.Saved); foreach (var zoneData in saveData.Zones) { var zone = World.GetZoneByName(zoneData.Name); var data = zone != null?GetZone(zone) : null; if (data != null) { data.Load(zoneData); } } SaveFilename = filename; }
public virtual string Save(WorldSaveData saveData) { _variables.SaveTo(saveData.PersistentVariables, VariableDefinition.Saved); foreach (var zone in Zones) { if (zone != null) { var zoneSaveData = new ZoneSaveData(); zone.Save(zoneSaveData); zoneSaveData.Name = zone.Zone.name; saveData.Zones.Add(zoneSaveData); } } return(SaveFilename); }