Exemplo n.º 1
0
        private void OnSaveGameLoaded()
        {
            try
            {
                byte[] data = sapi.WorldManager.SaveGame.GetData("journalItemsByPlayerUid");

                if (GameVersion.IsLowerVersionThan(sapi.WorldManager.SaveGame.LastSavedGameVersion, "1.14-pre.1"))
                {
                    if (data != null)
                    {
                        journalsByPlayerUid = upgrade(SerializerUtil.Deserialize <Dictionary <string, JournalOld> >(data));
                    }
                    sapi.World.Logger.Notification("Upgraded journalItemsByPlayerUid from v1.13 format to v1.14 format");
                }
                else
                {
                    if (data != null)
                    {
                        journalsByPlayerUid = SerializerUtil.Deserialize <Dictionary <string, Journal> >(data);
                    }
                }
            } catch (Exception e)
            {
                sapi.World.Logger.Error("Failed loading journalItemsByPlayerUid. Resetting. Exception: {0}", e);
            }
            if (journalsByPlayerUid == null)
            {
                journalsByPlayerUid = new Dictionary <string, Journal>();
            }

            try
            {
                byte[] data = sapi.WorldManager.SaveGame.GetData("loreDiscoveriesByPlayerUid");
                if (data != null)
                {
                    loreDiscoveryiesByPlayerUid = SerializerUtil.Deserialize <Dictionary <string, Dictionary <string, LoreDiscovery> > >(data);
                }
            }
            catch (Exception e)
            {
                sapi.World.Logger.Error("Failed loading loreDiscoveryiesByPlayerUid. Resetting. Exception: {0}", e);
            }

            if (loreDiscoveryiesByPlayerUid == null)
            {
                loreDiscoveryiesByPlayerUid = new Dictionary <string, Dictionary <string, LoreDiscovery> >();
            }
        }