Skip to content

Commit

Permalink
Merge pull request #396 from Towandaa/TestSprite
Browse files Browse the repository at this point in the history
TR2 #395
  • Loading branch information
DanzaG authored Nov 11, 2022
2 parents d3fa760 + 23b2b3d commit 4f57d31
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
13 changes: 12 additions & 1 deletion TRRandomizerCore/Editors/TR2RandoEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ protected override void StoreConfig(Config config)

protected override int GetSaveTarget(int numLevels)
{
return base.GetSaveTarget(numLevels) + Settings.GetSaveTarget(numLevels);
int target = base.GetSaveTarget(numLevels) + Settings.GetSaveTarget(numLevels);
if (Settings.RandomizeItems && Settings.RandomizeItemSprites)
{
target += numLevels;
}
return target;
}

protected override void SaveImpl(AbstractTRScriptEditor scriptEditor, TRSaveMonitor monitor)
Expand Down Expand Up @@ -252,6 +257,12 @@ protected override void SaveImpl(AbstractTRScriptEditor scriptEditor, TRSaveMoni
}.Randomize(Settings.NightModeSeed);
}
}

if (!monitor.IsCancelled && Settings.RandomizeItems && Settings.RandomizeItemSprites)
{
monitor.FireSaveStateBeginning(TRSaveCategory.Custom, "Randomizing Sprites");
itemRandomizer.RandomizeLevelsSprites();
}
}
}
}
Expand Down
25 changes: 23 additions & 2 deletions TRRandomizerCore/Randomizers/TR2/TR2ItemRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public override void Randomize(int seed)

RandomizeSeraph();

if (Settings.RandomizeItemSprites)
RandomizeSprites();
// if (Settings.RandomizeItemSprites)
// RandomizeSprites();

//Write back the level file
SaveLevelInstance();
Expand All @@ -74,6 +74,27 @@ public override void Randomize(int seed)
}
}

public void RandomizeLevelsSprites()
{

foreach (TR2ScriptedLevel lvl in Levels)
{
//Read the level into a combined data/script level object
LoadLevelInstance(lvl);

RandomizeSprites();

//Write back the level file
SaveLevelInstance();

if (!TriggerProgress())
{
break;
}
}

}


private void RandomizeSprites()
{
Expand Down

0 comments on commit 4f57d31

Please sign in to comment.