示例#1
0
 internal void SaveToFile()
 {
     if (this.Data != null)
     {
         ModCustomDataFileHelpers.SaveAsJson <InboxMessageData>(ModHelpersMod.Instance, "Inbox", true, this.Data);
     }
 }
        ////////////////

        public void Load()
        {
            var mymod = ResetModeMod.Instance;

            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Clients cannot load config from file");
                return;
            }

            var data = ModCustomDataFileHelpers.LoadJson <ResetModeSessionData>(mymod, SessionLogic.DataFileNameOnly);

            if (data != null)
            {
                // Very specific failsafe:
                if (data.IsRunning && !data.AwaitingNextWorld && data.CurrentSessionedWorldId == "" && data.AllPlayedWorlds.Count == 0)
                {
                    data.IsRunning = false;
                }

                this.DataOnLoad = data.Clone();
                this.Data       = data;
            }

            if (mymod.Config.DebugModeInfo)
            {
                LogHelpers.Alert("Success? " + (data != null) + ": " + this.Data.ToString());
            }
        }
示例#3
0
        private void UnloadModData()
        {
            if (this.Data != null)
            {
                ModCustomDataFileHelpers.SaveAsJson <ModHelpersData>(this, "data", true, this.Data);
            }

            this.Data = new ModHelpersData();
        }
        public void Save()
        {
            var mymod = ResetModeMod.Instance;

            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Clients cannot save config to file");
                return;
            }
            ModCustomDataFileHelpers.SaveAsJson(mymod, SessionLogic.DataFileNameOnly, true, this.Data);
        }
示例#5
0
        ////////////////

        private bool LoadModData()
        {
            var data = ModCustomDataFileHelpers.LoadJson <ModHelpersData>(this, "data");

            if (data != null)
            {
                this.Data = data;
                return(true);
            }

            return(false);
        }
示例#6
0
        public void Save(string baseFileName)
        {
            var mymod = RewardsMod.Instance;

            try {
                if (mymod.SettingsConfig.DebugModeSaveKillsAsJson)
                {
                    ModCustomDataFileHelpers.SaveAsJson(mymod, baseFileName, true, this);                       // false?
                }
                else
                {
                    ModCustomDataFileHelpers.SaveAsBinaryJson(mymod, baseFileName, true, this);                         // false?
                }
            } catch (IOException e) {
                throw new ModHelpersException("Failed to save file: " + baseFileName, e);
            }
        }
示例#7
0
        ////////////////

        internal bool LoadFromFile()
        {
            var data = ModCustomDataFileHelpers.LoadJson <InboxMessageData>(ModHelpersMod.Instance, "Inbox");

            if (data == null)
            {
                return(false);
            }

            this.Data = data;

            foreach (string msgName in this.Data.Messages.Keys)
            {
                this.Data.MessageActions[msgName] = null;
            }

            return(true);
        }
示例#8
0
        ////////////////

        public bool Load(string baseFileName, Player forPlayer = null)
        {
            var      mymod = RewardsMod.Instance;
            KillData data;
            bool     success = false;

            try {
                if (mymod.SettingsConfig.DebugModeSaveKillsAsJson)
                {
                    data = ModCustomDataFileHelpers.LoadJson <KillData>(mymod, baseFileName);
                }
                else
                {
                    data    = ModCustomDataFileHelpers.LoadBinaryJson <KillData>(mymod, baseFileName);
                    success = data != null;
                }
            } catch (IOException e) {
                throw new ModHelpersException("Failed to load file: " + baseFileName, e);
            }

            if (success)
            {
                this.KilledNpcs                = data.KilledNpcs;
                this.GoblinsConquered          = data.GoblinsConquered;
                this.FrostLegionConquered      = data.FrostLegionConquered;
                this.PiratesConquered          = data.PiratesConquered;
                this.MartiansConquered         = data.MartiansConquered;
                this.PumpkinMoonWavesConquered = data.PumpkinMoonWavesConquered;
                this.FrostMoonWavesConquered   = data.FrostMoonWavesConquered;
                this.ProgressPoints            = data.ProgressPoints;

                if (mymod.SettingsConfig.DebugModePPInfo)
                {
                    LogHelpers.Alert("PP set: " + this.ProgressPoints + " (for " + (forPlayer?.name ?? "world") + ")");
                }
            }
            else
            {
                LogHelpers.Alert("Could not load player's NPC kill (and PP) data. New player?");
            }

            return(success);
        }