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.
LostArtefacts#304 Cross-game Preparations
Some preparations for cross-game level support. - Zones/ZoneGroups implemented for TR1 as per TR2&3. Unit test added for adding to zones. - Ability to set the number of sounds in TRSoundDetails. - Ability to find tile segments from texture indices in texture packer. - Ability to add faces to meshes in MeshEditor. - Several general models made available for import (bridges, keys, some traps etc). - Fixes some texture deduplication issues in GW.
- Loading branch information
Showing
70 changed files
with
352 additions
and
41 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,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using TRLevelReader.Model; | ||
using TRLevelReader.Model.Base.Enums; | ||
|
||
namespace TRLevelReader.Helpers | ||
{ | ||
public static class TR1BoxUtilities | ||
{ | ||
public static void DuplicateZone(TRLevel level, int boxIndex) | ||
{ | ||
TRZoneGroup zoneGroup = level.Zones[boxIndex]; | ||
List<TRZoneGroup> zones = level.Zones.ToList(); | ||
zones.Add(new TRZoneGroup | ||
{ | ||
NormalZone = zoneGroup.NormalZone.Clone(), | ||
AlternateZone = zoneGroup.AlternateZone.Clone() | ||
}); | ||
level.Zones = zones.ToArray(); | ||
} | ||
|
||
public static TRZoneGroup[] ReadZones(uint numBoxes, ushort[] zoneData) | ||
{ | ||
// Initialise the zone groups - one for every box. | ||
TRZoneGroup[] zones = new TRZoneGroup[numBoxes]; | ||
for (int i = 0; i < zones.Length; i++) | ||
{ | ||
zones[i] = new TRZoneGroup | ||
{ | ||
NormalZone = new TRZone(), | ||
AlternateZone = new TRZone() | ||
}; | ||
} | ||
|
||
// Build the zones, mapping the multidimensional ushort structures into the corresponding | ||
// zone object values. | ||
IEnumerable<FlipStatus> flipValues = Enum.GetValues(typeof(FlipStatus)).Cast<FlipStatus>(); | ||
IEnumerable<TRZones> zoneValues = Enum.GetValues(typeof(TRZones)).Cast<TRZones>(); | ||
|
||
int valueIndex = 0; | ||
foreach (FlipStatus flip in flipValues) | ||
{ | ||
foreach (TRZones zone in zoneValues) | ||
{ | ||
for (int box = 0; box < zones.Length; box++) | ||
{ | ||
zones[box][flip].GroundZones[zone] = zoneData[valueIndex++]; | ||
} | ||
} | ||
|
||
for (int box = 0; box < zones.Length; box++) | ||
{ | ||
zones[box][flip].FlyZone = zoneData[valueIndex++]; | ||
} | ||
} | ||
|
||
return zones; | ||
} | ||
|
||
public static ushort[] FlattenZones(TRZoneGroup[] zoneGroups) | ||
{ | ||
// Convert the zone objects back into a flat ushort list. | ||
IEnumerable<FlipStatus> flipValues = Enum.GetValues(typeof(FlipStatus)).Cast<FlipStatus>(); | ||
IEnumerable<TRZones> zoneValues = Enum.GetValues(typeof(TRZones)).Cast<TRZones>(); | ||
|
||
List<ushort> zones = new List<ushort>(); | ||
|
||
foreach (FlipStatus flip in flipValues) | ||
{ | ||
foreach (TRZones zone in zoneValues) | ||
{ | ||
for (int box = 0; box < zoneGroups.Length; box++) | ||
{ | ||
zones.Add(zoneGroups[box][flip].GroundZones[zone]); | ||
} | ||
} | ||
|
||
for (int box = 0; box < zoneGroups.Length; box++) | ||
{ | ||
zones.Add(zoneGroups[box][flip].FlyZone); | ||
} | ||
} | ||
|
||
return zones.ToArray(); | ||
} | ||
} | ||
} |
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 TRLevelReader.Model.Base.Enums | ||
{ | ||
public enum TRZones | ||
{ | ||
Zone1 = 0, | ||
Zone2 = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using TRLevelReader.Model.Base.Enums; | ||
|
||
namespace TRLevelReader.Model | ||
{ | ||
public class TRZoneGroup : Dictionary<FlipStatus, TRZone> | ||
{ | ||
/// <summary> | ||
/// Zone values when flipmap is off. | ||
/// </summary> | ||
public TRZone NormalZone | ||
{ | ||
get => this[FlipStatus.Off]; | ||
set => this[FlipStatus.Off] = value; | ||
} | ||
/// <summary> | ||
/// Zone values when flipmap is on. | ||
/// </summary> | ||
public TRZone AlternateZone | ||
{ | ||
get => this[FlipStatus.On]; | ||
set => this[FlipStatus.On] = value; | ||
} | ||
} | ||
} |
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.