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.
Resolves LostArtefacts#470.
- Loading branch information
Showing
22 changed files
with
463 additions
and
26 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,76 @@ | ||
using TRLevelControl.Model; | ||
|
||
namespace TRLevelControl.Build; | ||
|
||
public class TRDemoBuilder<G, I> | ||
where G : Enum | ||
where I : Enum | ||
{ | ||
private readonly TRGameVersion _version; | ||
|
||
public TRDemoBuilder(TRGameVersion version) | ||
{ | ||
_version = version; | ||
} | ||
|
||
public TRDemoData<G, I> Read(TRLevelReader reader) | ||
{ | ||
ushort numDemoData = reader.ReadUInt16(); | ||
if (numDemoData == 0) | ||
{ | ||
return null; | ||
} | ||
|
||
TRDemoData<G, I> demoData = new() | ||
{ | ||
LaraPos = reader.ReadVertex32(), | ||
LaraRot = reader.ReadVertex32(), | ||
LaraRoom = reader.ReadInt32(), | ||
}; | ||
|
||
if (_version > TRGameVersion.TR1) | ||
{ | ||
demoData.LaraLastGun = (G)(object)reader.ReadInt32(); | ||
} | ||
|
||
int inputData; | ||
while ((inputData = reader.ReadInt32()) != -1) | ||
{ | ||
demoData.Inputs.Add((I)(object)inputData); | ||
} | ||
|
||
return demoData; | ||
} | ||
|
||
public void Write(TRDemoData<G, I> demoData, TRLevelWriter writer) | ||
{ | ||
if (demoData == null) | ||
{ | ||
writer.Write((ushort)0); | ||
return; | ||
} | ||
|
||
byte[] data; | ||
{ | ||
using MemoryStream ms = new(); | ||
using TRLevelWriter demoWriter = new(ms); | ||
|
||
demoWriter.Write(demoData.LaraPos); | ||
demoWriter.Write(demoData.LaraRot); | ||
demoWriter.Write(demoData.LaraRoom); | ||
|
||
if (_version > TRGameVersion.TR1) | ||
{ | ||
demoWriter.Write((int)(object)demoData.LaraLastGun); | ||
} | ||
|
||
demoWriter.Write(demoData.Inputs.Select(i => (int)(object)i)); | ||
demoWriter.Write(-1); | ||
|
||
data = ms.ToArray(); | ||
} | ||
|
||
writer.Write((ushort)data.Length); | ||
writer.Write(data); | ||
} | ||
} |
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
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,12 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
public class TRDemoData<G, I> | ||
where G : Enum | ||
where I : Enum | ||
{ | ||
public TRVertex32 LaraPos { get; set; } | ||
public TRVertex32 LaraRot { get; set; } | ||
public int LaraRoom { get; set; } | ||
public G LaraLastGun { get; set; } | ||
public List<I> Inputs { get; set; } = new(); | ||
} |
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,6 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
public enum TR1DemoGun | ||
{ | ||
None = 0, | ||
} |
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,24 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
[Flags] | ||
public enum TR1InputState | ||
{ | ||
None = 0, | ||
Forward = 1 << 0, | ||
Back = 1 << 1, | ||
Left = 1 << 2, | ||
Right = 1 << 3, | ||
Jump = 1 << 4, | ||
Draw = 1 << 5, | ||
Action = 1 << 6, | ||
Walk = 1 << 7, | ||
Option = 1 << 8, | ||
Look = 1 << 9, | ||
StepLeft = 1 << 10, | ||
StepRight = 1 << 11, | ||
Roll = 1 << 12, | ||
MenuConfirm = 1 << 20, | ||
MenuBack = 1 << 21, | ||
Save = 1 << 22, | ||
Load = 1 << 23, | ||
} |
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,13 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
public enum TR2DemoGun | ||
{ | ||
None = 0, | ||
Pistols = 1, | ||
Autos = 2, | ||
Uzis = 3, | ||
Shotgun = 4, | ||
M16 = 5, | ||
GrenadeLauncher = 6, | ||
Harpoon = 7, | ||
} |
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,25 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
[Flags] | ||
public enum TR2InputState | ||
{ | ||
None = 0, | ||
Forward = 1 << 0, | ||
Back = 1 << 1, | ||
Left = 1 << 2, | ||
Right = 1 << 3, | ||
Jump = 1 << 4, | ||
Draw = 1 << 5, | ||
Action = 1 << 6, | ||
Walk = 1 << 7, | ||
Option = 1 << 8, | ||
Look = 1 << 9, | ||
StepLeft = 1 << 10, | ||
StepRight = 1 << 11, | ||
Roll = 1 << 12, | ||
Flare = 1 << 19, | ||
MenuConfirm = 1 << 20, | ||
MenuBack = 1 << 21, | ||
Save = 1 << 22, | ||
Load = 1 << 23, | ||
} |
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,14 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
public enum TR3DemoGun | ||
{ | ||
None = 0, | ||
Pistols = 1, | ||
DEagle = 2, | ||
Uzis = 3, | ||
Shotgun = 4, | ||
MP5 = 5, | ||
RocketLauncher = 6, | ||
GrenadeLauncher = 7, | ||
Harpoon = 8, | ||
} |
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,27 @@ | ||
namespace TRLevelControl.Model; | ||
|
||
[Flags] | ||
public enum TR3InputState | ||
{ | ||
None = 0, | ||
Forward = 1 << 0, | ||
Back = 1 << 1, | ||
Left = 1 << 2, | ||
Right = 1 << 3, | ||
Jump = 1 << 4, | ||
Draw = 1 << 5, | ||
Action = 1 << 6, | ||
Walk = 1 << 7, | ||
Option = 1 << 8, | ||
Look = 1 << 9, | ||
StepLeft = 1 << 10, | ||
StepRight = 1 << 11, | ||
Roll = 1 << 12, | ||
Flare = 1 << 19, | ||
MenuConfirm = 1 << 20, | ||
MenuBack = 1 << 21, | ||
Save = 1 << 22, | ||
Load = 1 << 23, | ||
Duck = 1 << 30, | ||
Sprint = 1 << 31, | ||
} |
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.