コード例 #1
0
        public void Save()
        {
            LastSaved = DateTime.Now.Ticks;
            var bootSerialized = Util.SerializeObject(Boot);

            SlotData.m_Dict["boot"] = EncryptString.CompressStringToBytes(bootSerialized);

            // If position is changed, set z coordinate to float.infinity to avoid going under terrain
            var pos = Global.PlayerManager.m_SaveGamePosition;

            if (OriginalRegion != Boot.m_SceneName || pos[0] != originalPosition[0] || pos[1] != originalPosition[1] || pos[2] != originalPosition[2])
            {
                pos[1] = 9999999;
            }
            Global.SceneTransistion.m_SceneSaveFilenameCurrent  = Boot.m_SceneName;
            Global.SceneTransistion.m_SceneSaveFilenameNextLoad = Boot.m_SceneName;
            Global.PlayerManager.m_CheatsUsed = true;

            var globalSerialized = Global.Serialize();

            SlotData.m_Dict["global"] = EncryptString.CompressStringToBytes(globalSerialized);

            var slotDataSerialized = Util.SerializeObject(SlotData);

            File.WriteAllBytes(path, EncryptString.CompressStringToBytes(slotDataSerialized));
        }
コード例 #2
0
        public void Save()
        {
            Proxy.m_FeatsSerialized = Feats.Serialize();

            string json = Util.SerializeObject(Proxy);

            #region Break m_StatsDictionary

            // And of course the game can't read that valid json so we have to f**k it up again

            int currentIndex = 0;
            while (true)
            {
                int statsDictStartIndex = json.IndexOf("m_StatsDictionary", currentIndex);
                if (statsDictStartIndex == -1)
                {
                    break;
                }
                statsDictStartIndex = json.IndexOf('{', statsDictStartIndex);
                currentIndex        = statsDictStartIndex;

                int statsDictEndIndex = json.IndexOf('}', statsDictStartIndex);

                var newStats = json.Substring(statsDictStartIndex, statsDictEndIndex - statsDictStartIndex);
                if (newStats.Length <= 2)
                {
                    continue;
                }

                int currentIndex2 = 0;
                while (true)
                {
                    int colonIndex = newStats.IndexOf(':', currentIndex2);
                    if (colonIndex == -1)
                    {
                        break;
                    }
                    currentIndex2 = colonIndex + 1;

                    int i = colonIndex;
                    while (newStats[i] != '{' && newStats[i] != ',')
                    {
                        if (newStats[i] == '\\' || newStats[i] == '\"')
                        {
                            newStats = newStats.Remove(i, 1);
                        }
                        i--;
                    }
                }

                json = json.Substring(0, statsDictStartIndex) + newStats + json.Substring(statsDictEndIndex);
            }

            #endregion

            File.WriteAllBytes(path, EncryptString.CompressStringToBytes(json));
        }