Skip to content

Commit

Permalink
Add TRR enemy support (LostArtefacts#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 authored May 25, 2024
1 parent fb263cc commit 7847af4
Show file tree
Hide file tree
Showing 34 changed files with 3,713 additions and 2,668 deletions.
Binary file modified Deps/TRGE.Coord.dll
Binary file not shown.
Binary file modified Deps/TRGE.Core.dll
Binary file not shown.
19 changes: 19 additions & 0 deletions TRDataControl/Data/Remastered/BaseTRRDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ public abstract class BaseTRRDataCache<TKey, TAlias>

public string PDPFolder { get; set; }

public void Merge(ImportResult<TKey> importResult, TRDictionary<TKey, TRModel> pdpData, Dictionary<TKey, TAlias> mapData)
{
foreach (TKey type in importResult.ImportedTypes)
{
SetData(pdpData, mapData, type, TranslateAlias(type));
}

foreach (TKey type in importResult.RemovedTypes)
{
pdpData.Remove(type);
mapData.Remove(type);
}
}

public void SetData(TRDictionary<TKey, TRModel> pdpData, Dictionary<TKey, TAlias> mapData, TKey sourceType, TKey destinationType = default)
{
if (EqualityComparer<TKey>.Default.Equals(destinationType, default))
Expand All @@ -38,6 +52,10 @@ public void SetPDPData(TRDictionary<TKey, TRModel> pdpData, TKey sourceType, TKe
{
_pdpCache[sourceType] = models[translatedKey];
}
else if (models.ContainsKey(destinationType))
{
_pdpCache[sourceType] = models[destinationType];
}
else
{
throw new KeyNotFoundException($"Could not load cached PDP data for {sourceType}");
Expand All @@ -63,5 +81,6 @@ public void SetMapData(Dictionary<TKey, TAlias> mapData, TKey sourceType, TKey d
protected abstract TRPDPControlBase<TKey> GetPDPControl();
public abstract string GetSourceLevel(TKey key);
public abstract TKey TranslateKey(TKey key);
public abstract TKey TranslateAlias(TKey alias);
public abstract TAlias GetAlias(TKey key);
}
77 changes: 66 additions & 11 deletions TRDataControl/Data/Remastered/TR1RDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@ protected override TRPDPControlBase<TR1Type> GetPDPControl()
=> _control ??= new();

public override TR1Type TranslateKey(TR1Type key)
=> TR1TypeUtilities.TranslateSourceType(key);

public override string GetSourceLevel(TR1Type key)
{
_dataProvider ??= new();
TR1Type translatedType = _dataProvider.TranslateAlias(key);
return _sourceLevels.ContainsKey(translatedType) ? _sourceLevels[translatedType] : null;
return key switch
{
TR1Type.SecretAnkh_M_H => TR1Type.Puzzle4_M_H,
TR1Type.SecretGoldBar_M_H or TR1Type.SecretGoldIdol_M_H => TR1Type.Puzzle1_M_H,
TR1Type.SecretLeadBar_M_H => TR1Type.LeadBar_M_H,
TR1Type.SecretScion_M_H => TR1Type.ScionPiece_M_H,
_ => key,
};
}

public override TR1Type TranslateAlias(TR1Type key)
=> (_dataProvider ??= new()).TranslateAlias(key);

public override string GetSourceLevel(TR1Type key)
=> _sourceLevels.ContainsKey(key) ? _sourceLevels[key] : null;

public override TR1RAlias GetAlias(TR1Type key)
{
_dataProvider ??= new();
TR1Type translatedType = _dataProvider.TranslateAlias(key);
return _mapAliases.ContainsKey(translatedType) ? _mapAliases[translatedType] : default;
}
=> _mapAliases.ContainsKey(key) ? _mapAliases[key] : default;

private static readonly Dictionary<TR1Type, string> _sourceLevels = new()
{
Expand All @@ -36,6 +40,55 @@ public override TR1RAlias GetAlias(TR1Type key)
[TR1Type.SecretGoldIdol_M_H] = TR1LevelNames.VILCABAMBA,
[TR1Type.SecretLeadBar_M_H] = TR1LevelNames.MIDAS,
[TR1Type.SecretScion_M_H] = TR1LevelNames.QUALOPEC,

[TR1Type.Bat] = TR1LevelNames.CAVES,
[TR1Type.Bear] = TR1LevelNames.CAVES,
[TR1Type.Wolf] = TR1LevelNames.CAVES,

[TR1Type.Raptor] = TR1LevelNames.VALLEY,
[TR1Type.TRex] = TR1LevelNames.VALLEY,
[TR1Type.LaraMiscAnim_H_Valley] = TR1LevelNames.VALLEY,

[TR1Type.CrocodileLand] = TR1LevelNames.FOLLY,
[TR1Type.CrocodileWater] = TR1LevelNames.FOLLY,
[TR1Type.Gorilla] = TR1LevelNames.FOLLY,
[TR1Type.Lion] = TR1LevelNames.FOLLY,
[TR1Type.Lioness] = TR1LevelNames.FOLLY,

[TR1Type.RatLand] = TR1LevelNames.CISTERN,
[TR1Type.RatWater] = TR1LevelNames.CISTERN,

[TR1Type.Centaur] = TR1LevelNames.TIHOCAN,
[TR1Type.CentaurStatue] = TR1LevelNames.TIHOCAN,
[TR1Type.Pierre] = TR1LevelNames.TIHOCAN,
[TR1Type.ScionPiece_M_H] = TR1LevelNames.TIHOCAN,
[TR1Type.Key1_M_H] = TR1LevelNames.TIHOCAN,

[TR1Type.Panther] = TR1LevelNames.KHAMOON,
[TR1Type.NonShootingAtlantean_N] = TR1LevelNames.KHAMOON,

[TR1Type.BandagedAtlantean] = TR1LevelNames.OBELISK,
[TR1Type.BandagedFlyer] = TR1LevelNames.OBELISK,
[TR1Type.Missile2_H] = TR1LevelNames.OBELISK,

[TR1Type.Missile3_H] = TR1LevelNames.SANCTUARY,
[TR1Type.MeatyAtlantean] = TR1LevelNames.SANCTUARY,
[TR1Type.MeatyFlyer] = TR1LevelNames.SANCTUARY,
[TR1Type.ShootingAtlantean_N] = TR1LevelNames.SANCTUARY,
[TR1Type.Larson] = TR1LevelNames.SANCTUARY,

[TR1Type.CowboyOG] = TR1LevelNames.MINES,
[TR1Type.CowboyHeadless] = TR1LevelNames.MINES,
[TR1Type.SkateboardKid] = TR1LevelNames.MINES,
[TR1Type.Skateboard] = TR1LevelNames.MINES,
[TR1Type.Kold] = TR1LevelNames.MINES,

[TR1Type.AtlanteanEgg] = TR1LevelNames.ATLANTIS,

[TR1Type.Adam] = TR1LevelNames.PYRAMID,
[TR1Type.AdamEgg] = TR1LevelNames.PYRAMID,
[TR1Type.Natla] = TR1LevelNames.PYRAMID,
[TR1Type.LaraMiscAnim_H_Pyramid] = TR1LevelNames.PYRAMID,
};

private static readonly Dictionary<TR1Type, TR1RAlias> _mapAliases = new()
Expand All @@ -45,5 +98,7 @@ public override TR1RAlias GetAlias(TR1Type key)
[TR1Type.SecretGoldIdol_M_H] = TR1RAlias.PUZZLE_OPTION1_2,
[TR1Type.SecretLeadBar_M_H] = TR1RAlias.LEADBAR_OPTION,
[TR1Type.SecretScion_M_H] = TR1RAlias.SCION_OPTION,

[TR1Type.Natla] = TR1RAlias.NATLA_MUTANT,
};
}
130 changes: 130 additions & 0 deletions TRDataControl/Data/Remastered/TR2RDataCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using TRLevelControl;
using TRLevelControl.Helpers;
using TRLevelControl.Model;

namespace TRDataControl;

public class TR2RDataCache : BaseTRRDataCache<TR2Type, TR2RAlias>
{
private TR2PDPControl _control;
private TR2DataProvider _dataProvider;

protected override TRPDPControlBase<TR2Type> GetPDPControl()
=> _control ??= new();

public override TR2Type TranslateKey(TR2Type key)
=> key;

public override TR2Type TranslateAlias(TR2Type key)
=> (_dataProvider ??= new()).TranslateAlias(key);

public override string GetSourceLevel(TR2Type key)
=> _sourceLevels.ContainsKey(key) ? _sourceLevels[key] : null;

public override TR2RAlias GetAlias(TR2Type key)
=> _mapAliases.ContainsKey(key) ? _mapAliases[key] : default;

private static readonly Dictionary<TR2Type, string> _sourceLevels = new()
{
[TR2Type.Crow] = TR2LevelNames.GW,
[TR2Type.Spider] = TR2LevelNames.GW,
[TR2Type.BengalTiger] = TR2LevelNames.GW,
[TR2Type.TRex] = TR2LevelNames.GW,
[TR2Type.LaraMiscAnim_H_Wall] = TR2LevelNames.GW,

[TR2Type.Doberman] = TR2LevelNames.VENICE,
[TR2Type.MaskedGoon1] = TR2LevelNames.VENICE,
[TR2Type.MaskedGoon2] = TR2LevelNames.VENICE,
[TR2Type.MaskedGoon3] = TR2LevelNames.VENICE,
[TR2Type.Rat] = TR2LevelNames.VENICE,
[TR2Type.StickWieldingGoon1BodyWarmer] = TR2LevelNames.VENICE,

[TR2Type.StickWieldingGoon1WhiteVest] = TR2LevelNames.BARTOLI,

[TR2Type.ShotgunGoon] = TR2LevelNames.OPERA,

[TR2Type.Gunman1OG] = TR2LevelNames.RIG,
[TR2Type.Gunman1TopixtorCAC] = TR2LevelNames.RIG,
[TR2Type.Gunman1TopixtorORC] = TR2LevelNames.RIG,
[TR2Type.Gunman2] = TR2LevelNames.RIG,
[TR2Type.ScubaDiver] = TR2LevelNames.RIG,
[TR2Type.ScubaHarpoonProjectile_H] = TR2LevelNames.RIG,
[TR2Type.StickWieldingGoon1Bandana] = TR2LevelNames.RIG,

[TR2Type.FlamethrowerGoonOG] = TR2LevelNames.DA,
[TR2Type.FlamethrowerGoonTopixtor] = TR2LevelNames.DA,

[TR2Type.BarracudaUnwater] = TR2LevelNames.FATHOMS,
[TR2Type.Shark] = TR2LevelNames.FATHOMS,
[TR2Type.LaraMiscAnim_H_Unwater] = TR2LevelNames.FATHOMS,

[TR2Type.StickWieldingGoon1GreenVest] = TR2LevelNames.DORIA,
[TR2Type.YellowMorayEel] = TR2LevelNames.DORIA,

[TR2Type.BlackMorayEel] = TR2LevelNames.LQ,
[TR2Type.StickWieldingGoon2] = TR2LevelNames.LQ,

[TR2Type.Eagle] = TR2LevelNames.TIBET,
[TR2Type.Mercenary2] = TR2LevelNames.TIBET,
[TR2Type.Mercenary3] = TR2LevelNames.TIBET,
[TR2Type.MercSnowmobDriver] = TR2LevelNames.TIBET,
[TR2Type.BlackSnowmob] = TR2LevelNames.TIBET,
[TR2Type.RedSnowmobile] = TR2LevelNames.TIBET,
[TR2Type.SnowmobileBelt] = TR2LevelNames.TIBET,
[TR2Type.LaraSnowmobAnim_H] = TR2LevelNames.TIBET,
[TR2Type.SnowLeopard] = TR2LevelNames.TIBET,

[TR2Type.Mercenary1] = TR2LevelNames.MONASTERY,
[TR2Type.MonkWithKnifeStick] = TR2LevelNames.MONASTERY,
[TR2Type.MonkWithLongStick] = TR2LevelNames.MONASTERY,

[TR2Type.BarracudaIce] = TR2LevelNames.COT,
[TR2Type.Yeti] = TR2LevelNames.COT,
[TR2Type.LaraMiscAnim_H_Ice] = TR2LevelNames.COT,

[TR2Type.BirdMonster] = TR2LevelNames.CHICKEN,
[TR2Type.WhiteTiger] = TR2LevelNames.CHICKEN,

[TR2Type.BarracudaXian] = TR2LevelNames.XIAN,
[TR2Type.GiantSpider] = TR2LevelNames.XIAN,

[TR2Type.Knifethrower] = TR2LevelNames.FLOATER,
[TR2Type.KnifeProjectile_H] = TR2LevelNames.FLOATER,
[TR2Type.XianGuardSword] = TR2LevelNames.FLOATER,
[TR2Type.XianGuardSpear] = TR2LevelNames.FLOATER,
[TR2Type.XianGuardSpearStatue] = TR2LevelNames.FLOATER,
[TR2Type.XianGuardSwordStatue] = TR2LevelNames.FLOATER,

[TR2Type.MarcoBartoli] = TR2LevelNames.LAIR,
[TR2Type.DragonExplosionEmitter_N] = TR2LevelNames.LAIR,
[TR2Type.DragonExplosion1_H] = TR2LevelNames.LAIR,
[TR2Type.DragonExplosion2_H] = TR2LevelNames.LAIR,
[TR2Type.DragonExplosion3_H] = TR2LevelNames.LAIR,
[TR2Type.DragonFront_H] = TR2LevelNames.LAIR,
[TR2Type.DragonBack_H] = TR2LevelNames.LAIR,
[TR2Type.DragonBonesFront_H] = TR2LevelNames.LAIR,
[TR2Type.DragonBonesBack_H] = TR2LevelNames.LAIR,
[TR2Type.LaraMiscAnim_H_Xian] = TR2LevelNames.LAIR,
[TR2Type.Puzzle2_M_H_Dagger] = TR2LevelNames.LAIR,

[TR2Type.StickWieldingGoon1BlackJacket] = TR2LevelNames.HOME,

[TR2Type.Winston] = TR2LevelNames.ASSAULT,
};

private static readonly Dictionary<TR2Type, TR2RAlias> _mapAliases = new()
{
[TR2Type.BengalTiger] = TR2RAlias.TIGER_EMPRTOMB_WALL,
[TR2Type.StickWieldingGoon1BodyWarmer] = TR2RAlias.WORKER3_BOAT,
[TR2Type.StickWieldingGoon1WhiteVest] = TR2RAlias.WORKER3_VENICE_OPERA,
[TR2Type.ShotgunGoon] = TR2RAlias.CULT3_OPERA,
[TR2Type.StickWieldingGoon1Bandana] = TR2RAlias.WORKER3_PLATFORM_RIG,
[TR2Type.BarracudaUnwater] = TR2RAlias.BARACUDDA_DECK_LIVING_KEEL_UNWATER,
[TR2Type.StickWieldingGoon1GreenVest] = TR2RAlias.WORKER3_DECK_LIVING_KEEL_UNWATER,
[TR2Type.SnowLeopard] = TR2RAlias.TIGER_CATACOMB_SKIDOO,
[TR2Type.BarracudaIce] = TR2RAlias.BARACUDDA_ICECAVE_CATACOMB,
[TR2Type.WhiteTiger] = TR2RAlias.TIGER_ICECAVE,
[TR2Type.BarracudaXian] = TR2RAlias.BARACUDDA_EMPRTOMB,
[TR2Type.StickWieldingGoon1BlackJacket] = TR2RAlias.WORKER3_HOUSE,
};
}
93 changes: 83 additions & 10 deletions TRDataControl/Data/Remastered/TR3RDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@ public override TR3Type TranslateKey(TR3Type key)
};
}

public override TR3Type TranslateAlias(TR3Type key)
=> (_dataProvider ??= new()).TranslateAlias(key);

public override string GetSourceLevel(TR3Type key)
{
_dataProvider ??= new();
TR3Type translatedType = _dataProvider.TranslateAlias(key);
return _sourceLevels.ContainsKey(translatedType) ? _sourceLevels[translatedType] : null;
}
=> _sourceLevels.ContainsKey(key) ? _sourceLevels[key] : null;

public override TR3RAlias GetAlias(TR3Type key)
{
_dataProvider ??= new();
TR3Type translatedType = _dataProvider.TranslateAlias(key);
return _mapAliases.ContainsKey(translatedType) ? _mapAliases[translatedType] : default;
}
=> _mapAliases.ContainsKey(key) ? _mapAliases[key] : default;

private static readonly Dictionary<TR3Type, string> _sourceLevels = new()
{
Expand All @@ -50,6 +45,81 @@ public override TR3RAlias GetAlias(TR3Type key)
[TR3Type.Quest1_M_H] = TR3LevelNames.COASTAL,
[TR3Type.Quest2_P] = TR3LevelNames.MADHOUSE,
[TR3Type.Quest2_M_H] = TR3LevelNames.MADHOUSE,

[TR3Type.Monkey] = TR3LevelNames.JUNGLE,
[TR3Type.MonkeyMedMeshswap] = TR3LevelNames.JUNGLE,
[TR3Type.MonkeyKeyMeshswap] = TR3LevelNames.JUNGLE,
[TR3Type.Tiger] = TR3LevelNames.JUNGLE,

[TR3Type.Shiva] = TR3LevelNames.RUINS,
[TR3Type.ShivaStatue] = TR3LevelNames.RUINS,
[TR3Type.LaraExtraAnimation_H] = TR3LevelNames.RUINS,
[TR3Type.CobraIndia] = TR3LevelNames.RUINS,

[TR3Type.Quad] = TR3LevelNames.GANGES,
[TR3Type.LaraVehicleAnimation_H_Quad] = TR3LevelNames.GANGES,
[TR3Type.Vulture] = TR3LevelNames.GANGES,

[TR3Type.TonyFirehands] = TR3LevelNames.CAVES,

[TR3Type.Croc] = TR3LevelNames.COASTAL,
[TR3Type.TribesmanAxe] = TR3LevelNames.COASTAL,
[TR3Type.TribesmanDart] = TR3LevelNames.COASTAL,

[TR3Type.Compsognathus] = TR3LevelNames.CRASH,
[TR3Type.Mercenary] = TR3LevelNames.CRASH,
[TR3Type.Raptor] = TR3LevelNames.CRASH,
[TR3Type.Tyrannosaur] = TR3LevelNames.CRASH,

[TR3Type.Kayak] = TR3LevelNames.MADUBU,
[TR3Type.LaraVehicleAnimation_H_Kayak] = TR3LevelNames.MADUBU,
[TR3Type.LizardMan] = TR3LevelNames.MADUBU,

[TR3Type.Puna] = TR3LevelNames.PUNA,

[TR3Type.Crow] = TR3LevelNames.THAMES,
[TR3Type.LondonGuard] = TR3LevelNames.THAMES,
[TR3Type.LondonMerc] = TR3LevelNames.THAMES,
[TR3Type.Rat] = TR3LevelNames.THAMES,

[TR3Type.Punk] = TR3LevelNames.ALDWYCH,
[TR3Type.DogLondon] = TR3LevelNames.ALDWYCH,

[TR3Type.ScubaSteve] = TR3LevelNames.LUDS,
[TR3Type.UPV] = TR3LevelNames.LUDS,
[TR3Type.LaraVehicleAnimation_H_UPV] = TR3LevelNames.LUDS,

[TR3Type.SophiaLee] = TR3LevelNames.CITY,

[TR3Type.DamGuard] = TR3LevelNames.NEVADA,
[TR3Type.CobraNevada] = TR3LevelNames.NEVADA,

[TR3Type.MPWithStick] = TR3LevelNames.HSC,
[TR3Type.MPWithGun] = TR3LevelNames.HSC,
[TR3Type.Prisoner] = TR3LevelNames.HSC,
[TR3Type.DogNevada] = TR3LevelNames.HSC,

[TR3Type.KillerWhale] = TR3LevelNames.AREA51,
[TR3Type.MPWithMP5] = TR3LevelNames.AREA51,

[TR3Type.CrawlerMutantInCloset] = TR3LevelNames.ANTARC,
[TR3Type.Boat] = TR3LevelNames.ANTARC,
[TR3Type.LaraVehicleAnimation_H_Boat] = TR3LevelNames.ANTARC,
[TR3Type.RXRedBoi] = TR3LevelNames.ANTARC,
[TR3Type.DogAntarc] = TR3LevelNames.ANTARC,

[TR3Type.Crawler] = TR3LevelNames.RXTECH,
[TR3Type.RXTechFlameLad] = TR3LevelNames.RXTECH,
[TR3Type.BruteMutant] = TR3LevelNames.RXTECH,

[TR3Type.TinnosMonster] = TR3LevelNames.TINNOS,
[TR3Type.TinnosWasp] = TR3LevelNames.TINNOS,

[TR3Type.Willie] = TR3LevelNames.WILLIE,
[TR3Type.RXGunLad] = TR3LevelNames.WILLIE,

[TR3Type.Winston] = TR3LevelNames.ASSAULT,
[TR3Type.WinstonInCamoSuit] = TR3LevelNames.ASSAULT,
};

private static readonly Dictionary<TR3Type, TR3RAlias> _mapAliases = new()
Expand All @@ -66,5 +136,8 @@ public override TR3RAlias GetAlias(TR3Type key)
[TR3Type.Quest1_M_H] = TR3RAlias.PUZZLE_OPTION1_SHORE,
[TR3Type.Quest2_P] = TR3RAlias.PUZZLE_ITEM1_HAND,
[TR3Type.Quest2_M_H] = TR3RAlias.PUZZLE_OPTION1_HAND,

[TR3Type.DogLondon] = TR3RAlias.DOG_SEWER,
[TR3Type.CobraNevada] = TR3RAlias.COBRA_NEVADA,
};
}
8 changes: 8 additions & 0 deletions TRDataControl/Transport/ImportResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TRDataControl;

public class ImportResult<T>
where T : Enum
{
public List<T> ImportedTypes { get; set; } = new();
public List<T> RemovedTypes { get; set; } = new();
}
Loading

0 comments on commit 7847af4

Please sign in to comment.