summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata/CoreAssetPropagator.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-31 22:12:36 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-31 22:12:36 -0500
commite81e07594ca4863f9feb94c882b59ba7cc00a0ae (patch)
tree366be1cd19d51d92c2560b7faa2379bf80a51a2d /src/SMAPI/Metadata/CoreAssetPropagator.cs
parent423f2352af9d0e9815daf4ba3ba33134f587ce47 (diff)
downloadSMAPI-e81e07594ca4863f9feb94c882b59ba7cc00a0ae.tar.gz
SMAPI-e81e07594ca4863f9feb94c882b59ba7cc00a0ae.tar.bz2
SMAPI-e81e07594ca4863f9feb94c882b59ba7cc00a0ae.zip
extend aggressive memory optimization to a few more common textures (#757)
Diffstat (limited to 'src/SMAPI/Metadata/CoreAssetPropagator.cs')
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index 426fc3f6..e2a28c62 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -178,14 +178,19 @@ namespace StardewModdingAPI.Metadata
** Buildings
****/
case "buildings\\houses": // Farm
- reflection.GetField<Texture2D>(typeof(Farm), nameof(Farm.houseTextures)).SetValue(content.Load<Texture2D>(key));
- return true;
+ {
+ var field = reflection.GetField<Texture2D>(typeof(Farm), nameof(Farm.houseTextures));
+ field.SetValue(
+ this.LoadAndDisposeIfNeeded(field.GetValue(), key)
+ );
+ return true;
+ }
/****
** Content\Characters\Farmer
****/
case "characters\\farmer\\accessories": // Game1.LoadContent
- FarmerRenderer.accessoriesTexture = content.Load<Texture2D>(key);
+ FarmerRenderer.accessoriesTexture = this.LoadAndDisposeIfNeeded(FarmerRenderer.accessoriesTexture, key);
return true;
case "characters\\farmer\\farmer_base": // Farmer
@@ -195,19 +200,19 @@ namespace StardewModdingAPI.Metadata
return this.ReloadPlayerSprites(key);
case "characters\\farmer\\hairstyles": // Game1.LoadContent
- FarmerRenderer.hairStylesTexture = content.Load<Texture2D>(key);
+ FarmerRenderer.hairStylesTexture = this.LoadAndDisposeIfNeeded(FarmerRenderer.hairStylesTexture, key);
return true;
case "characters\\farmer\\hats": // Game1.LoadContent
- FarmerRenderer.hatsTexture = content.Load<Texture2D>(key);
+ FarmerRenderer.hatsTexture = this.LoadAndDisposeIfNeeded(FarmerRenderer.hatsTexture, key);
return true;
case "characters\\farmer\\pants": // Game1.LoadContent
- FarmerRenderer.pantsTexture = content.Load<Texture2D>(key);
+ FarmerRenderer.pantsTexture = this.LoadAndDisposeIfNeeded(FarmerRenderer.pantsTexture, key);
return true;
case "characters\\farmer\\shirts": // Game1.LoadContent
- FarmerRenderer.shirtsTexture = content.Load<Texture2D>(key);
+ FarmerRenderer.shirtsTexture = this.LoadAndDisposeIfNeeded(FarmerRenderer.shirtsTexture, key);
return true;
/****