Пример #1
0
 private void registerConsoleCommands()
 {
     CcLocations.clearSpace().register();
     CcSaveHandler.cleanup().register();
     CcSaveHandler.savecheck().register();
     CcTime.skip().register();
 }
Пример #2
0
 public void doMagic(bool playedToday)
 {
     Game1.player.forceTimePass = true;
     Game1.playSound("stardrop");
     if (Game1.timeOfDay < 2400)
     {
         Task.Run(() => CcTime.TimeSkip((Game1.timeOfDay).ToString(), false));
     }
 }
Пример #3
0
        public void callTimeSkip()
        {
            Game1.playSound("coin");

            if (Game1.timeOfDay < config.maxskip)
            {
                CcTime.TimeSkip(Game1.timeOfDay < (config.maxskip - config.skiptime) ? (Game1.timeOfDay + config.skiptime).ToString() : config.maxskip.ToString(), false);
            }

            Game1.playSound("coin");
            canSleep = true;
            Game1.currentLocation.lastQuestionKey = "Sleep";
            Game1.currentLocation.answerDialogue(new Response("Yes", "Yes"));
            canSleep = false;
        }
Пример #4
0
        public override void Entry(IModHelper helper)
        {
            config = helper.ReadConfig <Config>();
            if (config.skiptime > 18)
            {
                config.skiptime = 18;
            }

            if (config.skiptime < 1)
            {
                config.skiptime = 1;
            }

            helper.WriteConfig(config);

            PyTK.Events.PyTimeEvents.BeforeSleepEvents += (s, e) =>
            {
                if (!Game1.IsMultiplayer && !canSleep)
                {
                    e.Response.responseKey = "No";
                    Game1.playSound("coin");

                    if (Game1.timeOfDay >= 2400)
                    {
                        return;
                    }

                    Task.Run(() =>
                    {
                        CcTime.TimeSkip(Math.Min((config.skiptime * 100) + Game1.timeOfDay, 2400), () =>
                        {
                            canSleep = true;
                            Game1.playSound("coin");
                            Game1.currentLocation.lastQuestionKey = "Sleep";
                            Game1.currentLocation.answerDialogue(new Response("Yes", "Yes"));
                            canSleep = false;
                            Game1.hudMessages.Clear();
                        });;
                    });
                }
            };

            helper.Events.GameLoop.GameLaunched += (s, e) => SetUpConfigMenu();
        }
Пример #5
0
        public void doMagic(bool playedToday)
        {
            Game1.player.forceTimePass = true;
            Game1.playSound("stardrop");
            STime time    = STime.CURRENT + (STime.HOUR * 3);
            int   timeInt = (time.hour * 100 + time.minute * 10);

            if (timeInt > 2600)
            {
                timeInt = 2600;
            }

            if (Game1.timeOfDay < 2600)
            {
                Task.Run(() => {
                    try
                    {
                        CcTime.TimeSkip(timeInt.ToString(), false);
                    }
                    catch { }
                });
            }
        }
Пример #6
0
        private void registerConsoleCommands()
        {
            CcLocations.clearSpace().register();
            CcSaveHandler.cleanup().register();
            CcSaveHandler.savecheck().register();
            CcTime.skip().register();
            CcLua.runScript().register();

            new ConsoleCommand("adjustWarps", "", (s, p) =>
            {
                PyUtils.adjustWarps(p[0]);
            }).register();

            new ConsoleCommand("rebuild_objects", "", (s, e) =>
            {
                SaveHandler.RebuildAll(Game1.currentLocation.objects, Game1.currentLocation);
                SaveHandler.RebuildAll(Game1.currentLocation.terrainFeatures, Game1.currentLocation);
            }).register();

            new ConsoleCommand("allready", "confirms all players for the current readydialogue", (s, p) =>
            {
                if (!(Game1.activeClickableMenu is ReadyCheckDialog))
                {
                    Monitor.Log("No open ready check.", LogLevel.Alert);
                }
                else
                {
                    OvGame.allready = true;
                }
            }).register();

            new ConsoleCommand("send", "sends a message to all players: send [address] [message]", (s, p) =>
            {
                if (p.Length < 2)
                {
                    Monitor.Log("Missing address or message.", LogLevel.Alert);
                }
                else
                {
                    string address      = p[0];
                    List <string> parts = new List <string>(p);
                    parts.Remove(p[0]);
                    string message = String.Join(" ", p);
                    PyNet.sendMessage(address, message);
                    Monitor.Log("OK", LogLevel.Info);
                }
            }).register();

            new ConsoleCommand("messages", "lists all new messages on a specified address: messages [address]", (s, p) =>
            {
                if (p.Length == 0)
                {
                    Monitor.Log("Missing address", LogLevel.Alert);
                }
                else
                {
                    List <MPMessage> messages = PyNet.getNewMessages(p[0]).ToList();
                    foreach (MPMessage msg in messages)
                    {
                        Monitor.Log($"From {msg.sender.Name} : {msg.message}", LogLevel.Info);
                    }

                    Monitor.Log("OK", LogLevel.Info);
                }
            }).register();

            new ConsoleCommand("getstamina", "lists the current stamina values of all players", (s, p) =>
            {
                Monitor.Log(Game1.player.Name + ": " + Game1.player.Stamina, LogLevel.Info);
                foreach (Farmer farmer in Game1.otherFarmers.Values)
                {
                    PyNet.sendRequestToFarmer <int>("PytK.StaminaRequest", -1, farmer, (getStamina) => Monitor.Log(farmer.Name + ": " + getStamina, LogLevel.Info));
                }
            }).register();

            new ConsoleCommand("setstamina", "changes the stamina of all or a specific player. use: setstamina [playername or all] [stamina]", (s, p) =>
            {
                if (p.Length < 2)
                {
                    Monitor.Log("Missing parameter", LogLevel.Alert);
                }

                Monitor.Log(Game1.player.Name + ": " + Game1.player.Stamina, LogLevel.Info);
                Farmer farmer = null;

                farmer = Game1.otherFarmers.Find(k => k.Value.Name.Equals(p[0])).Value;


                if (farmer == null)
                {
                    Monitor.Log("Couldn't find Farmer", LogLevel.Alert);
                    return;
                }

                int i = -1;
                int.TryParse(p[1], out i);

                PyNet.sendRequestToFarmer <int>("PytK.StaminaRequest", i, farmer, (setStamina) => Monitor.Log(farmer.Name + ": " + setStamina, LogLevel.Info));
            }).register();


            new ConsoleCommand("ping", "pings all other players", (s, p) =>
            {
                foreach (Farmer farmer in Game1.otherFarmers.Values)
                {
                    long t = Game1.currentGameTime.TotalGameTime.Milliseconds;
                    PyNet.sendRequestToFarmer <bool>("PytK.Ping", t, farmer, (ping) =>
                    {
                        long r = Game1.currentGameTime.TotalGameTime.Milliseconds;
                        if (ping)
                        {
                            Monitor.Log(farmer.Name + ": " + (r - t) + "ms", LogLevel.Info);
                        }
                        else
                        {
                            Monitor.Log(farmer.Name + ": No Answer", LogLevel.Error);
                        }
                    });
                }
            }).register();

            new ConsoleCommand("syncmap", "Syncs map of a specified location to all clients. Exp.: syncmap Farm, syncmap BusStop, syncmao Town", (s, p) =>
            {
                if (p.Length < 1)
                {
                    Monitor.Log("No Location specified. ");
                }

                PyNet.syncLocationMapToAll(p[0]);
            }).register();
        }
Пример #7
0
        private void registerConsoleCommands()
        {
            CcLocations.clearSpace().register();
            CcSaveHandler.cleanup().register();
            CcSaveHandler.savecheck().register();
            CcTime.skip().register();
            CcLua.runScript().register();

            new ConsoleCommand("send", "sends a message to all players: send [address] [message]", (s, p) =>
            {
                if (p.Length < 2)
                {
                    Monitor.Log("Missing address or message.", LogLevel.Alert);
                }
                else
                {
                    string address      = p[0];
                    List <string> parts = new List <string>(p);
                    parts.Remove(p[0]);
                    string message = String.Join(" ", p);
                    PyNet.sendMessage(address, message);
                    Monitor.Log("OK", LogLevel.Info);
                }
            }).register();

            new ConsoleCommand("messages", "lists all new messages on a specified address: messages [address]", (s, p) =>
            {
                if (p.Length == 0)
                {
                    Monitor.Log("Missing address", LogLevel.Alert);
                }
                else
                {
                    List <MPMessage> messages = PyNet.getNewMessages(p[0]).ToList();
                    foreach (MPMessage msg in messages)
                    {
                        Monitor.Log($"From {msg.sender.Name} : {msg.message}", LogLevel.Info);
                    }

                    Monitor.Log("OK", LogLevel.Info);
                }
            }).register();

            new ConsoleCommand("getstamina", "lists the current stamina values of all players", (s, p) =>
            {
                Monitor.Log(Game1.player.Name + ": " + Game1.player.Stamina, LogLevel.Info);
                foreach (Farmer farmer in Game1.otherFarmers.Values)
                {
                    var getStamina = PyNet.sendRequestToFarmer <int>("PytK.StaminaRequest", -1, farmer);
                    getStamina.Wait();
                    Monitor.Log(farmer.Name + ": " + getStamina.Result, LogLevel.Info);
                }
            }).register();

            new ConsoleCommand("setstamina", "changes the stamina of all or a specific player. use: setstamina [playername or all] [stamina]", (s, p) =>
            {
                if (p.Length < 2)
                {
                    Monitor.Log("Missing parameter", LogLevel.Alert);
                }

                Monitor.Log(Game1.player.Name + ": " + Game1.player.Stamina, LogLevel.Info);
                Farmer farmer = null;
                try
                {
                    farmer = Game1.otherFarmers.Find(k => k.Value.Name.Equals(p[0])).Value;
                }
                catch
                {
                }

                if (farmer == null)
                {
                    Monitor.Log("Couldn't find Farmer", LogLevel.Alert);
                    return;
                }

                int i = -1;
                int.TryParse(p[1], out i);

                var setStamina = PyNet.sendRequestToFarmer <int>("PytK.StaminaRequest", i, farmer);
                setStamina.Wait();
                Monitor.Log(farmer.Name + ": " + setStamina.Result, LogLevel.Info);
            }).register();


            new ConsoleCommand("ping", "pings all other players", (s, p) =>
            {
                foreach (Farmer farmer in Game1.otherFarmers.Values)
                {
                    long t   = Game1.currentGameTime.TotalGameTime.Milliseconds;
                    var ping = PyNet.sendRequestToFarmer <bool>("PytK.Ping", t, farmer);
                    ping.Wait();

                    long r = Game1.currentGameTime.TotalGameTime.Milliseconds;
                    if (ping.Result)
                    {
                        Monitor.Log(farmer.Name + ": " + (r - t) + "ms", LogLevel.Info);
                    }
                    else
                    {
                        Monitor.Log(farmer.Name + ": No Answer", LogLevel.Error);
                    }
                }
            }).register();

            new ConsoleCommand("syncmap", "Syncs map of a specified location to all clients. Exp.: syncmap Farm, syncmap BusStop, syncmao Town", (s, p) =>
            {
                if (p.Length < 1)
                {
                    Monitor.Log("No Location specified. ");
                }

                PyNet.syncLocationMapToAll(p[0]);
            }).register();
        }