Skip to content

Commit

Permalink
Fix for skyrim scene fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Dec 23, 2023
1 parent 69d7178 commit 0f4b360
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ void IBinaryItem.WriteToBinary(
}

#region Structs
public IReadOnlyList<IScriptEntryStructsGetter> Structs => BinaryOverlayList.FactoryByLazyParse<IScriptEntryStructsGetter>(_structData, _package, countLength: 4, (s, p) => ScriptEntryStructsBinaryOverlay.ScriptEntryStructsFactory(s, p));
public IReadOnlyList<IScriptEntryStructsGetter> Structs { get; private set; } = null!;
protected int StructsEndingPos;
#endregion
partial void CustomFactoryEnd(
Expand Down Expand Up @@ -1230,6 +1230,13 @@ public static IScriptStructListPropertyGetter ScriptStructListPropertyFactory(
var ret = new ScriptStructListPropertyBinaryOverlay(
memoryPair: memoryPair,
package: package);
{
var tempStream = new OverlayStream(ret._structData, package)
{
};
ret.Structs = BinaryOverlayList.EagerFactoryByPrependedCount(tempStream, package, 4, (s, p) => ScriptEntryStructsBinaryOverlay.ScriptEntryStructsFactory(s, p));
ret.StructsEndingPos = tempStream.Position;
}
stream.Position += ret.StructsEndingPos;
ret.CustomFactoryEnd(
stream: stream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ void IBinaryItem.WriteToBinary(
}

#region PhaseFragments
public IReadOnlyList<IScenePhaseFragmentGetter> PhaseFragments => BinaryOverlayList.FactoryByLazyParse<IScenePhaseFragmentGetter>(_structData.Slice(0x1), _package, countLength: 2, (s, p) => ScenePhaseFragmentBinaryOverlay.ScenePhaseFragmentFactory(s, p));
public IReadOnlyList<IScenePhaseFragmentGetter> PhaseFragments { get; private set; } = null!;
protected int PhaseFragmentsEndingPos;
#endregion
partial void CustomFactoryEnd(
Expand Down Expand Up @@ -1235,6 +1235,14 @@ public static ISceneScriptFragmentsGetter SceneScriptFragmentsFactory(
var ret = new SceneScriptFragmentsBinaryOverlay(
memoryPair: memoryPair,
package: package);
{
var tempStream = new OverlayStream(ret._structData, package)
{
Position = 0x1
};
ret.PhaseFragments = BinaryOverlayList.EagerFactoryByPrependedCount(tempStream, package, 2, (s, p) => ScenePhaseFragmentBinaryOverlay.ScenePhaseFragmentFactory(s, p));
ret.PhaseFragmentsEndingPos = tempStream.Position;
}
stream.Position += ret.PhaseFragmentsEndingPos;
ret.CustomFactoryEnd(
stream: stream,
Expand Down
3 changes: 3 additions & 0 deletions Mutagen.Bethesda.Skyrim/Mutagen.Bethesda.Skyrim.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,9 @@
<Compile Include="Records\Major Records\RegionWeather.cs">
<DependentUpon>Region.xml</DependentUpon>
</Compile>
<Compile Include="Records\Major Records\SceneScriptFragments.cs">
<DependentUpon>Scene.xml</DependentUpon>
</Compile>
<Compile Include="Records\Major Records\StoryManagerEventNode.cs">
<DependentUpon>StoryManagerNodes.xml</DependentUpon>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Skyrim/Records/Major Records/Scene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</Object>
<Object name="SceneScriptFragments" baseClass="ScriptFragments" objType="Subrecord">
<Fields>
<RefList name="PhaseFragments" refName="ScenePhaseFragment" counterLength="2" />
<RefList name="PhaseFragments" refName="ScenePhaseFragment" counterLength="2" binaryOverlay="Custom" />
</Fields>
</Object>
<Object name="ScenePhaseFragment" objType="Subrecord">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Mutagen.Bethesda.Plugins.Binary.Overlay;

namespace Mutagen.Bethesda.Skyrim;

internal partial class SceneScriptFragmentsBinaryOverlay
{
public IReadOnlyList<IScenePhaseFragmentGetter> PhaseFragments => BinaryOverlayList.FactoryByLazyParse<IScenePhaseFragmentGetter>(_structData.Slice(FlagsEndingPos), _package, countLength: 2, (s, p) => ScenePhaseFragmentBinaryOverlay.ScenePhaseFragmentFactory(s, p));
}
Original file line number Diff line number Diff line change
Expand Up @@ -1196,8 +1196,8 @@ void IBinaryItem.WriteToBinary(
}

#region PhaseFragments
public IReadOnlyList<IScenePhaseFragmentGetter> PhaseFragments => BinaryOverlayList.FactoryByLazyParse<IScenePhaseFragmentGetter>(_structData.Slice(FlagsEndingPos), _package, countLength: 2, (s, p) => ScenePhaseFragmentBinaryOverlay.ScenePhaseFragmentFactory(s, p));
protected int PhaseFragmentsEndingPos;
partial void CustomPhaseFragmentsEndPos();
#endregion
partial void CustomFactoryEnd(
OverlayStream stream,
Expand Down Expand Up @@ -1230,6 +1230,7 @@ public static ISceneScriptFragmentsGetter SceneScriptFragmentsFactory(
var ret = new SceneScriptFragmentsBinaryOverlay(
memoryPair: memoryPair,
package: package);
ret.CustomPhaseFragmentsEndPos();
stream.Position += ret.PhaseFragmentsEndingPos;
ret.CustomFactoryEnd(
stream: stream,
Expand Down

0 comments on commit 0f4b360

Please sign in to comment.