Changes

Jump to navigation Jump to search
→‎Edit a game asset: + map patch helper
Line 315: Line 315:  
| <tt>minHeight</tt>
 
| <tt>minHeight</tt>
 
| The minimum desired height. If the image height is less than this value, it'll be extended from the bottom up to that size.
 
| The minimum desired height. If the image height is less than this value, it'll be extended from the bottom up to that size.
 +
|}
 +
 +
===Edit a map===
 +
{{SMAPI upcoming|3.5}}
 +
 +
When editing a map file, you can get a helper using <tt>asset.AsMap()</tt>.
 +
 +
; Data
 +
: A reference to the loaded map. You can directly edit the map or tiles through this field.
 +
 +
; PatchMap
 +
: Edit or replace part of the map. This is basically a copy & paste operation, so the source map is applied over the loaded map. For example:
 +
: <source lang="C#">
 +
public void Edit<T>(IAssetData asset)
 +
{
 +
  var editor = asset.AsMap();
 +
 
 +
  Map sourceMap = this.Helper.Content.Load<Map>("custom-map.tmx", ContentSource.ModFolder);
 +
  editor.PatchMap(sourceMap, targetArea: new Rectangle(30, 10, 20, 20));
 +
}
 +
</source>
 +
 +
: Available method arguments:
 +
: {| class="wikitable"
 +
|-
 +
! argument
 +
! usage
 +
|-
 +
| <tt>source</tt>
 +
| The source map to copy & paste onto the loaded map.
 +
|-
 +
| <tt>sourceArea</tt>
 +
| ''(optional)'' The tile area within the source map to copy (or omit to use the entire source map). This must fit within the target map.
 +
|-
 +
| <tt>targetArea</tt>
 +
| ''(optional)'' The tile area within the loaded map to replace (or omit to replace starting from the top-left corner up to the full source size).
 
|}
 
|}
  
translators
8,441

edits

Navigation menu