コード例 #1
0
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            QuickLogger.Debug($"Saving {_prefabId.Id} Data");

            if (!Directory.Exists(SaveDirectory))
            {
                Directory.CreateDirectory(SaveDirectory);
            }

            var saveData = new SaveData
            {
                BodyColor               = _currentBodyColor.ColorToVector4(),
                Batteries               = PowerManager.Save(),
                PowerState              = PowerManager.GetPowerState(),
                ChargeMode              = PowerManager.GetChargeMode(),
                ToggleMode              = AnimationManager.GetBoolHash(ToggleHash),
                AutoActivate            = GetAutoActivate(),
                BaseDrainProtection     = GetBaseDrainProtection(),
                BaseDrainProtectionGoal = GetBasePowerProtectionGoal(),
                AutoActivateAt          = GetAutoActivateAt()
            };

            var output = JsonConvert.SerializeObject(saveData, Formatting.Indented);

            File.WriteAllText(SaveFile, output);
            LoadData.CleanOldSaveData();
            BaseManager.SaveBases();
            QuickLogger.Debug($"Saved {_prefabId.Id} Data");
        }
コード例 #2
0
        /// <summary>
        /// Saves all the bases settings
        /// </summary>
        internal static void SaveBases()
        {
            QuickLogger.Debug("Save Bases");
            var saveDirectory = Information.GetSaveFileDirectory();
            var SaveFile      = Path.Combine(saveDirectory, "Bases.json");

            QuickLogger.Debug($"SD {saveDirectory} || SF {SaveFile}");

            if (!Directory.Exists(saveDirectory))
            {
                Directory.CreateDirectory(saveDirectory);
            }


            var output = JsonConvert.SerializeObject(Managers, Formatting.Indented);

            File.WriteAllText(SaveFile, output);
            LoadData.CleanOldSaveData();
        }