示例#1
0
        public static void OnRemoveItem(Item item)
        {
            if (Game1.IsMasterGame)
            {
                BinListener.Unregister();

                bool removed = ModEntry.OldItems.Remove(item);
                Console.WriteLine($"Host local remove {item.Name} x{item.Stack}");
            }
        }
示例#2
0
        public static void OnShipItem(Item item, Farmer player)
        {
            if (Game1.IsMasterGame)
            {
                BinListener.Unregister();

                Console.WriteLine($"Host local bin add {item.Name} x{item.Stack}");

                if (!ModEntry.OldItems.ContainsKey(item))//Can be called twice by the game.
                {
                    ModEntry.OldItems.Add(item, player.UniqueMultiplayerID);
                }
            }
        }
示例#3
0
        public override void Entry(IModHelper helper)
        {
            ModHelper = helper;

            MoneyData = helper.Data.ReadJsonFile <MoneyDataModel>("moneyData.json");
            if (MoneyData == null)
            {
                Monitor.Log("Creating new moneyData.json");
                MoneyData = new MoneyDataModel();
                helper.Data.WriteJsonFile("moneyData.json", MoneyData);
            }

            Config = helper.Data.ReadJsonFile <Config>("config.json");
            if (Config == null)
            {
                Monitor.Log("Creating new config.json");
                Config = new Config();
                helper.Data.WriteJsonFile("config.json", Config);
            }

            helper.Events.GameLoop.Saved += delegate
            {
                if (Game1.IsMasterGame)
                {
                    Monitor.Log("Saving money data");
                    helper.Data.WriteJsonFile("moneyData.json", MoneyData);
                }
            };

            helper.Events.GameLoop.DayEnding += delegate
            {
                if (Game1.IsMasterGame)
                {
                    BinListener.Unregister();
                }
            };

            Patch.PatchAll("Ilyaki.CapitalistSplitMoney");
        }