Advertisement
Guest User

FernIslands

a guest
Jun 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. using System;
  2. using Microsoft.Xna.Framework;
  3. using StardewModdingAPI;
  4. using StardewModdingAPI.Events;
  5. using StardewModdingAPI.Utilities;
  6. using StardewValley;
  7. using xTile;
  8. using xTile.Tiles;
  9.  
  10. namespace FernIslands
  11. {
  12. /// <summary>The mod entry point.</summary>
  13. public class ModEntry : Mod
  14. {
  15. private void AfterSaveLoaded(object sender, EventArgs args)
  16. {
  17. // load a map.tbin file from your mod's folder.
  18. Map map = this.Helper.Content.Load<Map>("FernIslands.tbin", ContentSource.ModFolder);
  19.  
  20. // create a map asset key
  21. string mapAssetKey = this.Helper.Content.GetActualAssetKey("FernIslands.xnb", ContentSource.ModFolder);
  22.  
  23. // add the new location
  24. GameLocation location = new GameLocation(mapAssetKey, "FernIslands") { IsOutdoors = false, IsFarm = false };
  25. Game1.locations.Add(location);
  26. }
  27.  
  28. public void Entry(IModHelper helper)
  29. {
  30. SaveEvents.AfterLoad += AfterSaveLoaded;
  31.  
  32. // This gets the asset key for a tilesheet.png file from your mod's folder. You can also load a game tilesheet like
  33. // this: helper.Content.GetActualAssetKey("spring_town", ContentSource.GameContent).
  34. string tilesheetPath = helper.Content.GetActualAssetKey("fern_beach.png", ContentSource.ModFolder);
  35.  
  36. // Get an instance of the in-game location you want to patch. For the farm, use Game1.getFarm() instead.
  37. GameLocation location = Game1.getLocationFromName("Town");
  38.  
  39. // Add the tilesheet.
  40. TileSheet tilesheet = new TileSheet(
  41. id: "z_fern_beach", // a unique ID for the tilesheet
  42. map: location.map,
  43. imageSource: tilesheetPath,
  44. sheetSize: new xTile.Dimensions.Size(272, 62), // the pixel size of your tilesheet image.
  45. tileSize: new xTile.Dimensions.Size(16, 16) // should always be 16x16 for maps
  46. );
  47. location.map.AddTileSheet(tilesheet);
  48. location.map.LoadTileSheets(Game1.mapDisplayDevice);
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement