Beispiel #1
0
 internal static void RealShop(object s, EventArgsMouseStateChanged e)
 {
     if (e.NewState.RightButton != ButtonState.Pressed)
     {
         ControlEvents.MouseChanged -= RealShop;
         try
         {
             if (!Configs.Compound.Shops.ContainsKey(_arguments[0]))
             {
                 Game1.activeClickableMenu = new ShopMenu(new List <Item>(), 0, null);
                 AdvancedLocationLoaderMod.Logger.Log("Unable to open shop, shop not found: " + _arguments[0], StardewModdingAPI.LogLevel.Error);
             }
             else
             {
                 Configs.ShopConfig shop  = Configs.Compound.Shops[_arguments[0]];
                 List <Item>        stock = new List <Item>();
                 NPC portrait             = new NPC();
                 EntoFramework.GetContentRegistry().RegisterXnb(shop.Portrait, shop.Portrait);
                 portrait.Portrait = Game1.content.Load <Texture2D>(shop.Portrait);
                 portrait.name     = shop.Owner;
                 foreach (Configs.ShopItem item in shop.Items)
                 {
                     if (!string.IsNullOrEmpty(item.Conditions) && !Conditions.CheckConditionList(item.Conditions, AdvancedLocationLoaderMod.ConditionResolver))
                     {
                         continue;
                     }
                     StardewValley.Object result;
                     if (item.Price != null)
                     {
                         result = new StardewValley.Object(item.Id, item.Stock, false, (int)item.Price);
                     }
                     else
                     {
                         result = new StardewValley.Object(item.Id, item.Stock, false, -1);
                     }
                     if (item.Stack > 1)
                     {
                         stock.Add(new StackableShopObject(result, item.Stack));
                     }
                     else
                     {
                         stock.Add(result);
                     }
                 }
                 if (stock.Count == 0)
                 {
                     AdvancedLocationLoaderMod.Logger.Log("No stock: " + _arguments[0] + ", if this is intended this message can be ignored.", StardewModdingAPI.LogLevel.Warn);
                 }
                 ShopMenu menu = new ShopMenu(stock);
                 menu.portraitPerson        = portrait;
                 menu.potraitPersonDialogue = shop.Messages[_Random.Next(shop.Messages.Count)];
                 Game1.activeClickableMenu  = menu;
             }
         }
         catch (Exception err)
         {
             AdvancedLocationLoaderMod.Logger.Log(StardewModdingAPI.LogLevel.Error, "Unable to open shop due to unexpected error: ", err);
         }
     }
 }
Beispiel #2
0
        /*********
        ** Private methods
        *********/
        /// <summary>Recursively find XNBs and register them with the content registry.</summary>
        /// <param name="root">The root path being searched.</param>
        /// <param name="path">The path for which to load XNBs.</param>
        private int LoadOverrides(string root, string path)
        {
            int files = 0;

            // log path
            {
                string relativePath = path.Replace(root + Path.DirectorySeparatorChar, Path.DirectorySeparatorChar.ToString()).Replace(root, Path.DirectorySeparatorChar.ToString());
                this.Monitor.Log($"Scanning for files and directories in {relativePath}", LogLevel.Trace);
            }

            // load subfolders
            foreach (string dir in Directory.EnumerateDirectories(path))
            {
                files += this.LoadOverrides(root, Path.Combine(path, dir));
            }

            // load files
            foreach (string file in Directory.EnumerateFiles(path))
            {
                string filePath = Path.Combine(path, Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
                string from     = filePath.Replace(root + Path.DirectorySeparatorChar, "");
                this.Monitor.Log($"Redirecting: {from} ~> {filePath}.xnb", LogLevel.Trace);
                EntoFramework.GetContentRegistry().RegisterXnb(from, filePath);
                files++;
            }

            return(files);
        }
Beispiel #3
0
        public override void Entry(IModHelper helper)
        {
            // init
            modPath = helper.DirectoryPath;
            Config  = helper.ReadConfig <MorePetsConfig>();

            // load textures
            EntoFramework.GetContentRegistry().RegisterTexture("paths_objects_MorePetsTilesheet", Path.Combine(modPath, "box.png"));
            this.LoadPetSkins(out CatTextures, out DogTextures);
            Monitor.Log($"Found [{CatTextures.Length}] Cat and [{DogTextures.Length}] Dog skins", LogLevel.Info);

            // hook events
            GameEvents.UpdateTick                 += GameEvents_UpdateTick;
            TimeEvents.AfterDayStarted            += TimeEvents_AfterDayStarted;
            ControlEvents.ControllerButtonPressed += ControlEvents_ControllerButtonPressed;
            ControlEvents.MouseChanged            += ControlEvents_MouseChanged;
            //LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
            helper.ConsoleCommands.Add("kill_pets", "Kills all the pets you adopted using MorePets, you monster", this.CommandFired_KillPets);

            // add console commands
            if (Config.DebugMode)
            {
                // DEV COMMANDS, kept in should they be needed in the future
                helper.ConsoleCommands
                .Add("spawn_pet", "Spawns either a `dog` or a `cat` depending on the given name | spawn_pet <type> <skin>", this.CommandFired_SpawnPet)
                .Add("test_adoption", "Triggers the adoption dialogue", this.CommandFired_TestAdoption);
            }

            // check version
            Version version = new Version(this.ModManifest.Version.MajorVersion, this.ModManifest.Version.MinorVersion, this.ModManifest.Version.PatchVersion);

            VersionChecker.AddCheck("MorePets", version, "https://raw.githubusercontent.com/Entoarox/StardewMods/master/VersionChecker/MorePets.json");
        }
Beispiel #4
0
 public override void Entry(IModHelper helper)
 {
     VersionChecker.AddCheck("FasterPaths", Version, "https://raw.githubusercontent.com/Entoarox/Stardew-SMAPI-mods/master/Projects/VersionChecker/FasterPaths.json");
     cfg = Helper.ReadConfig <ConfigFP>();
     GameEvents.UpdateTick += UpdateTick;
     helper.ConsoleCommands.Add("fp_info", "Gives info about the path you are currently standing on", this.CommandInfo);
     Modifiers = new FarmerModifier[10] {
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.woodFloorBoost, RunSpeedModifier = cfg.woodFloorBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.stoneFloorBoost, RunSpeedModifier = cfg.stoneFloorBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.weatheredFloorBoost, RunSpeedModifier = cfg.weatheredFloorBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.crystalFloorBoost, RunSpeedModifier = cfg.crystalFloorBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.strawFloorBoost, RunSpeedModifier = cfg.strawFloorBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.gravelPathBoost, RunSpeedModifier = cfg.gravelPathBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.woodPathBoost, RunSpeedModifier = cfg.woodPathBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.crystalPathBoost, RunSpeedModifier = cfg.crystalPathBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.cobblePathBoost, RunSpeedModifier = cfg.cobblePathBoost
         },
         new FarmerModifier()
         {
             WalkSpeedModifier = cfg.steppingStoneBoost, RunSpeedModifier = cfg.steppingStoneBoost
         }
     };
     PlayerHelper = EntoFramework.GetPlayerHelper();
     PlayerHelper.AddModifier(new FarmerModifier()
     {
         WalkSpeedModifier = cfg.walkSpeedBoost, RunSpeedModifier = cfg.runSpeedBoost
     });
 }
Beispiel #5
0
 public override void Entry(IModHelper helper)
 {
     VersionChecker.AddCheck("FurnitureAnywhere", typeof(FurnitureAnywhereMod).Assembly.GetName().Version, "https://raw.githubusercontent.com/Entoarox/StardewMods/master/VersionChecker/FurnitureAnywhere.json");
     MoreEvents.ActiveItemChanged          += MoreEvents_ActiveItemChanged;
     LocationEvents.CurrentLocationChanged += TriggerItemChangedEvent;
     MenuEvents.MenuChanged += TriggerItemChangedEvent;
     MenuEvents.MenuClosed  += TriggerItemChangedEvent;
     SaveEvents.BeforeSave  += SaveEvents_BeforeSave;
     SaveEvents.AfterSave   += SaveEvents_AfterSave_AfterLoad;
     SaveEvents.AfterLoad   += SaveEvents_AfterSave_AfterLoad;
     EntoFramework.GetTypeRegistry().RegisterType <AnywhereFurniture>();
 }
Beispiel #6
0
        public override void Entry(IModHelper helper)
        {
            ModPath   = helper.DirectoryPath;
            Logger    = Monitor;
            Localizer = helper.Translation;
            VersionChecker.AddCheck("AdvancedLocationLoader", GetType().Assembly.GetName().Version, "https://raw.githubusercontent.com/Entoarox/StardewMods/master/VersionChecker/AdvancedLocationLoader.json");

            GameEvents.UpdateTick                 += FirstUpdateTick;
            MoreEvents.ActionTriggered            += Events.MoreEvents_ActionTriggered;
            MoreEvents.WorldReady                 += Events.MoreEvents_WorldReady;
            LocationEvents.CurrentLocationChanged += Events.LocationEvents_CurrentLocationChanged;

            ITypeRegistry registry = EntoFramework.GetTypeRegistry();

            registry.RegisterType <Locations.Greenhouse>();
            registry.RegisterType <Locations.Sewer>();
            registry.RegisterType <Locations.Desert>();
            registry.RegisterType <Locations.DecoratableLocation>();
        }
Beispiel #7
0
        internal static void React(StardewValley.Farmer who, string[] arguments, Vector2 tile)
        {
            int interval = Convert.ToInt32(arguments[0]);

            int[] indexes = arguments[1].Split(',').Select(e => Convert.ToInt32(e)).ToArray();
            var   layer   = who.currentLocation.Map.GetLayer("Buildings");
            var   source  = layer.Tiles[(int)tile.X, (int)tile.Y];

            xTile.ObjectModel.PropertyValue property = EntoFramework.GetLocationHelper().GetTileProperty(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, "Action");
            int delay = interval * indexes.Length;

            EntoFramework.GetLocationHelper().SetAnimatedTile(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, indexes, interval, source.TileSheet.Id);
            System.Threading.Timer timer = null;
            timer = new System.Threading.Timer((obj) =>
            {
                EntoFramework.GetLocationHelper().SetStaticTile(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, source.TileIndex, source.TileSheet.Id);
                EntoFramework.GetLocationHelper().SetTileProperty(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, "Action", property);
                timer.Dispose();
            },
                                               null, delay, System.Threading.Timeout.Infinite);
        }
Beispiel #8
0
        public static void ApplyPatches()
        {
            int stage = 0;

            try
            {
                stage++; // 1
                SecondaryLocationManifest1_2 trueCompound = new SecondaryLocationManifest1_2();
                AdvancedLocationLoaderMod.Logger.Log("Applying Patches...", LogLevel.Trace);
                // First we need to check any things we couldnt before
                foreach (Location obj in Compound.Locations)
                {
                    if (Game1.getLocationFromName(obj.MapName) != null)
                    {
                        AdvancedLocationLoaderMod.Logger.Log("Unable to add location, it already exists: " + obj.ToString(), LogLevel.Error);
                    }
                    else
                    {
                        try
                        {
                            xTile.Map map = new LocalizedContentManager(Game1.content.ServiceProvider, Path.GetDirectoryName(obj.FileName)).Load <xTile.Map>(Path.GetFileName(obj.FileName));
                            MapSizes.Add(obj.MapName, new Point(map.DisplayWidth, map.DisplayHeight));
                            MapCache.Add(obj.MapName, map);
                            AffectedLocations.Add(obj.MapName);
                            trueCompound.Locations.Add(obj);
                        }
                        catch (Exception err)
                        {
                            AdvancedLocationLoaderMod.Logger.Log(LogLevel.Error, "Unable to add location, the map file caused a error when loaded: " + obj.ToString(), err);
                        }
                    }
                }
                stage++; // 2
                foreach (Override obj in Compound.Overrides)
                {
                    if (Game1.getLocationFromName(obj.MapName) == null)
                    {
                        AdvancedLocationLoaderMod.Logger.Log("Unable to override location, it does not exist: " + obj.ToString(), LogLevel.Error);
                    }
                    else
                    {
                        try
                        {
                            xTile.Map map = new LocalizedContentManager(Game1.content.ServiceProvider, Path.GetDirectoryName(obj.FileName)).Load <xTile.Map>(Path.GetFileName(obj.FileName));
                            MapSizes.Add(obj.MapName, new Point(map.DisplayWidth, map.DisplayHeight));
                            trueCompound.Overrides.Add(obj);
                        }
                        catch (Exception err)
                        {
                            AdvancedLocationLoaderMod.Logger.Log(LogLevel.Error, "Unable to override location, the map file caused a error when loaded: " + obj.ToString(), err);
                        }
                    }
                }
                stage++; // 3
                trueCompound.Redirects = Compound.Redirects;
                stage++; // 4
                foreach (Tilesheet obj in Compound.Tilesheets)
                {
                    if (Game1.getLocationFromName(obj.MapName) == null && !AffectedLocations.Contains(obj.MapName))
                    {
                        AdvancedLocationLoaderMod.Logger.Log("Unable to patch tilesheet, location does not exist: " + obj.ToString(), LogLevel.Error);
                    }
                    else
                    {
                        trueCompound.Tilesheets.Add(obj);
                    }
                }
                stage++; // 5
                foreach (Tile obj in Compound.Tiles)
                {
                    string info = CheckTileInfo(obj);
                    if (info != null)
                    {
                        if (info != "OPTIONAL")
                        {
                            AdvancedLocationLoaderMod.Logger.Log("Unable to apply tile patch, " + info + ":" + obj.ToString(), LogLevel.Error);
                            continue;
                        }
                    }
                    else if (obj.SheetId != null && (!TilesheetCache.ContainsKey(obj.MapName) || !TilesheetCache[obj.MapName].Contains(obj.SheetId)))
                    {
                        xTile.Map map = MapCache.ContainsKey(obj.MapName) ? MapCache[obj.MapName] : Game1.getLocationFromName(obj.MapName).map;
                        if (map.GetTileSheet(obj.SheetId) == null)
                        {
                            AdvancedLocationLoaderMod.Logger.Log("Unable to apply tile patch, tilesheet does not exist:" + obj.ToString(), LogLevel.Error);
                            continue;
                        }
                    }
                    trueCompound.Tiles.Add(obj);
                }
                stage++; // 6
                foreach (Property obj in Compound.Properties)
                {
                    string info = CheckTileInfo(obj);
                    if (info != null)
                    {
                        if (info != "OPTIONAL")
                        {
                            AdvancedLocationLoaderMod.Logger.Log("Unable to apply property patch, " + info + ":" + obj.ToString(), LogLevel.Error);
                        }
                    }
                    else
                    {
                        trueCompound.Properties.Add(obj);
                    }
                }
                stage++; // 7
                foreach (Warp obj in Compound.Warps)
                {
                    string info = CheckTileInfo(obj);
                    if (info != null)
                    {
                        if (info != "OPTIONAL")
                        {
                            AdvancedLocationLoaderMod.Logger.Log("Unable to apply warp patch, " + info + ":" + obj.ToString(), LogLevel.Error);
                        }
                    }
                    trueCompound.Warps.Add(obj);
                }
                stage++; // 8
                foreach (Conditional obj in Compound.Conditionals)
                {
                    Configs.Compound.Conditionals.Add(obj);
                }
                stage++; // 9
                foreach (TeleporterList obj in Compound.Teleporters)
                {
                    Configs.Compound.Teleporters.Add(obj);
                }
                stage++; // 10
                // At this point any edits that showed problems have been removed, so now we can actually process everything
                foreach (Location obj in trueCompound.Locations)
                {
                    Processors.ApplyLocation(obj);
                }
                stage++; // 11
                foreach (Override obj in trueCompound.Overrides)
                {
                    Processors.ApplyOverride(obj);
                }
                stage++; // 12
                foreach (Redirect obj in trueCompound.Redirects)
                {
                    EntoFramework.GetContentRegistry().RegisterXnb(obj.FromFile, obj.ToFile);
                }
                stage++; // 13
                foreach (Tilesheet obj in trueCompound.Tilesheets)
                {
                    Processors.ApplyTilesheet(obj);
                    if (obj.Seasonal)
                    {
                        Configs.Compound.SeasonalTilesheets.Add(obj);
                    }
                }
                stage++; // 14
                foreach (Tile obj in trueCompound.Tiles)
                {
                    Processors.ApplyTile(obj);
                    if (!string.IsNullOrEmpty(obj.Conditions))
                    {
                        Configs.Compound.DynamicTiles.Add(obj);
                    }
                }
                stage++; // 15
                foreach (Property obj in trueCompound.Properties)
                {
                    Processors.ApplyProperty(obj);
                    if (!string.IsNullOrEmpty(obj.Conditions))
                    {
                        Configs.Compound.DynamicProperties.Add(obj);
                    }
                }
                stage++; // 16
                foreach (Warp obj in trueCompound.Warps)
                {
                    Processors.ApplyWarp(obj);
                    if (!string.IsNullOrEmpty(obj.Conditions))
                    {
                        Configs.Compound.DynamicWarps.Add(obj);
                    }
                }
                stage++; // 17
                NPC.populateRoutesFromLocationToLocationList();
                stage++; // 18
                Compound          = null;
                Conditionals      = null;
                AffectedLocations = null;
                MapSizes          = null;
                stage++; // 19
                VerifyPatchIntegrity();
                stage++; // 20
                AdvancedLocationLoaderMod.Logger.Log("Patches have been applied", LogLevel.Debug);
            }
            catch (Exception err)
            {
                AdvancedLocationLoaderMod.Logger.ExitGameImmediately("Unable to patch the game, a unexpected error occured at stage " + stage.ToString(), err);
            }
        }
Beispiel #9
0
 public static void SetTile(this GameLocation self, int x, int y, int index, string layer, string sheet)
 {
     EntoFramework.GetLocationHelper().SetStaticTile(self, layer, x, y, index, sheet);
 }