Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions TRRandomizerCore/Randomizers/Shared/EnemyAllocator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using TRLevelControl.Model;
using TRLevelControl.Model;
using TRRandomizerCore.Editors;
using TRRandomizerCore.Helpers;
using TRRandomizerCore.Utilities;
Expand All @@ -22,10 +21,13 @@ public EnemyAllocator(TRGameVersion version)
{
string relocFile = $"Resources/{version}/Locations/enemy_relocations.json";
_relocations = File.Exists(relocFile)
? JsonConvert.DeserializeObject<Dictionary<string, List<Location>>>(File.ReadAllText(relocFile))
: new();
? JsonUtils.ReadFile<Dictionary<string, List<Location>>>(relocFile)
: [];
RelocationsLoaded();
}

protected virtual void RelocationsLoaded() { }

public void Initialise()
{
_resultantEnemies = new();
Expand Down
20 changes: 20 additions & 0 deletions TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ protected override Dictionary<TR2Type, List<int>> GetRestrictedRooms(string leve
protected override bool IsOneShotType(TR2Type type)
=> type == TR2Type.MarcoBartoli;

protected override void RelocationsLoaded()
{
foreach (var locations in _relocations.Values)
{
var blackLocations = locations.FindAll(l => l.TargetType == (short)TR2Type.BlackMorayEel);
foreach (var blackEel in blackLocations)
{
var hasYellowEel = locations.Any(l => l.IsEquivalent(blackEel)
&& l.EntityIndex == blackEel.EntityIndex
&& l.TargetType == (short)TR2Type.YellowMorayEel);
if (!hasYellowEel)
{
var yellowEel = blackEel.Clone();
yellowEel.TargetType = (short)TR2Type.YellowMorayEel;
locations.Add(yellowEel);
}
}
}
}

public EnemyTransportCollection<TR2Type> SelectCrossLevelEnemies(string levelName, TR2Level level)
{
if (levelName == TR2LevelNames.ASSAULT)
Expand Down
Loading
Loading