public void OnLoad()
        {
            Logger.Log("Deserialize Called for FiltrationMachine");
            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "FiltrationMachines");
            var saveFile    = Path.Combine(savePathDir, id + ".json");

            if (File.Exists(saveFile))
            {
                var rawJson = File.ReadAllText(saveFile);
                isOn = JsonConvert.DeserializeObject <FiltrationMachineSaveData>(rawJson).Working;
            }
            else
            {
                isOn = true;
            }
        }
Exemplo n.º 2
0
        public void OnProtoDeserialize(ProtobufSerializer serializer)
        {
            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "Spotlights");
            var saveFile    = Path.Combine(savePathDir, id + ".json");

            if (File.Exists(saveFile))
            {
                var json     = File.ReadAllText(saveFile);
                var saveData = JsonConvert.DeserializeObject <LightSaveData>(json);

                IsOn = saveData.IsOn;
            }
            else
            {
                IsOn = true;
            }
        }
Exemplo n.º 3
0
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "Spotlights");
            var saveFile    = Path.Combine(savePathDir, id + ".json");

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

            var saveData = new LightSaveData()
            {
                IsOn = IsOn
            };

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

            File.WriteAllText(saveFile, json);
        }
        public void OnProtoDeserialize(ProtobufSerializer serializer)
        {
            Logger.Log("Deserialize Called for FloodlightToggle");

            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "Floodlights");
            var savePath    = Path.Combine(savePathDir, id + ".json");

            if (File.Exists(savePath))
            {
                var rawJson  = File.ReadAllText(savePath);
                var saveData = JsonConvert.DeserializeObject <LightSaveData>(rawJson);

                isOn = saveData.IsOn;
            }
            else
            {
                isOn = true;
            }
        }
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            Logger.Log("Serialize Called for FloodlightToggle");

            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "Floodlights");
            var savePath    = Path.Combine(savePathDir, id + ".json");

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

            var saveData = new LightSaveData()
            {
                IsOn = isOn
            };

            var json = JsonConvert.SerializeObject(saveData);

            File.WriteAllText(savePath, json);
        }
        public void OnSave()
        {
            Logger.Log("Serialize Called for FiltrationMachine");
            var currentState = (bool)WorkingField.GetValue(filtrationMachine);

            var savePathDir = Path.Combine(Qpatch.GetSavePathDir(), "FiltrationMachines");
            var saveFile    = Path.Combine(savePathDir, id + ".json");

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

            var localSaveData = new FiltrationMachineSaveData()
            {
                Working = currentState
            };

            string json = JsonConvert.SerializeObject(localSaveData, Formatting.Indented);

            File.WriteAllText(saveFile, json);
        }