-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,641 additions
and
7 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
104 changes: 104 additions & 0 deletions
104
Mutagen.Bethesda.Starfield/Records/Major Records/PERS.cs
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,104 @@ | ||
using Mutagen.Bethesda.Plugins.Binary.Overlay; | ||
using Mutagen.Bethesda.Plugins.Binary.Streams; | ||
using Mutagen.Bethesda.Plugins.Binary.Translations; | ||
using Mutagen.Bethesda.Plugins.Internals; | ||
using Mutagen.Bethesda.Starfield.Internals; | ||
using NexusMods.Paths.Trees.Traits; | ||
|
||
namespace Mutagen.Bethesda.Starfield; | ||
|
||
partial class PERSBinaryCreateTranslation | ||
{ | ||
internal static readonly IReadOnlyRecordCollection Targets = RecordCollection.Factory(RecordTypes.XXXX, RecordTypes.DAT2); | ||
|
||
public static partial ParseResult FillBinaryItemsParseCustom( | ||
MutagenFrame frame, | ||
IPERSInternal item, | ||
PreviousParse lastParsed) | ||
{ | ||
frame = frame.SpawnAll(); | ||
item.Items.Clear(); | ||
int? contentLen = null; | ||
while (frame.TryGetSubrecord(Targets, out var subRec)) | ||
{ | ||
if (subRec.RecordType == RecordTypes.XXXX) | ||
{ | ||
contentLen = subRec.AsInt32(); | ||
frame.Position += subRec.TotalLength; | ||
} | ||
else | ||
{ | ||
if (contentLen == null) | ||
{ | ||
contentLen = subRec.ContentLength; | ||
} | ||
frame.Position += subRec.HeaderLength; | ||
|
||
var items = Mutagen.Bethesda.Plugins.Binary.Translations.ListBinaryTranslation<PERSItem>.Instance.Parse( | ||
reader: frame.SpawnWithLength(contentLen.Value), | ||
transl: PERSItem.TryCreateFromBinary); | ||
item.Items.Add(new PERSItems() | ||
{ | ||
Items = items | ||
}); | ||
} | ||
} | ||
|
||
return (int)PERS_FieldIndex.Items; | ||
} | ||
} | ||
|
||
partial class PERSBinaryWriteTranslation | ||
{ | ||
public static partial void WriteBinaryItemsParseCustom( | ||
MutagenWriter writer, | ||
IPERSGetter item) | ||
{ | ||
foreach (var x in item.Items) | ||
{ | ||
using (HeaderExport.Subrecord(writer, RecordTypes.DAT2, | ||
overflowRecord: RecordTypes.XXXX, | ||
out var writerToUse)) | ||
{ | ||
x.WriteToBinary(writerToUse); | ||
} | ||
} | ||
} | ||
} | ||
|
||
partial class PERSBinaryOverlay | ||
{ | ||
public IReadOnlyList<IPERSItemsGetter> Items { get; private set; } = Array.Empty<IPERSItemsGetter>(); | ||
|
||
public partial ParseResult ItemsParseCustomParse( | ||
OverlayStream stream, | ||
int offset, | ||
PreviousParse lastParsed) | ||
{ | ||
var itemsList = new List<IPERSItemsGetter>(); | ||
int? contentLen = null; | ||
while (stream.TryGetSubrecord(PERSBinaryCreateTranslation.Targets, out var subRec)) | ||
{ | ||
if (subRec.RecordType == RecordTypes.XXXX) | ||
{ | ||
contentLen = subRec.AsInt32(); | ||
stream.Position += subRec.TotalLength; | ||
} | ||
else | ||
{ | ||
if (contentLen == null) | ||
{ | ||
contentLen = subRec.ContentLength; | ||
} | ||
|
||
stream.Position += subRec.HeaderLength; | ||
|
||
itemsList.Add(PERSItemsBinaryOverlay.PERSItemsFactory(stream.ReadMemory(contentLen.Value), _package)); | ||
} | ||
} | ||
|
||
Items = itemsList; | ||
|
||
return (int)PERS_FieldIndex.Items; | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="us-ascii"?> | ||
<Loqui xmlns="http://tempuri.org/LoquiSource.xsd"> | ||
<Object name="PERS" recordType="PERS" objType="Record" baseClass="StarfieldMajorRecord"> | ||
<Fields> | ||
<UInt32 name="DATA" recordType="DATA" unknown="true" /> | ||
<CustomLogic name="ItemsParse"> | ||
<RecordType>XXXX</RecordType> | ||
<RecordType>DAT2</RecordType> | ||
</CustomLogic> | ||
<RefList name="Items" refName="PERSItems" unknown="true" binary="NoGeneration" /> | ||
</Fields> | ||
</Object> | ||
<Object name="PERSItems" objType="Subrecord"> | ||
<Fields> | ||
<RefList name="Items" refName="PERSItem" unknown="true" /> | ||
</Fields> | ||
</Object> | ||
<Object name="PERSItem" objType="Subrecord"> | ||
<Fields> | ||
<FormLink name="Record" refName="StarfieldMajorRecord" /> | ||
<UInt32 name="Unknown1" unknown="true" /> | ||
<UInt32 name="Unknown2" unknown="true" /> | ||
</Fields> | ||
</Object> | ||
</Loqui> |
Oops, something went wrong.