Utility that attempts to persist player progress/settings. It wraps a save Action in a try/catch, marks Settings.Current.ProgressSavePending when SaveSettings is called, and logs a warning on exceptions while returning success/failure.
using System;
namespace BlockParty;
/// <summary>Best-effort writes after earning progress. Callers retain their in-memory changes.</summary>
internal static class ProgressPersistence
{
public static bool SaveSettings( string context )
{
Settings.Current.ProgressSavePending = true;
return TrySave( Settings.Save, context );
}
public static bool TrySave( Action save, string context )
{
try
{
save();
return true;
}
catch ( Exception e )
{
Log.Warning( $"BlockParty: couldn't save {context}; retained in memory for a later save: {e.Message}" );
return false;
}
}
}