-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reward rooms created and reward items earmarked. Locations marked for each TRUB level. Added a method of pinpointing entity indices from environment mods, which we use to adjust some secrets after they have been placed.
- Loading branch information
Showing
15 changed files
with
2,704 additions
and
5 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
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
68 changes: 68 additions & 0 deletions
68
TREnvironmentEditor/Model/Types/Triggers/EMResetPickupTriggerFunction.cs
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,68 @@ | ||
using TREnvironmentEditor.Helpers; | ||
using TRFDControl; | ||
using TRFDControl.FDEntryTypes; | ||
using TRFDControl.Utilities; | ||
using TRLevelControl.Model; | ||
|
||
namespace TREnvironmentEditor.Model.Types; | ||
|
||
public class EMResetPickupTriggerFunction : BaseEMFunction | ||
{ | ||
public List<EMLocation> Locations { get; set; } | ||
|
||
public override void ApplyToLevel(TR1Level level) | ||
{ | ||
EMLevelData data = GetData(level); | ||
|
||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
ResetPickupTriggers(floorData, l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, data.ConvertRoom(l.Room), level, floorData)); | ||
|
||
floorData.WriteToLevel(level); | ||
} | ||
|
||
public override void ApplyToLevel(TR2Level level) | ||
{ | ||
EMLevelData data = GetData(level); | ||
|
||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
ResetPickupTriggers(floorData, l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, data.ConvertRoom(l.Room), level, floorData)); | ||
|
||
floorData.WriteToLevel(level); | ||
} | ||
|
||
public override void ApplyToLevel(TR3Level level) | ||
{ | ||
EMLevelData data = GetData(level); | ||
|
||
FDControl floorData = new(); | ||
floorData.ParseFromLevel(level); | ||
|
||
ResetPickupTriggers(floorData, l => FDUtilities.GetRoomSector(l.X, l.Y, l.Z, data.ConvertRoom(l.Room), level, floorData)); | ||
|
||
floorData.WriteToLevel(level); | ||
} | ||
|
||
private void ResetPickupTriggers(FDControl floorData, Func<EMLocation, TRRoomSector> sectorFunc) | ||
{ | ||
foreach (EMLocation location in Locations) | ||
{ | ||
TRRoomSector sector = sectorFunc(location); | ||
if (sector.FDIndex == 0) | ||
{ | ||
continue; | ||
} | ||
|
||
FDEntry entry = floorData.Entries[sector.FDIndex].Find(e => e is FDTriggerEntry); | ||
if (entry is FDTriggerEntry trigger | ||
&& trigger.TrigType == FDTrigType.Pickup | ||
&& trigger.TrigActionList.Count > 1) | ||
{ | ||
trigger.TrigActionList.RemoveRange(1, trigger.TrigActionList.Count - 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
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.