forked from LostArtefacts/TR-Rando
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Unfinished Business (LostArtefacts#580)
See LostArtefacts#580 for details. Resolves LostArtefacts#579.
- Loading branch information
Showing
144 changed files
with
40,673 additions
and
1,115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using TRFDControl; | ||
using TRFDControl.Utilities; | ||
using TRLevelControl.Helpers; | ||
using TRLevelControl.Model; | ||
|
||
namespace TREnvironmentEditor.Helpers; | ||
|
||
public class EMEntityFinder | ||
{ | ||
public EMLocation Location { get; set; } | ||
public EMEntityType Type { get; set; } | ||
public List<short> Types { get; set; } | ||
|
||
public int GetEntity(TR1Level level) | ||
{ | ||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
EMLevelData data = EMLevelData.GetData(level); | ||
|
||
List<TR1Type> types = new(); | ||
if (Type == EMEntityType.Item) | ||
{ | ||
types.AddRange(TR1TypeUtilities.GetStandardPickupTypes()); | ||
} | ||
else if (Type == EMEntityType.KeyItem) | ||
{ | ||
types.AddRange(TR1TypeUtilities.GetKeyItemTypes()); | ||
} | ||
if (Types != null) | ||
{ | ||
types.AddRange(Types.Select(t => (TR1Type)t)); | ||
} | ||
|
||
return GetEntity(level.Entities, types, data, | ||
l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, l.Room, level, floorData)); | ||
} | ||
|
||
public int GetEntity(TR2Level level) | ||
{ | ||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
EMLevelData data = EMLevelData.GetData(level); | ||
|
||
List<TR2Type> types = new(); | ||
if (Type == EMEntityType.Item) | ||
{ | ||
types.AddRange(TR2TypeUtilities.GetStandardPickupTypes()); | ||
} | ||
else if (Type == EMEntityType.KeyItem) | ||
{ | ||
types.AddRange(TR2TypeUtilities.GetKeyItemTypes()); | ||
} | ||
if (Types != null) | ||
{ | ||
types.AddRange(Types.Select(t => (TR2Type)t)); | ||
} | ||
|
||
return GetEntity(level.Entities, types, data, | ||
l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, l.Room, level, floorData)); | ||
} | ||
|
||
public int GetEntity(TR3Level level) | ||
{ | ||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
EMLevelData data = EMLevelData.GetData(level); | ||
|
||
List<TR3Type> types = new(); | ||
if (Type == EMEntityType.Item) | ||
{ | ||
types.AddRange(TR3TypeUtilities.GetStandardPickupTypes()); | ||
} | ||
else if (Type == EMEntityType.KeyItem) | ||
{ | ||
types.AddRange(TR3TypeUtilities.GetKeyItemTypes()); | ||
} | ||
if (Types != null) | ||
{ | ||
types.AddRange(Types.Select(t => (TR3Type)t)); | ||
} | ||
|
||
return GetEntity(level.Entities, types, data, | ||
l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, l.Room, level, floorData)); | ||
} | ||
|
||
public int GetEntity<E, T>(List<E> entities, List<T> types, EMLevelData data, Func<EMLocation, TRRoomSector> sectorFunc) | ||
where E : TREntity<T> | ||
where T : Enum | ||
{ | ||
EMLocation location = new() | ||
{ | ||
X = Location.X, | ||
Y = Location.Y, | ||
Z = Location.Z, | ||
Room = data.ConvertRoom(Location.Room) | ||
}; | ||
|
||
TRRoomSector sector = sectorFunc(location); | ||
for (int i = 0; i < entities.Count; i++) | ||
{ | ||
E entity = entities[i]; | ||
if (types.Contains(entity.TypeID) | ||
&& entity.Room == location.Room | ||
&& sectorFunc(new() { X = entity.X, Y = entity.Y, Z = entity.Z, Room = entity.Room }) == sector) | ||
{ | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace TREnvironmentEditor.Helpers; | ||
|
||
public enum EMEntityType | ||
{ | ||
Any, | ||
Item, | ||
KeyItem, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.