Skip to content

Commit

Permalink
*Slightly* optimize memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Oct 28, 2023
1 parent 3d68b87 commit 2a8044e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions YAMS-LIB/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath)
{
gmData = UndertaleIO.Read(fs);
}
Console.WriteLine("Read data file.");
var decompileContext = new GlobalDecompileContext(gmData, false);

// Check for 1.5.5 before doing *anything*
Expand Down Expand Up @@ -678,7 +679,7 @@ void AddAllSpritesFromDir(string dirPath)

void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem texture)
{
var texturePage = Image.Load(texture.TexturePage.TextureData.TextureBlob);
using var texturePage = Image.Load(texture.TexturePage.TextureData.TextureBlob);
texturePage.Mutate(im => im.Hue(rotation, new Rectangle(texture.SourceX, texture.SourceY, texture.SourceWidth, texture.SourceHeight)));

using var ms = new MemoryStream();
Expand Down Expand Up @@ -2833,7 +2834,8 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te
""");

// speed booster blocks near a5 activation
foreach (var gameObject in gmData.Rooms.ByName("rm_a5c08").GameObjects.Where(o => o.ObjectDefinition.Name.Content == "oBlockSpeed"))
var a5c08 = gmData.Rooms.ByName("rm_a5c08");
foreach (var gameObject in a5c08.GameObjects.Where(o => o.ObjectDefinition.Name.Content == "oBlockSpeed"))
{
// Y 32 is the top row of speed blocks
if (gameObject.Y == 32)
Expand Down

0 comments on commit 2a8044e

Please sign in to comment.