Skip to content

Commit f3cdad8

Browse files
committed
load base types
1 parent 0ec1eac commit f3cdad8

8 files changed

Lines changed: 50 additions & 12 deletions

File tree

src/ModVerify/Verifiers/ReferencedModelsVerifier.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace AET.ModVerify.Verifiers;
99

10+
// TODO: Add GameObjectTypeVerifier and check that LandModelTerrainOverride is correct (all keys correct, no dups)
11+
1012
public sealed class ReferencedModelsVerifier(
1113
IStarWarsGameEngine engine,
1214
GameVerifySettings settings,

src/PetroglyphTools/PG.StarWarsGame.Engine/Audio/Sfx/SfxEvent.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ internal SfxEvent(string name, Crc32 nameCrc, XmlLocationInfo location)
170170
: base(name, nameCrc, location)
171171
{
172172
PreSamples = new ReadOnlyCollection<string>(PreSamplesInternal);
173+
Samples = new ReadOnlyCollection<string>(SamplesInternal);
174+
PostSamples = new ReadOnlyCollection<string>(PostSamplesInternal);
175+
LocalizedTextIDs = new ReadOnlyCollection<string>(LocalizedTextIDsInternal);
173176
}
174177

175178
internal void FixupValues()

src/PetroglyphTools/PG.StarWarsGame.Engine/GameObjects/GameObject.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.ObjectModel;
44
using System.Diagnostics;
55
using PG.Commons.Hashing;
6+
using PG.StarWarsGame.Engine.Utilities;
67
using PG.StarWarsGame.Files.XML;
78
using PG.StarWarsGame.Files.XML.Data;
89

@@ -33,8 +34,6 @@ public sealed class GameObject : NamedXmlObject
3334

3435
public string? SpaceModel { get; internal set; }
3536

36-
public string? TacticalModel { get; internal set; }
37-
3837
public string? GalacticFleetOverrideModel { get; internal set; }
3938

4039
public string? GuiModel { get; internal set; }
@@ -77,6 +76,19 @@ public void PostLoadFixup()
7776

7877
internal void ApplyBaseType(GameObject baseType)
7978
{
80-
throw new NotImplementedException();
79+
// The following properties must not be inherited from the base type:
80+
// ID, CRC, Name, Location, IsLoadingComplete, ClassificationName and VariantOfExistingType[Name], LuaScript
81+
82+
GalacticModel = baseType.GalacticModel;
83+
DestroyedGalacticModel = baseType.DestroyedGalacticModel;
84+
LandModel = baseType.LandModel;
85+
SpaceModel = baseType.SpaceModel;
86+
GalacticFleetOverrideModel = baseType.GalacticFleetOverrideModel;
87+
GuiModel = baseType.GuiModel;
88+
ModelName = baseType.ModelName;
89+
LandAnimOverrideModel = baseType.LandAnimOverrideModel;
90+
SpaceAnimOverrideModel = baseType.SpaceAnimOverrideModel;
91+
DamagedSmokeAssetModel = baseType.DamagedSmokeAssetModel;
92+
InternalLandTerrainModelMapping.ClearAddRange(baseType.InternalLandTerrainModelMapping);
8193
}
8294
}

src/PetroglyphTools/PG.StarWarsGame.Engine/GameObjects/GameObjectTypeGameManager.Initialization.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using AnakinRaW.CommonUtilities.FileSystem;
89

910
namespace PG.StarWarsGame.Engine.GameObjects;
1011

@@ -62,7 +63,7 @@ private void ParseGameObjectDatabases()
6263
{
6364
foreach (var gameObject in _gameObjects)
6465
{
65-
if (!gameObject.IsLoadingComplete && gameObject.Location.XmlFile == gameObjectXmlFile)
66+
if (!gameObject.IsLoadingComplete && IsSameFile(gameObject.Location.XmlFile, gameObjectXmlFile))
6667
ParseSingleGameObjectFile(gameObjectXmlFile, gameParser, gameObjectFileParser);
6768
}
6869
}
@@ -79,6 +80,11 @@ private void ParseGameObjectDatabases()
7980
}
8081
}
8182

83+
private bool IsSameFile(string filePathA, string filePathB)
84+
{
85+
return FileSystem.Path.AreEqual(filePathA, filePathB);
86+
}
87+
8288
private void OnGameObjectParsed(object sender, GameObjectParsedEventArgs e)
8389
{
8490
if (!e.Unique)

src/PetroglyphTools/PG.StarWarsGame.Engine/GameObjects/GameObjectTypeGameManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public IEnumerable<string> GetModels(GameObject gameObject)
3737
AddNotEmpty(gameObject.DestroyedGalacticModel);
3838
AddNotEmpty(gameObject.LandModel);
3939
AddNotEmpty(gameObject.SpaceModel);
40-
AddNotEmpty(gameObject.TacticalModel);
4140
AddNotEmpty(gameObject.GalacticFleetOverrideModel);
4241
AddNotEmpty(gameObject.GuiModel);
4342
AddNotEmpty(gameObject.ModelName);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace PG.StarWarsGame.Engine.Utilities;
4+
5+
internal static class ExtensionMethods
6+
{
7+
extension<T>(List<T> list)
8+
{
9+
public void ClearAddRange(IEnumerable<T> items)
10+
{
11+
list.Clear();
12+
list.AddRange(items);
13+
}
14+
}
15+
}

src/PetroglyphTools/PG.StarWarsGame.Engine/Xml/Parsers/NamedObjects/GameObjectParser.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ protected override void ParseObject(
6363

6464
if (OverlayLoad)
6565
{
66-
Debug.Assert(replace);
6766
OverlayType(xmlObject, element, parsedEntries);
6867
}
6968
else
@@ -168,22 +167,22 @@ protected override void BuildMappings()
168167
GameObjectXmlTags.SpaceModelAnimOverrideName,
169168
PetroglyphXmlStringParser.Instance.Parse,
170169
(obj, val) => obj.SpaceAnimOverrideModel = val);
171-
172-
// TODO
173-
170+
174171
AddMapping(
175172
GameObjectXmlTags.DamagedSmokeAssetName,
176173
PetroglyphXmlStringParser.Instance.Parse,
177174
(obj, val) => obj.DamagedSmokeAssetModel = val);
178175

179-
// TODO
180176

181177
AddMapping(
182178
GameObjectXmlTags.GuiModelName,
183179
PetroglyphXmlStringParser.Instance.Parse,
184180
(obj, val) => obj.GuiModel = val);
185181

186-
// TODO
182+
AddMapping(
183+
GameObjectXmlTags.VariantOfExistingType,
184+
PetroglyphXmlStringParser.Instance.Parse,
185+
(obj, val) => obj.VariantOfExistingTypeName = val);
187186
}
188187
}
189188

@@ -202,5 +201,7 @@ internal static class GameObjectXmlTags
202201
public const string LandModelAnimOverrideName = "Land_Model_Anim_Override_Name";
203202
public const string SpaceModelAnimOverrideName = "Space_Model_Anim_Override_Name";
204203
public const string DamagedSmokeAssetName = "Damaged_Smoke_Asset_Name";
204+
205+
public const string VariantOfExistingType = "Variant_Of_Existing_Type";
205206
}
206207
}

src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/Primitives/PetroglyphXmlStringParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public sealed class PetroglyphXmlStringParser : PetroglyphPrimitiveXmlParser<str
99

1010
private protected override string DefaultValue => string.Empty;
1111

12-
internal override int EngineDataTypeId => 0x17;
12+
internal override int EngineDataTypeId => 0x17 & 0x1D & 0x1F;
1313

1414
private PetroglyphXmlStringParser()
1515
{

0 commit comments

Comments
 (0)