public override ParseResult FillRecordType( OverlayStream stream, int finalPos, int offset, RecordType type, PreviousParse lastParsed, Dictionary <RecordType, int>?recordParseCount, TypedParseParams?parseParams = null) { type = parseParams.ConvertToStandard(type); switch (type.TypeInt) { case RecordTypeInts.FNAM: { return(TypeCharCustomParse( stream, offset)); } default: return(base.FillRecordType( stream: stream, finalPos: finalPos, offset: offset, type: type, lastParsed: lastParsed, recordParseCount: recordParseCount)); } }
public static ParseResult FillBinaryRecordTypes( IGlobalInternal item, MutagenFrame frame, PreviousParse lastParsed, Dictionary <RecordType, int>?recordParseCount, RecordType nextRecordType, int contentLength, TypedParseParams?translationParams = null) { nextRecordType = translationParams.ConvertToStandard(nextRecordType); switch (nextRecordType.TypeInt) { case RecordTypeInts.FNAM: { return(GlobalBinaryCreateTranslation.FillBinaryTypeCharCustom( frame: frame.SpawnWithLength(frame.MetaData.Constants.SubConstants.HeaderLength + contentLength), item: item)); } default: return(OblivionMajorRecordBinaryCreateTranslation.FillBinaryRecordTypes( item: item, frame: frame, lastParsed: lastParsed, recordParseCount: recordParseCount, nextRecordType: nextRecordType, contentLength: contentLength)); } }
private ParseResult CustomRecordFallback( OverlayStream stream, int finalPos, int offset, RecordType type, PreviousParse lastParsed, TypedParseParams?parseParams = null) { if (type.TypeInt == 0x44494445) // EDID { return(base.FillRecordType( stream: stream, finalPos: finalPos, offset: offset, type: type, recordParseCount: null, lastParsed: lastParsed, parseParams: parseParams)); } WeatherBinaryCreateTranslation.FillCloudTexture( new MutagenFrame(new MutagenInterfaceReadStream(stream, _package.MetaData)), type, _cloudTextures); return(default(int?)); }
partial void TopicsCustomParse( OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { Topics = new List <IATopicReferenceGetter>( ATopicReferenceBinaryCreateTranslation.Factory( new MutagenFrame(stream))); }
public static void FillModTypes( IBinaryReadStream stream, ModTypeFillWrapper fill, BinaryOverlayFactoryPackage package) { var lastParsed = new PreviousParse(); ModHeader headerMeta = stream.GetModHeader(package); var minimumFinalPos = checked ((int)(stream.Position + headerMeta.TotalLength)); fill( stream: stream, finalPos: minimumFinalPos, offset: 0, type: headerMeta.RecordType, lastParsed: lastParsed, parseParams: null); stream.Position = (int)headerMeta.TotalLength; while (!stream.Complete) { GroupHeader groupMeta = stream.GetGroup(package); if (!groupMeta.IsGroup) { throw new ArgumentException("Did not see GRUP header as expected."); } minimumFinalPos = checked ((int)(stream.Position + groupMeta.TotalLength)); var parsed = fill( stream: stream, finalPos: minimumFinalPos, offset: 0, type: groupMeta.ContainedRecordType, lastParsed: lastParsed, parseParams: null); if (!parsed.KeepParsing) { break; } if (!parsed.KeepParsing) { break; } if (minimumFinalPos > stream.Position) { stream.Position = checked ((int)minimumFinalPos); } lastParsed = parsed; } }
public static ParseResult CustomRecordFallback( IWeatherInternal item, MutagenFrame frame, PreviousParse lastParsed, Dictionary <RecordType, int>?recordParseCount, RecordType nextRecordType, int contentLength, TypedParseParams?translationParams = null) { if (nextRecordType.TypeInt == 0x44494445) // EDID { return(SkyrimMajorRecordBinaryCreateTranslation.FillBinaryRecordTypes( item: item, frame: frame, lastParsed: lastParsed, recordParseCount: recordParseCount, nextRecordType: nextRecordType, contentLength: contentLength, translationParams: translationParams)); } WeatherBinaryCreateTranslation.FillCloudTexture(frame, nextRecordType, item.CloudTextures); return(default(int?)); }
public void FillMajorRecords( OverlayStream stream, int finalPos, int offset, TypedParseParams?parseParams, RecordTypeFillWrapper fill) { var lastParsed = new PreviousParse(); Dictionary <RecordType, int>?recordParseCount = null; while (!stream.Complete && stream.Position < finalPos) { MajorRecordHeader majorMeta = stream.GetMajorRecord(); try { var minimumFinalPos = stream.Position + majorMeta.TotalLength; var parsed = fill( stream: stream, finalPos: finalPos, offset: offset, recordParseCount: recordParseCount, type: majorMeta.RecordType, lastParsed: lastParsed, parseParams: parseParams); if (!parsed.KeepParsing) { break; } if (parsed.DuplicateParseMarker != null) { if (recordParseCount == null) { recordParseCount = new Dictionary <RecordType, int>(); } recordParseCount[parsed.DuplicateParseMarker !.Value] =
partial void CloudsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { WeatherBinaryCreateTranslation.FillBinaryCloudYSpeeds( new MutagenFrame(new MutagenInterfaceReadStream(stream, _package.MetaData)), _clouds); }
partial void PointsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { if (stream.Complete) { return; } var subMeta = stream.GetSubrecord(); if (subMeta.RecordType != RecordTypes.PGRP) { return; } stream.Position += subMeta.HeaderLength; var pointBytes = stream.ReadMemory(subMeta.ContentLength); subMeta = stream.GetSubrecord(); switch (subMeta.RecordTypeInt) { case 0x52524750: // "PGRR": stream.Position += subMeta.HeaderLength; var connBytes = stream.ReadMemory(subMeta.ContentLength); this.Points = BinaryOverlayList.FactoryByLazyParse <IRoadPointGetter>( pointBytes, _package, getter: (s, p) => { int numPts = pointBytes.Length / RoadBinaryCreateTranslation.POINT_LEN; RoadPoint[] points = new RoadPoint[numPts]; var connFloats = connBytes.Span.AsFloatSpan(); for (int i = 0; i < numPts; i++) { var pt = RoadBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn); s = s.Slice(RoadBinaryCreateTranslation.POINT_LEN); P3Float[] conns = new P3Float[numConn]; for (int j = 0; j < numConn; j++) { conns[j] = new P3Float( x: connFloats[0], y: connFloats[1], z: connFloats[2]); connFloats = connFloats.Slice(3); } pt.Connections.AddRange(conns); points[i] = pt; } return(points); }); break; default: this.Points = BinaryOverlayList.FactoryByStartIndex <IRoadPointGetter>( pointBytes, _package, itemLength: RoadBinaryCreateTranslation.POINT_LEN, getter: (s, p) => RoadBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn)); break; } }
public static partial ParseResult FillBinaryParseCustom(MutagenFrame frame, IAvailableMorphs item, PreviousParse lastParsed) { FillBinaryParse(frame, item); return(lastParsed); }
partial void PointToPointConnectionsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { var dataFrame = stream.ReadSubrecordFrame(); uint ptCount = BinaryPrimitives.ReadUInt16LittleEndian(dataFrame.Content); var pgrpMeta = stream.GetSubrecord(); if (pgrpMeta.RecordType != PathGridBinaryCreateTranslation.PGRP) { return; } stream.Position += pgrpMeta.HeaderLength; var pointData = stream.ReadMemory(pgrpMeta.ContentLength); var bytePointsNum = pgrpMeta.ContentLength / PathGridBinaryCreateTranslation.POINT_LEN; if (bytePointsNum != ptCount) { throw new ArgumentException($"Unexpected point byte length, when compared to expected point count. {pgrpMeta.ContentLength} bytes: {bytePointsNum} != {ptCount} points."); } bool readPGRR = false; for (int recAttempt = 0; recAttempt < 2; recAttempt++) { if (stream.Complete) { break; } var subMeta = stream.GetSubrecord(); switch (subMeta.RecordType.TypeInt) { case 0x47414750: //"PGAG": this._PGAGLocation = stream.Position - offset; stream.Position += subMeta.TotalLength; break; case 0x52524750: // "PGRR": stream.Position += subMeta.HeaderLength; var connectionPtData = stream.ReadMemory(subMeta.ContentLength); this.PointToPointConnections = BinaryOverlayList.FactoryByLazyParse <IPathGridPointGetter>( pointData, _package, getter: (s, p) => { var connectionInts = connectionPtData.Span.AsInt16Span(); IPathGridPointGetter[] pathGridPoints = new IPathGridPointGetter[bytePointsNum]; for (int i = 0; i < bytePointsNum; i++) { var pt = PathGridPointBinaryOverlay.Factory(s, p); pt.Connections.AddRange(connectionInts.Slice(0, pt.NumConnections).ToArray()); pathGridPoints[i] = pt; s = s.Slice(16); connectionInts = connectionInts.Slice(pt.NumConnections); } return(pathGridPoints); }); readPGRR = true; break; default: break; } } if (!readPGRR) { this.PointToPointConnections = BinaryOverlayList.FactoryByStartIndex <IPathGridPointGetter>( pointData, this._package, itemLength: 16, getter: (s, p) => { return(PathGridBinaryCreateTranslation.ReadPathGridPoint(s, out var numConn)); }); } }
public partial ParseResult FunctionParametersCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { return(lastParsed); }
public partial ParseResult ParseCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { morphs = new AvailableMorphs(); AvailableMorphsBinaryCreateTranslation.FillBinaryParse( new MutagenFrame(new MutagenInterfaceReadStream(stream: stream, metaData: _package.MetaData)), morphs); return(lastParsed); }
public static partial ParseResult FillBinaryIDParseCustom(MutagenFrame frame, IQuestAlias item, PreviousParse lastParsed) { var subMeta = frame.ReadSubrecord(); item.Type = subMeta.RecordTypeInt switch { // ALST 0x54534C41 => QuestAlias.TypeEnum.Reference, // ALLS 0x534C4C41 => QuestAlias.TypeEnum.Location, _ => throw new NotImplementedException(), }; item.ID = frame.ReadUInt32(); return(lastParsed); }
public partial ParseResult EffectInitialCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { return(lastParsed); }
public partial ParseResult IDParseCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { var subMeta = stream.ReadSubrecord(); this.Type = subMeta.RecordTypeInt switch { // ALST 0x54534C41 => QuestAlias.TypeEnum.Reference, // ALLS 0x534C4C41 => QuestAlias.TypeEnum.Location, _ => throw new NotImplementedException(), }; this.ID = stream.ReadUInt32(); return(lastParsed); }
partial void AnimationsCustomParse( OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { byte?count = null; for (int i = 0; i < 3; i++) { var subRecord = stream.GetSubrecordFrame(); if (subRecord.RecordType == RecordTypes.IDLC) { // Counter start if (subRecord.Content.Length != 1) { throw new ArgumentException("Unexpected counter length"); } count = subRecord.Content[0]; stream.Position += subRecord.TotalLength; } else if (subRecord.RecordType == RecordTypes.IDLA) { if (count == null) { this.Animations = BinaryOverlayList.FactoryByArray <IFormLinkGetter <IIdleAnimationGetter> >( mem: stream.RemainingMemory, package: _package, getter: (s, p) => new FormLink <IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(s))), locs: ParseRecordLocations( stream: stream, constants: _package.MetaData.Constants.SubConstants, trigger: type, skipHeader: true)); } else { var subMeta = stream.ReadSubrecord(); var subLen = subMeta.ContentLength; this.Animations = BinaryOverlayList.FactoryByStartIndex <IFormLinkGetter <IIdleAnimationGetter> >( mem: stream.RemainingMemory.Slice(0, subLen), package: _package, itemLength: 4, getter: (s, p) => new FormLink <IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(s)))); stream.Position += subLen; } } else if (subRecord.RecordType == RecordTypes.IDLT) { _timerSetting = subRecord.Content.Float(); stream.Position += subRecord.TotalLength; } else { break; } } if (count.HasValue && count.Value != Animations.Count) { throw new ArgumentException("Idle animation counts did not match."); } }
partial void AnimationsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { var subHeader = stream.ReadSubrecord(); Animations = BinaryOverlayList.FactoryByStartIndex<IFormLinkGetter<IIdleAnimationGetter>>( mem: stream.RemainingMemory.Slice(0, subHeader.ContentLength), package: _package, itemLength: 4, getter: (s, p) => new FormLink<IIdleAnimationGetter>(FormKey.Factory(p.MetaData.MasterReferences!, BinaryPrimitives.ReadUInt32LittleEndian(s)))); }
public static partial ParseResult FillBinaryPatrolScriptMarkerCustom(MutagenFrame frame, IPatrol item, PreviousParse lastParsed) { if (frame.ReadSubrecordFrame().Content.Length != 0) { throw new ArgumentException($"Marker had unexpected length."); } return(lastParsed); }
public partial ParseResult PatrolScriptMarkerCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { if (stream.ReadSubrecordFrame().Content.Length != 0) { throw new ArgumentException($"Marker had unexpected length."); } return(lastParsed); }
partial void ConditionsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { Conditions = ConditionBinaryOverlay.ConstructBinayOverlayList(stream, _package); }
partial void CellsCustomParse(OverlayStream stream, long finalPos, int offset, RecordType type, PreviousParse lastParsed) { this.Cells = BinaryOverlayList.FactoryByArray <CellBinaryOverlay>( mem: stream.RemainingMemory, package: _package, parseParams: null, getter: (s, p, recConv) => CellBinaryOverlay.CellFactory(new OverlayStream(s, p), p, recConv), locs: CellBinaryOverlay.ParseRecordLocations( stream: stream, package: _package)); }
public partial ParseResult EndCustomParse(OverlayStream stream, int offset, PreviousParse lastParsed) { stream.ReadSubrecordFrame(); return(lastParsed); }
public static partial ParseResult FillBinaryFunctionParametersCustom(MutagenFrame frame, IAPerkEntryPointEffect item, PreviousParse lastParsed) { return(lastParsed); }
public static partial ParseResult FillBinaryEndCustom(MutagenFrame frame, IQuestAlias item, PreviousParse lastParsed) { // Skip frame.ReadSubrecordFrame(); return(lastParsed); }
public static partial ParseResult FillBinaryEffectInitialCustom(MutagenFrame frame, IEffect item, PreviousParse lastParsed) { var subMeta = frame.ReadSubrecord(); if (subMeta.ContentLength != Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect name must be length 4. Was: {subMeta.ContentLength}"); } var magicEffName = frame.ReadMemory(4); if (!frame.Reader.TryGetSubrecord(RecordTypes.EFIT, out var efitMeta)) { throw new ArgumentException("Expected EFIT header."); } if (efitMeta.ContentLength < Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect ref length was less than 4. Was: {efitMeta.ContentLength}"); } var magicEffName2 = frame.GetMemory(amount: Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength, offset: efitMeta.HeaderLength); if (!magicEffName.Span.SequenceEqual(magicEffName2.Span)) { throw new ArgumentException($"Magic effect names did not match. {BinaryStringUtility.ToZString(magicEffName, frame.MetaData.Encodings.NonTranslated)} != {BinaryStringUtility.ToZString(magicEffName2, frame.MetaData.Encodings.NonTranslated)}"); } return(lastParsed.ParsedIndex); }