Skip to content

Commit 17079a9

Browse files
committed
Handle eel positions in Golden Mask
Assigns relocation points for eels in Golden Mask if player chooses to move awkward enemies. Also removes duplicated locations between black and yellow moray eels, and instead assigns dynamically at runtime.
1 parent 1f6752a commit 17079a9

3 files changed

Lines changed: 1606 additions & 3216 deletions

File tree

TRRandomizerCore/Randomizers/Shared/EnemyAllocator.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Newtonsoft.Json;
2-
using TRLevelControl.Model;
1+
using TRLevelControl.Model;
32
using TRRandomizerCore.Editors;
43
using TRRandomizerCore.Helpers;
54
using TRRandomizerCore.Utilities;
@@ -22,10 +21,13 @@ public EnemyAllocator(TRGameVersion version)
2221
{
2322
string relocFile = $"Resources/{version}/Locations/enemy_relocations.json";
2423
_relocations = File.Exists(relocFile)
25-
? JsonConvert.DeserializeObject<Dictionary<string, List<Location>>>(File.ReadAllText(relocFile))
26-
: new();
24+
? JsonUtils.ReadFile<Dictionary<string, List<Location>>>(relocFile)
25+
: [];
26+
RelocationsLoaded();
2727
}
2828

29+
protected virtual void RelocationsLoaded() { }
30+
2931
public void Initialise()
3032
{
3133
_resultantEnemies = new();

TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ protected override Dictionary<TR2Type, List<int>> GetRestrictedRooms(string leve
5656
protected override bool IsOneShotType(TR2Type type)
5757
=> type == TR2Type.MarcoBartoli;
5858

59+
protected override void RelocationsLoaded()
60+
{
61+
foreach (var locations in _relocations.Values)
62+
{
63+
var blackLocations = locations.FindAll(l => l.TargetType == (short)TR2Type.BlackMorayEel);
64+
foreach (var blackEel in blackLocations)
65+
{
66+
var hasYellowEel = locations.Any(l => l.IsEquivalent(blackEel)
67+
&& l.EntityIndex == blackEel.EntityIndex
68+
&& l.TargetType == (short)TR2Type.YellowMorayEel);
69+
if (!hasYellowEel)
70+
{
71+
var yellowEel = blackEel.Clone();
72+
yellowEel.TargetType = (short)TR2Type.YellowMorayEel;
73+
locations.Add(yellowEel);
74+
}
75+
}
76+
}
77+
}
78+
5979
public EnemyTransportCollection<TR2Type> SelectCrossLevelEnemies(string levelName, TR2Level level)
6080
{
6181
if (levelName == TR2LevelNames.ASSAULT)

0 commit comments

Comments
 (0)