Ejemplo n.º 1
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // submit command
            decimal zoomLevel;

            if (!args.Any())
            {
                zoomLevel = 1.0m;
            }
            else if (!args.TryGetDecimal(0, "zoomLevel", out zoomLevel, min: 0.1m, max: 10m))
            {
                return;
            }
            object       viewport            = typeof(Game1).GetField("viewport", BindingFlags.Static | BindingFlags.Public).GetValue(null);
            PropertyInfo x                   = viewport.GetType().GetProperty("X");
            PropertyInfo y                   = viewport.GetType().GetProperty("Y");
            int          oldX                = (int)x.GetValue(viewport);
            int          oldY                = (int)y.GetValue(viewport);
            FieldInfo    _lastPinchZoomLevel = typeof(PinchZoom).GetField("_lastPinchZoomLevel", BindingFlags.Instance | BindingFlags.NonPublic);
            FieldInfo    _pinchZoomLevel     = typeof(PinchZoom).GetField("_pinchZoomLevel", BindingFlags.Instance | BindingFlags.NonPublic);

            Game1.options.zoomLevel = Game1.NativeZoomLevel * (float)zoomLevel;
            float oldZoom = (float)_lastPinchZoomLevel.GetValue(PinchZoom.Instance);

            _lastPinchZoomLevel.SetValue(PinchZoom.Instance, _pinchZoomLevel.GetValue(PinchZoom.Instance));
            _pinchZoomLevel.SetValue(PinchZoom.Instance, Game1.options.zoomLevel);
            Game1.game1.refreshWindowSettings();
            PinchZoom.Instance.Center();
            WeatherDebrisManager.Instance.RepositionOnZoomChange(oldX, oldY, (int)x.GetValue(viewport), (int)y.GetValue(viewport), oldZoom, Game1.options.zoomLevel);
            RainManager.Instance.UpdateRainPositionForPinchZoom((float)(oldX - (int)x.GetValue(viewport)), (float)(oldY - (int)y.GetValue(viewport)));
            // show result
            monitor.Log("Zoom level changed.", LogLevel.Info);
        }
Ejemplo n.º 2
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // validate
            if (!args.Any())
            {
                monitor.Log($"You currently have {(this.InfiniteMoney ? "infinite" : Game1.player.Money.ToString())} gold. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            string amountStr = args[0];

            if (amountStr == "inf")
            {
                this.InfiniteMoney = true;
                monitor.Log("OK, you now have infinite money.", LogLevel.Info);
            }
            else
            {
                this.InfiniteMoney = false;
                if (int.TryParse(amountStr, out int amount))
                {
                    Game1.player.Money = amount;
                    monitor.Log($"OK, you now have {Game1.player.Money} gold.", LogLevel.Info);
                }
                else
                {
                    this.LogArgumentNotInt(monitor);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // validate
            if (!args.Any())
            {
                monitor.Log($"You currently have {Game1.player.immunity} immunity. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            if (args.TryGetInt(0, "amount", out int amount, min: 0))
            {
                Game1.player.immunity = amount;
                monitor.Log($"OK, you now have {Game1.player.immunity} immunity.", LogLevel.Info);
            }
        }
Ejemplo n.º 4
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            BaseStats stats = SGame.Instance.xLocalPlayer.xEntity.xBaseStats;

            // validate
            if (!args.Any())
            {
                monitor.Log($"You currently have {stats.iMaxEP} max energy. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            if (args.TryGetInt(0, "amount", out int amount, min: 1))
            {
                stats.iMaxEP = amount;
                monitor.Log($"OK, you now have {stats.iMaxEP} max energy.", LogLevel.Info);
            }
        }
Ejemplo n.º 5
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"The current date is {Game1.currentSeason} {Game1.dayOfMonth}. Specify a value to change the day.", LogLevel.Info);
                return;
            }

            // parse arguments
            if (!args.TryGetInt(0, "day", out int day, min: 1, max: 28))
            {
                return;
            }

            // handle
            Game1.dayOfMonth = day;
            monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info);
        }
Ejemplo n.º 6
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"The current season is {Game1.currentSeason}. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // parse arguments
            if (!args.TryGet(0, "season", out string season, oneOf: this.ValidSeasons))
            {
                return;
            }

            // handle
            Game1.currentSeason = season;
            monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info);
        }
Ejemplo n.º 7
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"The current year is {Game1.year}. Specify a value to change the year.", LogLevel.Info);
                return;
            }

            // parse arguments
            if (!args.TryGetInt(0, "year", out int year, min: 1))
            {
                return;
            }

            // handle
            Game1.year = year;
            monitor.Log($"OK, the year is now {Game1.year}.", LogLevel.Info);
        }
Ejemplo n.º 8
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"The current time is {Game1.timeOfDay}. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // parse arguments
            if (!args.TryGetInt(0, "time", out int time, min: 600, max: 2600))
            {
                return;
            }

            // handle
            this.SafelySetTime(time);
            FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
            monitor.Log($"OK, the time is now {Game1.timeOfDay.ToString().PadLeft(4, '0')}.", LogLevel.Info);
        }
Ejemplo n.º 9
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"The current season is {Game1.currentSeason}. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // parse arguments
            if (!args.TryGet(0, "season", out string season, oneOf: this.ValidSeasons))
            {
                return;
            }

            // handle
            Game1.currentSeason = season.ToLower();
            Game1.setGraphicsForSeason();
            Game1.stats.DaysPlayed = (uint)SDate.Now().DaysSinceStart;
            monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info);
        }
Ejemplo n.º 10
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            if (args.Any())
            {
                // parse arguments
                if (!args.TryGetInt(0, "value", out int value, min: 0, max: 1))
                {
                    return;
                }

                // handle
                this.FreezeTime = value == 1;
                FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
                monitor.Log($"OK, time is now {(this.FreezeTime ? "frozen" : "resumed")}.", LogLevel.Info);
            }
            else
            {
                this.FreezeTime = !this.FreezeTime;
                FreezeTimeCommand.FrozenTime = Game1.timeOfDay;
                monitor.Log($"OK, time is now {(this.FreezeTime ? "frozen" : "resumed")}.", LogLevel.Info);
            }
        }
Ejemplo n.º 11
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            // no-argument mode
            if (!args.Any())
            {
                monitor.Log($"You currently have {Game1.player.health} health. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            string amountStr = args[0];

            if (int.TryParse(amountStr, out int amount))
            {
                Game1.player.health = amount;
                monitor.Log($"OK, you now have {Game1.player.health} health.", LogLevel.Info);
            }
            else
            {
                this.LogArgumentNotInt(monitor);
            }
        }
Ejemplo n.º 12
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            BaseStats stats = SGame.Instance.xLocalPlayer.xEntity.xBaseStats;

            // validate
            if (!args.Any())
            {
                monitor.Log($"You currently have {stats.iEP} energy. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            string amountStr = args[0];

            if (int.TryParse(amountStr, out int amount))
            {
                stats.iEP = amount;
                monitor.Log($"OK, you now have {stats.iEP} energy.", LogLevel.Info);
            }
            else
            {
                this.LogArgumentNotInt(monitor);
            }
        }
Ejemplo n.º 13
0
        /// <summary>Handle the command.</summary>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        /// <param name="command">The command name.</param>
        /// <param name="args">The command arguments.</param>
        public override void Handle(IMonitor monitor, string command, ArgumentParser args)
        {
            Inventory inventory = SGame.Instance.xLocalPlayer.xInventory;

            // validate
            if (!args.Any())
            {
                monitor.Log($"You currently have {inventory.GetMoney()} gold. Specify a value to change it.", LogLevel.Info);
                return;
            }

            // handle
            string amountStr = args[0];

            if (int.TryParse(amountStr, out int amount))
            {
                inventory.SetMoney(amount);
                monitor.Log($"OK, you now have {inventory.GetMoney()} gold.", LogLevel.Info);
            }
            else
            {
                this.LogArgumentNotInt(monitor);
            }
        }