Esempio n. 1
0
        ////////////////

        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());
            }
        }
Esempio n. 2
0
        ////////////////

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

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

            return(false);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }