Beispiel #1
0
        public override SObject attach(SObject o)
        {
            SObject priorAttachement = null;

            if (attachments.Length > 0 && attachments[0] != null)
            {
                if (!(attachments[0] is SheetMusic))
                {
                    SaveHandler.RebuildAll(attachments[0], attachments);
                }

                priorAttachement = (SObject)attachments[0].getOne();
            }

            if (o is SheetMusic)
            {
                attachments[0] = o;
                Game1.playSound("button1");
                return(priorAttachement);
            }
            else if (o == null)
            {
                attachments[0] = null;
                Game1.playSound("dwop");
                return(priorAttachement);
            }

            return(null);
        }
Beispiel #2
0
        public void rebuild(Dictionary <string, string> additionalSaveData, object replacement)
        {
            if (replacement is Tool t && t.attachments.Count > 0)
            {
                if (!(t.attachments[0] is SheetMusic))
                {
                    SaveHandler.RebuildAll(t.attachments[0], t.attachments);
                }

                attachments[0] = t.attachments[0];
            }

            foreach (string key in additionalSaveData.Keys)
            {
                if (key != "id" && !allAdditionalSaveData.ContainsKey(key))
                {
                    allAdditionalSaveData.Add(key, additionalSaveData[key]);
                }
            }
        }
Beispiel #3
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();
        }