Skip to content
Open
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
1 change: 1 addition & 0 deletions Installer/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Tomb Editor:
* Added Flyby Timeline control to edit and preview flyby sequences.
* Added "Preview flyby sequence" and "Preview camera" context menus for cameras.
* Added On Pickup, On Vehicle Enter and On Vehicle Exit global events in the global event set editor.
* Added support for mine cart floor data in TRX.

WadTool:
* Added missing TR2 henchman death sound (ID 838) and appropriate TR2 -> TEN conversion.
Expand Down
8 changes: 4 additions & 4 deletions TombEditor/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2076,20 +2076,20 @@ static CommandHandler()
EditorActions.SetDiagonalWall(args.Editor.SelectedRoom, args.Editor.SelectedSectors.Area);
});

AddCommand("SetBeetleCheckpoint", "Set beetle checkpoint / minecart right (TR3)", CommandType.Sectors, delegate (CommandArgs args)
AddCommand("SetBeetleCheckpoint", "Set beetle checkpoint / minecart right (TR3/TRX)", CommandType.Sectors, delegate (CommandArgs args)
{
if (!EditorActions.CheckForRoomAndSectorSelection(args.Window))
return;
if (!EditorActions.VersionCheck(args.Editor.Level.Settings.GameVersion.Native() >= TRVersion.Game.TR3, "This flag"))
if (!EditorActions.VersionCheck(args.Editor.Level.Settings.GameVersion >= TRVersion.Game.TR3, "This flag"))
return;
EditorActions.ToggleSectorFlag(args.Editor.SelectedRoom, args.Editor.SelectedSectors.Area, SectorFlags.Beetle);
});

AddCommand("SetTriggerTriggerer", "Set trigger triggerer / minecart left (TR3)", CommandType.Sectors, delegate (CommandArgs args)
AddCommand("SetTriggerTriggerer", "Set trigger triggerer / minecart left (TR3/TRX)", CommandType.Sectors, delegate (CommandArgs args)
{
if (!EditorActions.CheckForRoomAndSectorSelection(args.Window))
return;
if (!EditorActions.VersionCheck(args.Editor.Level.Settings.GameVersion.Native() >= TRVersion.Game.TR3, "This flag"))
if (!EditorActions.VersionCheck(args.Editor.Level.Settings.GameVersion >= TRVersion.Game.TR3, "This flag"))
return;
EditorActions.ToggleSectorFlag(args.Editor.SelectedRoom, args.Editor.SelectedSectors.Area, SectorFlags.TriggerTriggerer);
});
Expand Down
6 changes: 3 additions & 3 deletions TombEditor/ToolWindows/SectorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ obj is Editor.GameVersionChangedEvent ||
obj is Editor.LevelChangedEvent)
{
bool climbingSupported = _editor.Level.Settings.GameVersion.SupportsClimbing();
bool isTR345 = _editor.Level.Settings.GameVersion.Native() >= TRVersion.Game.TR3;
bool beetleTrigMineSupported = _editor.Level.Settings.GameVersion >= TRVersion.Game.TR3;

butClimbNegativeX.Enabled = climbingSupported;
butClimbNegativeZ.Enabled = climbingSupported;
butClimbPositiveX.Enabled = climbingSupported;
butClimbPositiveZ.Enabled = climbingSupported;
butMonkey.Enabled = _editor.Level.Settings.GameVersion.SupportsMonkeySwing();
butFlagBeetle.Enabled = isTR345;
butFlagTriggerTriggerer.Enabled = isTR345;
butFlagBeetle.Enabled = beetleTrigMineSupported;
butFlagTriggerTriggerer.Enabled = beetleTrigMineSupported;

if (_editor.Level.Settings.GameVersion.Native() >= TRVersion.Game.TR4)
{
Expand Down
31 changes: 31 additions & 0 deletions TombLib/TombLib/LevelData/Compilers/Trx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ private IEnumerable<TrxSectorEdit> GenerateTrxSectorEdits()
{
yield return climbEdit;
}
if (GetMineCartEntry(teRoom, x, z) is TrxSectorEdit mineCartEdit)
{
yield return mineCartEdit;
}
if (GetTriangulation(teRoom, x, z) is TrxSectorEdit triangulationEdit)
{
yield return triangulationEdit;
Expand Down Expand Up @@ -118,6 +122,33 @@ private TrxClimbEntry GetClimbEntry(Room teRoom, ushort x, ushort z)
};
}

private TrxMineCartEntry GetMineCartEntry(Room teRoom, ushort x, ushort z)
{
var teSector = teRoom.Sectors[x, z];
var left = (teSector.Flags & SectorFlags.TriggerTriggerer) != 0;
var right = (teSector.Flags & SectorFlags.Beetle) != 0;

var type = (left, right) switch
{
(true, true) => TrxMineCartType.Stop,
(true, false) => TrxMineCartType.Left,
(false, true) => TrxMineCartType.Right,
_ => TrxMineCartType.None,
};
if (type == TrxMineCartType.None)
{
return null;
}

return new()
{
RoomIndex = (short)_roomRemapping[teRoom],
X = x,
Z = z,
Type = type,
};
}

private TrxTriangulationEntry GetTriangulation(Room teRoom, ushort x, ushort z)
{
var teSector = teRoom.Sectors[x, z];
Expand Down
20 changes: 20 additions & 0 deletions TombLib/TombLib/LevelData/Compilers/Util/TrxInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ protected override void SerializeImpl(BinaryWriterEx writer)
}
}

public enum TrxMineCartType
{
None,
Left,
Right,
Stop,
}

public class TrxMineCartEntry : TrxSectorEdit
{
public override int Command => 14;

public TrxMineCartType Type { get; set; }

protected override void SerializeImpl(BinaryWriterEx writer)
{
writer.Write((int)Type);
}
}

public class TrxTriangulationEntry : TrxSectorEdit
{
public override int Command => 13;
Expand Down