Changes

→‎Advanced: + patch helper for custom assets
Line 385: Line 385:     
When you add or remove an asset editor/loader, SMAPI will call their <tt>CanEdit</tt> and <tt>CanLoad</tt> methods for all loaded assets and reload matched assets. This is an expensive process when done outside your <tt>Entry</tt> method, so avoid adding editors/loaders unnecessarily.
 
When you add or remove an asset editor/loader, SMAPI will call their <tt>CanEdit</tt> and <tt>CanLoad</tt> methods for all loaded assets and reload matched assets. This is an expensive process when done outside your <tt>Entry</tt> method, so avoid adding editors/loaders unnecessarily.
 +
 +
===Patch helper for custom assets===
 +
{{SMAPI upcoming|3.5|content=
 +
A patch helper provides utility methods for editing a given asset (e.g. to merge maps or resize an image).
 +
 +
You can get a patch helper for arbitrary data. For example, this loads two map files and merges them:
 +
<source lang="c#">
 +
Map farm = this.Helper.Content.Load<Map>("assets/farm.tmx", ContentSource.ModFolder);
 +
Map islands = this.Helper.Content.Load<Map>("assets/islands.tmx", ContentSource.ModFolder);
 +
 +
this.Helper.Content
 +
  .GetPatchHelper(farm)
 +
  .AsMap()
 +
  .PatchMap(source: islands, targetArea: new Rectangle(0, 26, 56, 49));
 +
</source>
 +
 +
See [[#Edit a game asset|''edit a game asset'']] for a description of the available patch helpers.
 +
}}
translators
8,404

edits