Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.Xna.Framework;
- using StardewModdingAPI;
- using StardewModdingAPI.Events;
- using StardewModdingAPI.Utilities;
- using StardewValley;
- using xTile;
- using xTile.Tiles;
- namespace FernIslands
- {
- /// <summary>The mod entry point.</summary>
- public class ModEntry : Mod
- {
- private void AfterSaveLoaded(object sender, EventArgs args)
- {
- // load a map.tbin file from your mod's folder.
- Map map = this.Helper.Content.Load<Map>("FernIslands.tbin", ContentSource.ModFolder);
- // create a map asset key
- string mapAssetKey = this.Helper.Content.GetActualAssetKey("FernIslands.xnb", ContentSource.ModFolder);
- // add the new location
- GameLocation location = new GameLocation(mapAssetKey, "FernIslands") { IsOutdoors = false, IsFarm = false };
- Game1.locations.Add(location);
- }
- public void Entry(IModHelper helper)
- {
- SaveEvents.AfterLoad += AfterSaveLoaded;
- // This gets the asset key for a tilesheet.png file from your mod's folder. You can also load a game tilesheet like
- // this: helper.Content.GetActualAssetKey("spring_town", ContentSource.GameContent).
- string tilesheetPath = helper.Content.GetActualAssetKey("fern_beach.png", ContentSource.ModFolder);
- // Get an instance of the in-game location you want to patch. For the farm, use Game1.getFarm() instead.
- GameLocation location = Game1.getLocationFromName("Town");
- // Add the tilesheet.
- TileSheet tilesheet = new TileSheet(
- id: "z_fern_beach", // a unique ID for the tilesheet
- map: location.map,
- imageSource: tilesheetPath,
- sheetSize: new xTile.Dimensions.Size(272, 62), // the pixel size of your tilesheet image.
- tileSize: new xTile.Dimensions.Size(16, 16) // should always be 16x16 for maps
- );
- location.map.AddTileSheet(tilesheet);
- location.map.LoadTileSheets(Game1.mapDisplayDevice);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement