// Saving
        private bool LoadSettings()
        {
            if (deconstructor.Storage == null)
            {
                return(false);
            }

            string rawData;

            if (!deconstructor.Storage.TryGetValue(SETTINGS_GUID, out rawData))
            {
                return(false);
            }

            try
            {
                var loadedSettings = MyAPIGateway.Utilities.SerializeFromBinary <DeconstructorBlockSettings>(Convert.FromBase64String(rawData));

                if (loadedSettings != null)
                {
                    Settings.Efficiency = loadedSettings.Efficiency;
                    Settings.IsGrinding = loadedSettings.IsGrinding;
                    Settings.Time       = loadedSettings.Time;
                    Settings.Items      = loadedSettings.Items;
                    return(true);
                }
            }
            catch (Exception e)
            {
                DeconstructorLog.Error($"Error loading settings!\n{e}");
            }

            return(false);
        }
        protected override void UnloadData()
        {
            instance = null;

            if (handler != null && handler.AutoClose)
            {
                Unload();
            }
        }
        public override bool IsSerialized()
        {
            try
            {
                SaveSettings();
            }
            catch (Exception e)
            {
                DeconstructorLog.Error(e);
            }

            return(base.IsSerialized());
        }
 public override void LoadData()
 {
     instance = this;
     EnsureHandlerCreated();
     handler.Init(this);
 }
            public void Init(DeconstructorLog sessionComp)
            {
                if (writer != null)
                {
                    return;                     // already initialized
                }
                if (MyAPIGateway.Utilities == null)
                {
                    Error("MyAPIGateway.Utilities is NULL !");
                    return;
                }

                this.sessionComp = sessionComp;

                if (string.IsNullOrWhiteSpace(ModName))
                {
                    ModName = sessionComp.ModContext.ModName;
                }

                WorkshopId = GetWorkshopID(sessionComp.ModContext.ModId);

                writer = MyAPIGateway.Utilities.WriteFileInLocalStorage(FILE, typeof(DeconstructorLog));

                #region Pre-init messages

                if (preInitMessages != null)
                {
                    string warning = $"{modName} WARNING: there are log messages before the mod initialized!";

                    Info($"--- pre-init messages ---");

                    foreach (var msg in preInitMessages)
                    {
                        Info(msg, warning);
                    }

                    Info("--- end pre-init messages ---");

                    preInitMessages = null;
                }

                #endregion Pre-init messages

                #region Init message

                sb.Clear();
                sb.Append("Initialized");
                sb.Append("\nGameMode=").Append(MyAPIGateway.Session.SessionSettings.GameMode);
                sb.Append("\nOnlineMode=").Append(MyAPIGateway.Session.SessionSettings.OnlineMode);
                sb.Append("\nServer=").Append(MyAPIGateway.Session.IsServer);
                sb.Append("\nDS=").Append(MyAPIGateway.Utilities.IsDedicated);
                sb.Append("\nDefined=");

#if STABLE
                sb.Append("STABLE, ");
#endif

#if UNOFFICIAL
                sb.Append("UNOFFICIAL, ");
#endif

#if DEBUG
                sb.Append("DEBUG, ");
#endif

#if BRANCH_STABLE
                sb.Append("BRANCH_STABLE, ");
#endif

#if BRANCH_DEVELOP
                sb.Append("BRANCH_DEVELOP, ");
#endif

#if BRANCH_UNKNOWN
                sb.Append("BRANCH_UNKNOWN, ");
#endif

                Info(sb.ToString());
                sb.Clear();

                #endregion Init message
            }