public override void Entry(IModHelper helper)
        {
            config = Helper.ReadConfig <Config>();
            TMXLoaderMod.helper = Helper;
            monitor             = Monitor;
            if (config.converter)
            {
                exportAllMaps();
                convert();
            }
            loadContentPacks();
            setTileActions();
            helper.Events.Player.Warped += OnWarped;
            PyLua.registerType(typeof(Map), false, true);
            PyLua.registerType(typeof(TMXActions), false, false);
            PyLua.addGlobal("TMX", new TMXActions());
            new ConsoleCommand("loadmap", "Teleport to a map", (s, st) => {
                Game1.player.warpFarmer(new Warp(int.Parse(st[1]), int.Parse(st[2]), st[0], int.Parse(st[1]), int.Parse(st[2]), false));
            });
            fixCompatibilities();
            harmonyFix();

            helper.Events.GameLoop.UpdateTicked += (s, e) =>
            {
                if (e.IsOneSecond && Context.IsWorldReady && Game1.IsMasterGame && Game1.IsMultiplayer && Game1.otherFarmers.Values.Where(f => f.isActive() && f != Game1.player && !syncedFarmers.Contains(f)) is IEnumerable <SFarmer> ef && ef.Count() is int i && i > 0)
                {
                    syncMaps(ef);
                }
            };
        }
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            if (hasKisekae)
            {
                var registry = Helper.ModRegistry.GetType().GetField("Registry", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Helper.ModRegistry);
                System.Collections.IList list = (System.Collections.IList)registry.GetType().GetField("Mods", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(registry);
                foreach (var m in list)
                {
                    IManifest mmanifest = (IManifest)m.GetType().GetProperty("Manifest").GetValue(m);
                    if (mmanifest.UniqueID == "Kabigon.kisekae")
                    {
                        kisekae = (IMod)m.GetType().GetProperty("Mod").GetValue(m);
                        break;
                    }
                }
            }

            loadPacks();

            if (_config.water)
            {
                new CustomObjectData("Platonymous.Water", "Water/1/2/Cooking -7/Water/Plain drinking water./drink/0 0 0 0 0 0 0 0 0 0 0/0", Game1.objectSpriteSheet.getTile(247).setSaturation(0), Color.Aqua, type: typeof(WaterItem));
                ButtonClick.ActionButton.onClick((pos) => clickedOnWateringCan(pos), (p) => convertWater());
            }

            PyLua.registerType(typeof(CustomMachine), registerAssembly: true);
        }
        public override void Entry(IModHelper helper)
        {
            _helper  = Helper;
            _monitor = Monitor;
            _config  = Helper.ReadConfig <Config>();

            hasKisekae = helper.ModRegistry.IsLoaded("Kabigon.kisekae");

            if (hasKisekae)
            {
                var registry = helper.ModRegistry.GetType()
                               .GetField("Registry", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(helper.ModRegistry);
                System.Collections.IList list = (System.Collections.IList)registry.GetType()
                                                .GetField("Mods", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(registry);
                foreach (var m in list)
                {
                    IManifest mmanifest = (IManifest)m.GetType().GetProperty("Manifest").GetValue(m);
                    if (mmanifest.UniqueID == "Kabigon.kisekae")
                    {
                        kisekae = (IMod)m.GetType().GetProperty("Mod").GetValue(m);
                        break;
                    }
                }
            }

            loadPacks();
            MenuEvents.MenuChanged += MenuEvents_MenuChanged;
            SaveEvents.AfterLoad   += (s, e) =>
            {
                foreach (var c in craftingrecipes)
                {
                    if (Game1.player.craftingRecipes.ContainsKey(c.Key))
                    {
                        Game1.player.craftingRecipes[c.Key] = c.Value;
                    }
                    else
                    {
                        Game1.player.craftingRecipes.Add(c.Key, c.Value);
                    }
                }
            };

            harmonyFix();
            SaveHandler.addPreprocessor(legacyFix);
            SaveHandler.addReplacementPreprocessor(fixLegacyObject);
            helper.ConsoleCommands.Add("replace_custom_farming", "Triggers Custom Farming Replacement",
                                       replaceCustomFarming);

            if (_config.water)
            {
                new CustomObjectData("Platonymous.Water",
                                     "Water/1/2/Cooking -7/Water/Plain drinking water./drink/0 0 0 0 0 0 0 0 0 0 0/0",
                                     Game1.objectSpriteSheet.getTile(247).setSaturation(0), Color.Aqua, type: typeof(WaterItem));
                ButtonClick.ActionButton.onClick((pos) => clickedOnWateringCan(pos), (p) => convertWater());
            }

            PyLua.registerType(typeof(CustomMachine), registerAssembly: true);
        }
 public override void Entry(IModHelper helper)
 {
     Monitor.Log("Environment:" + PyUtils.getContentFolder());
     exportAllMaps();
     convert();
     loadContentPacks();
     setTileActions();
     LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
     PyLua.registerType(typeof(Map), false, true);
     PyLua.registerType(typeof(TMXActions), false, false);
     PyLua.addGlobal("TMX", new TMXActions());
 }
Beispiel #5
0
        public override void Entry(IModHelper helper)
        {
            config = Helper.ReadConfig <Config>();
            TMXLoaderMod.helper = Helper;
            monitor             = Monitor;
            if (config.converter)
            {
                exportAllMaps();
                convert();
            }
            loadContentPacks();
            setTileActions();
            helper.Events.Player.Warped += OnWarped;
            PyLua.registerType(typeof(Map), false, true);
            PyLua.registerType(typeof(TMXActions), false, false);
            PyLua.addGlobal("TMX", new TMXActions());
            new ConsoleCommand("loadmap", "Teleport to a map", (s, st) => {
                Game1.player.warpFarmer(new Warp(int.Parse(st[1]), int.Parse(st[2]), st[0], int.Parse(st[1]), int.Parse(st[2]), false));
            }).register();

            new ConsoleCommand("removeNPC", "Removes an NPC", (s, st) => {
                if (Game1.getCharacterFromName(st.Last()) == null)
                {
                    Monitor.Log("Couldn't find NPC with that name!", LogLevel.Alert);
                }
                else
                {
                    Game1.removeThisCharacterFromAllLocations(Game1.getCharacterFromName(st.Last()));
                    if (Game1.player.friendshipData.ContainsKey(st.Last()))
                    {
                        Game1.player.friendshipData.Remove(st.Last());
                    }
                    Monitor.Log(st.Last() + " was removed!", LogLevel.Info);
                }
            }).register();

            fixCompatibilities();
            harmonyFix();

            helper.Events.GameLoop.UpdateTicked += (s, e) =>
            {
                if (e.IsOneSecond && Context.IsWorldReady && Game1.IsMasterGame && Game1.IsMultiplayer && Game1.otherFarmers.Values.Where(f => f.isActive() && f != Game1.player && !syncedFarmers.Contains(f)) is IEnumerable <SFarmer> ef && ef.Count() is int i && i > 0)
                {
                    syncMaps(ef);
                }
            };
        }
Beispiel #6
0
        public override void Entry(IModHelper helper)
        {
            TMXLoaderMod.helper = Helper;
            monitor             = Monitor;
            Monitor.Log("Environment:" + PyUtils.getContentFolder());
            exportAllMaps();
            convert();
            loadContentPacks();
            setTileActions();
            PlayerEvents.Warped        += LocationEvents_CurrentLocationChanged;
            TimeEvents.AfterDayStarted += TimeEvents_AfterDayStarted;
            PyLua.registerType(typeof(Map), false, true);
            PyLua.registerType(typeof(TMXActions), false, false);
            PyLua.addGlobal("TMX", new TMXActions());
            fixCompatibilities();
            harmonyFix();

            GameEvents.OneSecondTick += (s, e) =>
            {
                if (Context.IsWorldReady && Game1.IsServer && Game1.IsMultiplayer)
                {
                    if (Game1.otherFarmers.Values.Where(f => f.isActive() && !syncedFarmers.Contains(f)) is IEnumerable <SFarmer> ef && ef.Count() is int i && i > 0)
                    {
                        syncMaps(ef);
                    }
                }
            };

            TimeEvents.AfterDayStarted += (s, e) => {
                List <SFarmer> toRemove = new List <SFarmer>();

                foreach (SFarmer farmer in syncedFarmers)
                {
                    if (!Game1.otherFarmers.ContainsKey(farmer.UniqueMultiplayerID) || !Game1.otherFarmers[farmer.UniqueMultiplayerID].isActive())
                    {
                        toRemove.Add(farmer);
                    }
                }

                foreach (SFarmer remove in toRemove)
                {
                    syncedFarmers.Remove(remove);
                }
            };
        }
Beispiel #7
0
 public override void Entry(IModHelper helper)
 {
     maplayers           = new List <Map>();
     TMXLoaderMod.helper = Helper;
     monitor             = Monitor;
     Monitor.Log("Environment:" + PyUtils.getContentFolder());
     exportAllMaps();
     convert();
     loadContentPacks();
     setTileActions();
     PlayerEvents.Warped += LocationEvents_CurrentLocationChanged;
     PyLua.registerType(typeof(Map), false, true);
     PyLua.registerType(typeof(TMXActions), false, false);
     PyLua.addGlobal("TMX", new TMXActions());
     fixCompatibilities();
     harmonyFix();
     PlayerEvents.Warped += (s, e) => { if (e.NewLocation is GameLocation l && l.map is Map m)
                                        {
                                            addMoreMapLayers(m);
                                        }
     };
 }
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            if (config.converter)
            {
                exportAllMaps();
                convert();
            }
            loadContentPacks();
            setTileActions();

            PyLua.registerType(typeof(Map), false, true);
            PyLua.registerType(typeof(TMXActions), false, false);
            PyLua.addGlobal("TMX", new TMXActions());
            new ConsoleCommand("loadmap", "Teleport to a map", (s, st) => {
                Game1.player.warpFarmer(new Warp(int.Parse(st[1]), int.Parse(st[2]), st[0], int.Parse(st[1]), int.Parse(st[2]), false));
            }).register();

            new ConsoleCommand("removeNPC", "Removes an NPC", (s, st) => {
                if (Game1.getCharacterFromName(st.Last()) == null)
                {
                    Monitor.Log("Couldn't find NPC with that name!", LogLevel.Alert);
                }
                else
                {
                    Game1.removeThisCharacterFromAllLocations(Game1.getCharacterFromName(st.Last()));
                    if (Game1.player.friendshipData.ContainsKey(st.Last()))
                    {
                        Game1.player.friendshipData.Remove(st.Last());
                    }
                    Monitor.Log(st.Last() + " was removed!", LogLevel.Info);
                }
            }).register();

            fixCompatibilities();
            harmonyFix();
        }
        public override void Entry(IModHelper helper)
        {
            _helper  = Helper;
            _monitor = Monitor;
            _config  = Helper.ReadConfig <Config>();

            loadPacks();
            MenuEvents.MenuChanged += MenuEvents_MenuChanged;
            SaveEvents.AfterLoad   += (s, e) =>
            {
                foreach (var c in craftingrecipes)
                {
                    if (Game1.player.craftingRecipes.ContainsKey(c.Key))
                    {
                        Game1.player.craftingRecipes[c.Key] = c.Value;
                    }
                    else
                    {
                        Game1.player.craftingRecipes.Add(c.Key, c.Value);
                    }
                }
            };

            harmonyFix();
            SaveHandler.addPreprocessor(legacyFix);
            SaveHandler.addReplacementPreprocessor(fixLegacyObject);
            helper.ConsoleCommands.Add("replace_custom_farming", "Triggers Custom Farming Replacement", replaceCustomFarming);

            if (_config.water)
            {
                new CustomObjectData("Platonymous.Water", "Water/1/2/Cooking -7/Water/Plain drinking water./drink/0 0 0 0 0 0 0 0 0 0 0/0", Game1.objectSpriteSheet.getTile(247).setSaturation(0), Color.Aqua, type: typeof(WaterItem));
                ButtonClick.ActionButton.onClick((pos) => clickedOnWateringCan(pos), (p) => convertWater());
            }

            PyLua.registerType(typeof(CustomMachine), registerAssembly: true);
        }