Example #1
0
        public override void Entry(IModHelper helper)
        {
            moneyReceiver = new PyResponder <bool, int>(moneyReceiverName, (i) => { Game1.player.Money += i; return(true); }, 30);
            moneyReceiver.start();
            #region moneyItem
            new CustomObjectData("Platonymous.G", "G/1/-300/Basic/G/The common currency of Pelican Town.", Game1.mouseCursors.getArea(new Rectangle(280, 410, 16, 16)), Color.White, type: typeof(GoldItem));
            ButtonClick.ActionButton.onClick((pos) => new List <IClickableMenu>(Game1.onScreenMenus).Exists(m => m is DayTimeMoneyBox && m.isWithinBounds(pos.X, pos.Y - 180) && m.isWithinBounds(pos.X, pos.Y) && m.isWithinBounds(pos.X, pos.Y + 50)), (p) => convertMoney());
            #endregion

            #region harmony
            HarmonyInstance instance = HarmonyInstance.Create("Platonymous.SplitMoney");
            instance.PatchAll(Assembly.GetExecutingAssembly());
            #endregion
        }
Example #2
0
        public override void Entry(IModHelper helper)
        {
            SMonitor      = Monitor;
            SHelper       = Helper;
            moneyReceiver = new PyResponder <bool, int>(moneyReceiverName, (i) => { Game1.player.Money += i; return(true); }, 30);
            moneyReceiver.start();
            moneyPoolReceiver = new PyResponder <bool, string>(moneyPoolName, (s) =>
            {
                if (s.Split('>') is string[] split && split.Length > 1)
                {
                    moneyPool.AddOrReplace(split[0], int.Parse(split[1]));
                }

                return(true);
            }, 30);
Example #3
0
        public override void Entry(IModHelper helper)
        {
            monitor         = Monitor;
            SnakeMod.helper = helper;
            helper.Events.GameLoop.GameLaunched += (o, e) =>
            {
                sdata = new CustomObjectData("Snake", "Snake/0/-300/Crafting -9/Play 'Snake by Platonymous' at home!/true/true/0/Snake", helper.Content.Load <Texture2D>(@"Assets/arcade.png"), Color.White, bigCraftable: true, type: typeof(SnakeMachine));

                if (Helper.ModRegistry.GetApi <IMobilePhoneApi>("aedenthorn.MobilePhone") is IMobilePhoneApi api)
                {
                    Texture2D appIcon = Helper.Content.Load <Texture2D>(Path.Combine("assets", "mobile_app_icon.png"));
                    bool      success = api.AddApp(Helper.ModRegistry.ModID + "MobileSnake", "Snake", () =>
                    {
                        Game1.currentMinigame = new SnakeMinigame(helper);
                    }, appIcon);
                }
            };
            helper.Events.GameLoop.SaveLoaded += (o, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    SnakeMinigame.HighscoreTable = helper.Data.ReadSaveData <HighscoreList>("Platonymous.SnakeAcrcade.Highscore");
                    if (SnakeMinigame.HighscoreTable == null)
                    {
                        SnakeMinigame.HighscoreTable = new HighscoreList();
                    }

                    Monitor.Log("Loading Highscores");

                    foreach (Highscore h in SnakeMinigame.HighscoreTable.Entries)
                    {
                        Monitor.Log(h.Name + ": " + h.Value);
                    }
                }
                addToCatalogue();
            };


            helper.Events.GameLoop.Saving += (o, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    helper.Data.WriteSaveData <HighscoreList>("Platonymous.SnakeAcrcade.Highscore", SnakeMinigame.HighscoreTable);
                }
            };

            highscoreReceiver = new PyResponder <bool, Highscore>(highscoreReceiverName, (score) =>
            {
                if (Game1.IsMasterGame)
                {
                    Monitor.Log("Received Highscore from " + score.Name + "(" + score.Value + ")");
                    SnakeMinigame.setScore(score.Name, score.Value);
                    PyNet.sendRequestToAllFarmers <bool>(highscoreListReceiverName, SnakeMinigame.HighscoreTable, null, serializationType: PyTK.Types.SerializationType.JSON);
                }
                return(true);
            }, 60, requestSerialization: SerializationType.JSON);

            highscoreReceiver.start();

            highscoreListReceiver = new PyResponder <bool, HighscoreList>(highscoreListReceiverName, (score) =>
            {
                if (!Game1.IsMasterGame)
                {
                    Monitor.Log("Received Highscore Update");

                    foreach (Highscore h in score.Entries)
                    {
                        Monitor.Log(h.Name + ": " + h.Value);
                    }

                    SnakeMinigame.HighscoreTable = score;
                }
                return(true);
            }, 40, requestSerialization: SerializationType.JSON);

            highscoreListReceiver.start();

            helper.Events.Multiplayer.PeerContextReceived += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    PyUtils.setDelayedAction(5000, () => PyNet.sendRequestToAllFarmers <bool>(highscoreListReceiverName, SnakeMinigame.HighscoreTable, null, serializationType: PyTK.Types.SerializationType.JSON));
                }
            };
        }