Example #1
0
            public static ConditionBinaryOverlay ConditionFactory(OverlayStream stream, BinaryOverlayFactoryPackage package)
            {
                var subRecMeta = stream.GetSubrecordFrame();

                if (subRecMeta.RecordType != RecordTypes.CTDA)
                {
                    throw new ArgumentException();
                }
                Condition.Flag flag = ConditionBinaryCreateTranslation.GetFlag(subRecMeta.Content[0]);
                if (flag.HasFlag(Condition.Flag.UseGlobal))
                {
                    return(ConditionGlobalBinaryOverlay.ConditionGlobalFactory(stream, package));
                }
                else
                {
                    return(ConditionFloatBinaryOverlay.ConditionFloatFactory(stream, package));
                }
            }
Example #2
0
            public static IBodyTemplateGetter?CustomFactory(OverlayStream stream, BinaryOverlayFactoryPackage package)
            {
                var subFrame = stream.GetSubrecordFrame();
                var version  = package.FormVersion !.FormVersion !.Value;

                switch (subFrame.RecordTypeInt)
                {
                case RecordTypeInts.BODT:
                    if (version >= 44)
                    {
                        throw new ArgumentException("BODT type not expected on versions >= 44");
                    }
                    return(BodyTemplateBinaryOverlay.BodyTemplateFactory(stream, package));

                case RecordTypeInts.BOD2:
                    if (version < 43)
                    {
                        throw new ArgumentException("BOD2 type not expected on versions < 43");
                    }
                    if (version >= 44)
                    {
                        return(BodyTemplateBinaryOverlay.BodyTemplateFactory(stream, package));
                    }
                    var cur = package.FormVersion;
                    package.FormVersion = new FormVersionGetter()
                    {
                        FormVersion = 44
                    };
                    var template = BodyTemplateBinaryOverlay.BodyTemplateFactory(stream, package);
                    template.ActsLike44 = true;
                    package.FormVersion = cur;
                    return(template);

                default:
                    throw new ArgumentException();
                }
            }
Example #3
0
            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.");
                }
            }