private static KeyValuePair <int, int> GetMapCoordinatesForNPC(NPC character) { string locationName = character.currentLocation?.Name ?? character.DefaultMap; // Ginger Island if (character.currentLocation is IslandLocation) { return(new KeyValuePair <int, int>(1104, 658)); } // Scale Town and Forest if (locationName == "Town" || locationName == "Forest") { int xStart = locationName == "Town" ? 595 : 183; int yStart = locationName == "Town" ? 163 : 378; int areaWidth = locationName == "Town" ? 345 : 319; int areaHeight = locationName == "Town" ? 330 : 261; xTile.Map map = character.currentLocation.Map; float xScale = (float)areaWidth / (float)map.DisplayWidth; float yScale = (float)areaHeight / (float)map.DisplayHeight; float scaledX = character.position.X * xScale; float scaledY = character.position.Y * yScale; int xPos = (int)scaledX + xStart; int yPos = (int)scaledY + yStart; return(new KeyValuePair <int, int>(xPos, yPos)); } // Other known locations return(_mapLocations.SafeGet(locationName, new KeyValuePair <int, int>(0, 0))); }
/// <summary> /// Loads an xTile map into memory. /// </summary> public void LoadMap(string mapDirectory) { Display = new XnaDisplayDevice(Game.Content, Game.GraphicsDevice); Viewport = new xTile.Dimensions.Rectangle(new Size(Game.GraphicsDevice.PresentationParameters.BackBufferWidth, Game.GraphicsDevice.PresentationParameters.BackBufferHeight)); XMap = Game.Content.Load <xTile.Map>(mapDirectory); XMap.LoadTileSheets(Display); }
public Sprite( Vector2 location, Vector2 velocity, xTile.Map map) { this.location = location; this.velocity = velocity; this.map = map; // this.origin = new Vector2(frameWidth / 2, frameHeight / 2); tag = null; }
public Pacman( Vector2 location, Texture2D texture, Rectangle initialFrame, Vector2 velocity, xTile.Map map) : base(location, texture, initialFrame, velocity) { direction = Direction.RIGHT; target = location + new Vector2(32, 0); this.map = map; UpdateDirection(); }
public Particle( Texture2D texture, Vector2 location, Vector2 velocity, float lifeSpan, float angularVelocity, bool ignoreCollisions, xTile.Map map) : base(location, velocity, map) { this.lifeSpan = lifeSpan; this.angularvelocity = angularVelocity; this.Dead = false; this.IgnoreCollisions = ignoreCollisions; }
internal static void ApplyLocation(Location location) { AdvancedLocationLoaderMod.Logger.Log(location.ToString(), LogLevel.Trace); try { GameLocation loc; ContentRegistry.RegisterXnb(location.FileName, location.FileName); xTile.Map map = Game1.content.Load <xTile.Map>(location.FileName); switch (location.Type) { case "Cellar": loc = new StardewValley.Locations.Cellar(map, location.MapName); loc.objects = new SerializableDictionary <Microsoft.Xna.Framework.Vector2, StardewValley.Object>(); break; case "BathHousePool": loc = new StardewValley.Locations.BathHousePool(map, location.MapName); break; case "Decoratable": loc = new Locations.DecoratableLocation(map, location.MapName); break; case "Desert": loc = new Locations.Desert(map, location.MapName); break; case "Greenhouse": loc = new Locations.Greenhouse(map, location.MapName); break; case "Sewer": loc = new Locations.Sewer(map, location.MapName); break; default: loc = new GameLocation(map, location.MapName); break; } loc.isOutdoors = location.Outdoor; loc.isFarm = location.Farmable; Game1.locations.Add(loc); } catch (Exception err) { AdvancedLocationLoaderMod.Logger.ExitGameImmediately("Unable to add custom location, a unexpected error occured: " + location.ToString(), err); } }
internal static void ApplyLocation(IContentPack contentPack, Location location) { try { GameLocation loc; xTile.Map map = contentPack.LoadAsset <xTile.Map>(location.FileName); switch (location.Type) { case "Cellar": loc = new StardewValley.Locations.Cellar(map, location.MapName) { objects = new SerializableDictionary <Microsoft.Xna.Framework.Vector2, StardewValley.Object>() }; break; case "BathHousePool": loc = new StardewValley.Locations.BathHousePool(map, location.MapName); break; case "Decoratable": loc = new Locations.DecoratableLocation(map, location.MapName); break; case "Desert": loc = new Locations.Desert(map, location.MapName); break; case "Greenhouse": loc = new Locations.Greenhouse(map, location.MapName); break; case "Sewer": loc = new Locations.Sewer(map, location.MapName); break; default: loc = new GameLocation(map, location.MapName); break; } loc.isOutdoors = location.Outdoor; loc.isFarm = location.Farmable; Game1.locations.Add(loc); } catch (Exception err) { ModEntry.Logger.ExitGameImmediately("Unable to add custom location, a unexpected error occured: " + location, err); } }
/********* ** Private methods *********/ private bool PreprocessTile(TileInfo info, HashSet <string> customLocationNames, IDictionary <string, Point> mapSizes, out string error) { error = null; if (Game1.getLocationFromName(info.MapName) == null && !customLocationNames.Contains(info.MapName)) { if (!info.Optional) { error = "location does not exist"; } return(false); } Point size; if (!customLocationNames.Contains(info.MapName)) { xTile.Map map = Game1.getLocationFromName(info.MapName).map; size = new Point(map.DisplayWidth, map.DisplayHeight); customLocationNames.Add(info.MapName); mapSizes[info.MapName] = size; } else { size = mapSizes[info.MapName]; } int minX = 0; int minY = 0; int maxX = size.X; int maxY = size.Y; if (info is Warp) { minX--; minY--; maxX++; maxY++; } if (info.TileX < minX || info.TileY < minY || info.TileX > maxX || info.TileY > maxY) { error = "placement is outside location bounds"; return(false); } return(true); }
public Enemy( ContentManager content, Vector2 location, Vector2 velocity, int x_left, // Left x extend int x_right, xTile.Map map) : base(location, velocity, map) { this.x_left = x_left; this.x_right = x_right; animations.Add("run", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Badguys\goomba"), 32, "run", 0, 2)); animations["run"].LoopAnimation = true; animations["run"].FrameLength = 0.08f; animations.Add("die", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Badguys\goomba"), 32, "die", 65, 1)); animations["die"].LoopAnimation = false; animations["die"].FrameLength = 1f; animations["die"].NextAnimation = "dead"; animations.Add("dead", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Badguys\goomba"), 0, "dead", 0, 1)); currentAnimation = "run"; }
internal static void UpdateTilesheets() { List <string> locations = new List <string>(); foreach (Tilesheet t in Compound.SeasonalTilesheets) { Processors.ApplyTilesheet(t); if (!locations.Contains(t.MapName)) { locations.Add(t.MapName); } } foreach (string map in locations) { xTile.Map location = Game1.getLocationFromName(map).map; location.DisposeTileSheets(Game1.mapDisplayDevice); location.LoadTileSheets(Game1.mapDisplayDevice); } }
public static List <List <int> > VisibleTiles(GameLocation location) { xTile.Map map = location.Map; int mapWidth = map.Layers[0].LayerWidth; int mapHeight = map.Layers[0].LayerWidth; int startX = (Math.Max(Game1.viewport.X, 0) + 63) / 64; int startY = (Math.Max(Game1.viewport.Y, 0) + 63) / 64; int endX = Math.Min(Game1.viewport.MaxCorner.X / 64, mapWidth); int endY = Math.Min(Game1.viewport.MaxCorner.X / 64, mapHeight); var tiles = new List <List <int> >(); for (int x = startX; x < endX; x++) { for (int y = startY; y < endY; y++) { var tile = new List <int> { x, y }; tiles.Add(tile); } } return(tiles); }
internal static void UpdateTilesheets() { Logger.Log("Month changed, updating custom seasonal tilesheets...", LogLevel.Trace); List <string> locations = new List <string>(); foreach (var pair in ModEntry.PatchData.SeasonalTilesheets) { foreach (var tilesheet in pair.Value) { Processors.ApplyTilesheet(ModEntry.SHelper.Content, pair.Key, tilesheet); if (!locations.Contains(tilesheet.MapName)) { locations.Add(tilesheet.MapName); } } } foreach (string map in locations) { xTile.Map location = Game1.getLocationFromName(map).map; location.DisposeTileSheets(Game1.mapDisplayDevice); location.LoadTileSheets(Game1.mapDisplayDevice); } }
internal static string CheckTileInfo(TileInfo info) { if (Game1.getLocationFromName(info.MapName) == null && !AffectedLocations.Contains(info.MapName)) { return(info.Optional ? "OPTIONAL" : "location does not exist"); } Point size; if (!AffectedLocations.Contains(info.MapName)) { xTile.Map map = Game1.getLocationFromName(info.MapName).map; size = new Point(map.DisplayWidth, map.DisplayHeight); AffectedLocations.Add(info.MapName); MapSizes.Add(info.MapName, size); } else { size = MapSizes[info.MapName]; } int minX = 0; int minY = 0; int maxX = size.X; int maxY = size.Y; if (info is Warp) { minX--; minY--; maxX++; maxY++; } if (info.TileX < minX || info.TileY < minY || info.TileX > maxX || info.TileY > maxY) { return("placement is outside location bounds"); } return(null); }
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedActiveMenu_DrawNPCLocationsOnMap(object sender, RenderedActiveMenuEventArgs e) { if (Game1.activeClickableMenu is GameMenu gameMenu) { if (gameMenu.currentTab == 3) { List <String> namesToShow = new List <string>(); foreach (var character in _townsfolk) { try { int hashCode = character.Name.GetHashCode(); bool drawCharacter = _options.SafeGet(hashCode.ToString()).SafeParseBool(); if (drawCharacter) { KeyValuePair <int, int> location = new KeyValuePair <int, int>((int)character.Position.X, (int)character.position.Y); String locationName = character.currentLocation?.Name ?? character.DefaultMap; switch (locationName) { case "Town": case "Forest": { int xStart = 0; int yStart = 0; int areaWidth = 0; int areaHeight = 0; switch (locationName) { case "Town": { xStart = 595; yStart = 163; areaWidth = 345; areaHeight = 330; break; } case "Forest": { xStart = 183; yStart = 378; areaWidth = 319; areaHeight = 261; break; } } xTile.Map map = character.currentLocation.Map; float xScale = (float)areaWidth / (float)map.DisplayWidth; float yScale = (float)areaHeight / (float)map.DisplayHeight; float scaledX = character.position.X * xScale; float scaledY = character.position.Y * yScale; int xPos = (int)scaledX + xStart; int yPos = (int)scaledY + yStart; location = new KeyValuePair <int, int>(xPos, yPos); break; } default: { _mapLocations.TryGetValue(locationName, out location); break; } } //if (character.currentLocation.Name == "Town") //{ // String locationName = character.currentLocation.Name; // xTile.Map map = character.currentLocation.Map; // int xStart = 595; // int yStart = 163; // int townWidth = 345; // int townHeight = 330; // float xScale = (float)townWidth / (float)map.DisplayWidth; // float yScale = (float)townHeight / (float)map.DisplayHeight; // float scaledX = character.position.X * xScale; // float scaledY = character.position.Y * yScale; // int xPos = (int)scaledX + xStart; // int yPos = (int)scaledY + yStart; // location = new KeyValuePair<int, int>(xPos, yPos); //} //else //{ // _mapLocations.TryGetValue(character.currentLocation.name, out location); //} Rectangle headShot = character.GetHeadShot(); int xBase = Game1.activeClickableMenu.xPositionOnScreen - 158; int yBase = Game1.activeClickableMenu.yPositionOnScreen - 40; int x = xBase + location.Key; int y = yBase + location.Value; Color color = character.CurrentDialogue.Count <= 0 ? Color.Gray : Color.White; ClickableTextureComponent textureComponent = new ClickableTextureComponent( character.Name, new Rectangle(x, y, 0, 0), null, character.Name, character.Sprite.Texture, headShot, 2.3f); float headShotScale = 2f; Game1.spriteBatch.Draw( character.Sprite.Texture, new Vector2(x, y), new Rectangle?(headShot), color, 0.0f, Vector2.Zero, headShotScale, SpriteEffects.None, 1f); int mouseX = Game1.getMouseX(); int mouseY = Game1.getMouseY(); if (mouseX >= x && mouseX <= x + headShot.Width * headShotScale && mouseY >= y && mouseY <= y + headShot.Height * headShotScale) { namesToShow.Add(character.displayName); } foreach (var quest in Game1.player.questLog) { if (quest.accepted.Value && quest.dailyQuest.Value && !quest.completed.Value) { bool isQuestTarget = false; switch (quest.questType.Value) { case 3: isQuestTarget = (quest as ItemDeliveryQuest).target.Value == character.Name; break; case 4: isQuestTarget = (quest as SlayMonsterQuest).target.Value == character.Name; break; case 7: isQuestTarget = (quest as FishingQuest).target.Value == character.Name; break; case 10: isQuestTarget = (quest as ResourceCollectionQuest).target.Value == character.Name; break; } if (isQuestTarget) { Game1.spriteBatch.Draw( Game1.mouseCursors, new Vector2(x + 10, y - 12), new Rectangle(394, 495, 4, 10), Color.White, 0.0f, Vector2.Zero, 3f, SpriteEffects.None, 1f); } } } } } catch (Exception ex) { ModEntry.MonitorObject.Log(ex.Message + Environment.NewLine + ex.StackTrace, LogLevel.Error); } } if (namesToShow.Count > 0) { StringBuilder text = new StringBuilder(); int longestLength = 0; foreach (String name in namesToShow) { text.AppendLine(name); longestLength = Math.Max(longestLength, (int)Math.Ceiling(Game1.smallFont.MeasureString(name).Length())); } int windowHeight = Game1.smallFont.LineSpacing * namesToShow.Count + 25; Vector2 windowPos = new Vector2(Game1.getMouseX() + 40, Game1.getMouseY() - windowHeight); IClickableMenu.drawTextureBox( Game1.spriteBatch, (int)windowPos.X, (int)windowPos.Y, longestLength + 30, Game1.smallFont.LineSpacing * namesToShow.Count + 25, Color.White); Game1.spriteBatch.DrawString( Game1.smallFont, text, new Vector2(windowPos.X + 17, windowPos.Y + 17), Game1.textShadowColor); Game1.spriteBatch.DrawString( Game1.smallFont, text, new Vector2(windowPos.X + 15, windowPos.Y + 15), Game1.textColor); } //The cursor needs to show up in front of the character faces Tools.DrawMouseCursor(); String hoverText = (String)typeof(MapPage) .GetField( "hoverText", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(((List <IClickableMenu>) typeof(GameMenu) .GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(gameMenu))[gameMenu.currentTab]); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.smallFont); } } }
public Player( ContentManager content, Vector2 location, Vector2 velocity, xTile.Map map, ParticleManager particleManager) : base(location, velocity, map) { // mario, new Rectangle(0, 0, 48, 48 this.particleManager = particleManager; animations.Add("idle", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\Mario"), 30, "idle", 139, 1)); animations["idle"].LoopAnimation = true; animations.Add("run", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\Mario"), 34, "run", 0, 2)); animations["run"].LoopAnimation = true; animations["run"].FrameLength = 0.08f; animations.Add("jump", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\Mario"), 34, "jump", 102, 1)); float i = animations["jump"].FrameLength; animations["jump"].LoopAnimation = true; animations["jump"].FrameLength = 0.7f; animations["jump"].NextAnimation = "idle"; animations.Add("die", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\Mario"), 34, "die", 171, 1)); animations["die"].LoopAnimation = false; animations.Add("idleBig", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\marioBig"), 32, "idleBig", 128, 1)); animations["idleBig"].LoopAnimation = true; animations.Add("runBig", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\marioBig"), 32, "run", 0, 3)); animations["runBig"].LoopAnimation = true; animations.Add("crouch", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\marioBig"), 32, "run", 160, 1)); animations["crouch"].LoopAnimation = true; animations.Add("jumpBig", new AnimationStrip( content.Load <Texture2D>(@"Sprites\Player\marioBig"), 32, "jumpBig", 96, 1)); float k = animations["jumpBig"].FrameLength; animations["jumpBig"].LoopAnimation = true; animations["jumpBig"].FrameLength = 0.5f; animations["jumpBig"].NextAnimation = "idleBig"; currentAnimation = "idle" + (isBig ? "Big" : ""); }
public Desert(xTile.Map map, string name) : base(map, name) { }
public Sewer(xTile.Map map, string name) : base(map, name) { }
public DecoratableLocation(xTile.Map map, string name) : base(map, name) { }
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); } }
public Greenhouse(xTile.Map map, string name) : base(map, name) { }
/// <summary>Apply content data to the game.</summary> /// <param name="compoundData">Compound data loaded from the content packs.</param> public void ApplyPatches(out Compound compoundData) { // track info var seasonalTilesheetsByContentPack = new Dictionary <IContentPack, Tilesheet[]>(); var customLocationNames = new HashSet <string>(); var mapSizes = new Dictionary <string, Point>(); var mapCache = new Dictionary <string, xTile.Map>(); var tilesheetCache = new Dictionary <string, List <string> >(); var dynamicTiles = new List <Tile>(); var dynamicProperties = new List <Property>(); var dynamicWarps = new List <Warp>(); var conditionals = new List <Conditional>(); var teleporters = new List <TeleporterList>(); var shops = new List <ShopConfig>(); // apply content packs foreach (ContentPackData pack in this.Data) { this.Monitor.Log($"Applying {pack.ContentPack.Manifest.Name}...", LogLevel.Debug); string stage = "entry"; try { // apply locations stage = "locations"; foreach (Location obj in pack.Locations) { if (Game1.getLocationFromName(obj.MapName) != null) { this.Monitor.Log($" Can't add location {obj.MapName}, it already exists.", LogLevel.Warn); continue; } try { // cache info xTile.Map map = pack.ContentPack.LoadAsset <xTile.Map>(obj.FileName); mapSizes.Add(obj.MapName, new Point(map.DisplayWidth, map.DisplayHeight)); mapCache.Add(obj.MapName, map); customLocationNames.Add(obj.MapName); Processors.ApplyLocation(pack.ContentPack, obj); } catch (Exception err) { this.Monitor.Log($" Can't add location {obj.MapName}, an error occurred.", LogLevel.Error, err); } } // apply overrides stage = "overrides"; foreach (Override obj in pack.Overrides) { if (Game1.getLocationFromName(obj.MapName) == null) { this.Monitor.Log($" Can't override location {obj.MapName}, it doesn't exist.", LogLevel.Error); continue; } try { xTile.Map map = pack.ContentPack.LoadAsset <xTile.Map>(obj.FileName); mapSizes.Add(obj.MapName, new Point(map.DisplayWidth, map.DisplayHeight)); Processors.ApplyOverride(pack.ContentPack, obj); } catch (Exception err) { this.Monitor.Log($" Can't override location {obj.MapName}, an error occurred.", LogLevel.Error, err); } } // apply redirects stage = "redirects"; { HashSet <string> redirCache = new HashSet <string>(); foreach (Redirect obj in pack.Redirects) { if (!redirCache.Contains(obj.ToFile)) { string toAssetPath = pack.ContentPack.GetRelativePath(fromAbsolutePath: ModEntry.SHelper.DirectoryPath, toLocalPath: obj.ToFile); this.CoreContentHelper.RegisterXnbReplacement(obj.FromFile, toAssetPath); redirCache.Add(obj.ToFile); } } } // apply tilesheets stage = "tilesheets"; IList <Tilesheet> seasonalTilesheets = new List <Tilesheet>(); foreach (Tilesheet obj in pack.Tilesheets) { if (Game1.getLocationFromName(obj.MapName) == null && !customLocationNames.Contains(obj.MapName)) { this.Monitor.Log($" Can't apply tilesheet '{obj.SheetId}', location '{obj.MapName}' doesn't exist.", LogLevel.Error); continue; } Processors.ApplyTilesheet(this.CoreContentHelper, pack.ContentPack, obj); if (obj.Seasonal) { seasonalTilesheets.Add(obj); } } if (seasonalTilesheets.Any()) { seasonalTilesheetsByContentPack[pack.ContentPack] = seasonalTilesheets.ToArray(); } // apply tiles stage = "tiles"; foreach (Tile obj in pack.Tiles) { if (!this.PreprocessTile(obj, customLocationNames, mapSizes, out string error)) { if (error != null) { this.Monitor.Log($" Can't apply tile {obj}: {error}", LogLevel.Error); } } 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 && (!tilesheetCache.ContainsKey(map.Id) || !tilesheetCache[map.Id].Contains(obj.SheetId))) { this.Monitor.Log($" Can't apply tile {obj}, tilesheet doesn't exist.", LogLevel.Error); continue; } } Processors.ApplyTile(obj); if (!string.IsNullOrEmpty(obj.Conditions)) { dynamicTiles.Add(obj); } } // apply properties stage = "properties"; foreach (Property obj in pack.Properties) { if (!this.PreprocessTile(obj, customLocationNames, mapSizes, out string error)) { if (error != null) { this.Monitor.Log($" Can't apply property patch {obj}: {error}.", LogLevel.Error); } continue; } Processors.ApplyProperty(obj); if (!string.IsNullOrEmpty(obj.Conditions)) { dynamicProperties.Add(obj); } } // apply warps stage = "warps"; foreach (Warp obj in pack.Warps) { if (!this.PreprocessTile(obj, customLocationNames, mapSizes, out string error)) { if (error != null) { this.Monitor.Log($" Can't apply warp {obj}: {error}.", LogLevel.Error); } continue; } Processors.ApplyWarp(obj); if (!string.IsNullOrEmpty(obj.Conditions)) { dynamicWarps.Add(obj); } } // save conditionals stage = "conditionals"; foreach (Conditional obj in pack.Conditionals) { conditionals.Add(obj); } // save teleporters stage = "teleporters"; foreach (TeleporterList obj in pack.Teleporters) { teleporters.Add(obj); } // save shops stage = "shops"; foreach (ShopConfig obj in pack.Shops) { shops.Add(obj); } } catch (Exception ex) { this.Monitor.ExitGameImmediately($"Failed applying changes from the {pack.ContentPack.Manifest.Name} content pack ({stage} step).", ex); } } // postprocess try { NPC.populateRoutesFromLocationToLocationList(); VerifyGameIntegrity(); this.Monitor.Log("Patches applied!", LogLevel.Debug); } catch (Exception ex) { this.Monitor.ExitGameImmediately("Failed post-processing after content pack changes.", ex); } // create compound info compoundData = new Compound(seasonalTilesheetsByContentPack, dynamicTiles, dynamicProperties, dynamicWarps, conditionals, teleporters, shops); }
public ParticleManager(xTile.Map map) { this.map = map; particleList = new Dictionary <string, AnimationStrip>(); }
public CustomDecoratableLocation(xTile.Map m, string name) : base(m, name) { }