コード例 #1
0
 internal void WriteHeader(BinaryWriterEx bw, int i, int j, TAEFormat format)
 {
     bw.WriteVarint(indices.Count);
     bw.ReserveVarint($"EventGroupValuesOffset{i}:{j}");
     bw.ReserveVarint($"EventGroupTypeOffset{i}:{j}");
     if (format != TAEFormat.DS1)
     {
         bw.WriteVarint(0);
     }
 }
コード例 #2
0
            internal void WriteBody(BinaryWriterEx bw, int i, TAEFormat format)
            {
                bw.FillVarint($"AnimationOffset{i}", bw.Position);

                if (format == TAEFormat.DS1)
                {
                    bw.WriteInt32(Events.Count);
                    bw.ReserveVarint($"EventHeadersOffset{i}");
                    bw.WriteInt32(EventGroups.Count);
                    bw.ReserveVarint($"EventGroupHeadersOffset{i}");
                    bw.ReserveInt32($"TimesCount{i}");
                    bw.ReserveVarint($"TimesOffset{i}");
                    bw.ReserveVarint($"AnimFileOffset{i}");
                    //For DeS write 5 int32 == 0
                }
                else
                {
                    bw.ReserveVarint($"EventHeadersOffset{i}");
                    bw.ReserveVarint($"EventGroupHeadersOffset{i}");
                    bw.ReserveVarint($"TimesOffset{i}");
                    bw.ReserveVarint($"AnimFileOffset{i}");
                    bw.WriteInt32(Events.Count);
                    bw.WriteInt32(EventGroups.Count);
                    bw.ReserveInt32($"TimesCount{i}");
                    bw.WriteInt32(0);
                }
            }
コード例 #3
0
 internal void WriteHeader(BinaryWriterEx bw, int i, TAEFormat format)
 {
     bw.WriteVarint(ID);
     bw.ReserveVarint($"AnimationOffset{i}");
     if (format == TAEFormat.DES)
     {
         bw.Pad(0x10);
     }
 }
コード例 #4
0
 internal void WriteHeader(BinaryWriterEx bw, int animIndex, int eventIndex, Dictionary <float, long> timeOffsets, TAEFormat format)
 {
     bw.WriteVarint(timeOffsets[StartTime]);
     bw.WriteVarint(timeOffsets[EndTime]);
     bw.ReserveVarint($"EventDataOffset{animIndex}:{eventIndex}");
     if (format == TAEFormat.DES)
     {
         bw.Pad(0x10);
     }
 }
コード例 #5
0
            internal void WriteAnimFile(BinaryWriterEx bw, int i, TAEFormat format)
            {
                bw.FillVarint($"AnimFileOffset{i}", bw.Position);
                bw.WriteVarint((int)MiniHeader.Type);
                bw.WriteVarint(bw.Position + (bw.VarintLong ? 8 : 4));
                bw.ReserveVarint("AnimFileNameOffset");

                //if (AnimFileReference)
                //{
                //    bw.WriteInt32(ReferenceID);

                //    bw.WriteBoolean(UnkReferenceFlag1);
                //    bw.WriteBoolean(ReferenceIsTAEOnly);
                //    bw.WriteBoolean(ReferenceIsHKXOnly);
                //    bw.WriteBoolean(LoopByDefault);
                //}
                //else
                //{
                //    bw.WriteBoolean(UnkReferenceFlag1);
                //    bw.WriteBoolean(ReferenceIsTAEOnly);
                //    bw.WriteBoolean(ReferenceIsHKXOnly);
                //    bw.WriteBoolean(LoopByDefault);

                //    bw.WriteInt32(ReferenceID);
                //}

                MiniHeader.WriteInner(bw);

                if (format != TAEFormat.DS1)
                {
                    bw.WriteVarint(0);
                    bw.WriteVarint(0);
                }
                else
                {
                    bw.WriteVarint(0);

                    if (MiniHeader.Type == MiniHeaderType.ImportOtherAnim)
                    {
                        bw.WriteVarint(0);
                    }
                }

                bw.FillVarint("AnimFileNameOffset", bw.Position);
                if (AnimFileName != "")
                {
                    bw.WriteUTF16(AnimFileName, true);

                    if (format != TAEFormat.DS1)
                    {
                        bw.Pad(0x10);
                    }
                }
            }
コード例 #6
0
                public void Write(BinaryWriterEx bw)
                {
                    bw.ReserveVarint("EventGroupDataOffset");
                    long dataStartPos = bw.Position;

                    WriteInner(bw);
                    if (dataStartPos != bw.Position)
                    {
                        bw.FillVarint("EventGroupDataOffset", dataStartPos);
                    }
                    else
                    {
                        bw.FillVarint("EventGroupDataOffset", 0);
                    }
                }
コード例 #7
0
            internal void WriteBody(BinaryWriterEx bw, int i, TAEFormat format)
            {
                bw.FillVarint($"AnimationOffset{i}", bw.Position);

                EventGroups.Clear();
                foreach (var ev in Events)
                {
                    if (ev.Group != null && !EventGroups.Contains(ev.Group))
                    {
                        EventGroups.Add(ev.Group);
                    }
                }

                if (format == TAEFormat.DS1 || format == TAEFormat.DES)
                {
                    bw.WriteInt32(Events.Count);
                    bw.ReserveVarint($"EventHeadersOffset{i}");
                    bw.WriteInt32(EventGroups.Count);
                    bw.ReserveVarint($"EventGroupHeadersOffset{i}");
                    bw.ReserveInt32($"TimesCount{i}");
                    bw.ReserveVarint($"TimesOffset{i}");
                    bw.ReserveVarint($"AnimFileOffset{i}");
                    //For DeS write 5 int32 == 0
                    if (format == TAEFormat.DES)
                    {
                        for (int j = 0; j < 5; j++)
                        {
                            bw.WriteInt32(0);
                        }
                    }
                }
                else
                {
                    bw.ReserveVarint($"EventHeadersOffset{i}");
                    bw.ReserveVarint($"EventGroupHeadersOffset{i}");
                    bw.ReserveVarint($"TimesOffset{i}");
                    bw.ReserveVarint($"AnimFileOffset{i}");
                    bw.WriteInt32(Events.Count);
                    bw.WriteInt32(EventGroups.Count);
                    bw.ReserveInt32($"TimesCount{i}");
                    bw.WriteInt32(0);
                }
            }
コード例 #8
0
            internal void WriteData(BinaryWriterEx bw, int animIndex, int eventIndex, TAEFormat format)
            {
                CopyParametersToBytes(bw.BigEndian);

                bw.FillVarint($"EventDataOffset{animIndex}:{eventIndex}", bw.Position);
                bw.WriteInt32(Type);

                if (format != TAEFormat.DS1)
                {
                    bw.WriteInt32(Unk04);
                }



                if (format == TAEFormat.SDT && Type == 943)
                {
                    bw.WriteVarint(0);
                }
                else
                {
                    bw.ReserveVarint($"EventDataParametersOffset{animIndex}:{eventIndex}");
                }

                if (format == TAEFormat.DES)
                {
                    bw.Pad(0x10);
                }

                bw.FillVarint($"EventDataParametersOffset{animIndex}:{eventIndex}", bw.Position);

                bw.WriteBytes(ParameterBytes);

                if (bw.VarintLong || format == TAEFormat.DES)
                {
                    bw.Pad(0x10);
                }
            }
コード例 #9
0
            internal void WriteData(BinaryWriterEx bw, int i, int j, List <long> eventHeaderOffsets, TAEFormat format)
            {
                bw.FillVarint($"EventGroupTypeOffset{i}:{j}", bw.Position);
                bw.WriteVarint(GroupType);

                if (format == TAEFormat.SOTFS)
                {
                    bw.WriteVarint(bw.Position + (bw.VarintLong ? 8 : 4));
                    bw.WriteVarint(0);
                    bw.WriteVarint(0);
                }
                else if (format != TAEFormat.DS1)
                {
                    bw.WriteVarint(0);
                }
                else
                {
                    bw.ReserveVarint("EventGroupDataOffset");
                    long dataStartPos = bw.Position;

                    if (GroupData.DataType == EventGroupDataType.ApplyToSpecificCutsceneEntity)
                    {
                        bw.WriteUInt16((ushort)(GroupData.CutsceneEntityType));
                        bw.WriteInt16(GroupData.CutsceneEntityIDPart1);
                        bw.WriteInt16(GroupData.CutsceneEntityIDPart2);
                        bw.WriteSByte(GroupData.Block);
                        bw.WriteSByte(GroupData.Area);
                        bw.WriteInt32(0);
                        bw.WriteInt32(0);
                    }

                    if (dataStartPos != bw.Position)
                    {
                        bw.FillVarint("EventGroupDataOffset", dataStartPos);
                    }
                    else
                    {
                        bw.FillVarint("EventGroupDataOffset", 0);
                    }


                    if ((int)GroupData.DataType != GroupType)
                    {
                        throw new InvalidDataException("TAE event group data is not for the correct type.");
                    }
                }

                bw.FillVarint($"EventGroupValuesOffset{i}:{j}", bw.Position);
                for (int k = 0; k < indices.Count; k++)
                {
                    if (format == TAEFormat.SOTFS)
                    {
                        bw.WriteVarint(eventHeaderOffsets[indices[k]]);
                    }
                    else
                    {
                        bw.WriteInt32((int)eventHeaderOffsets[indices[k]]);
                    }
                }

                if (format != TAEFormat.DS1)
                {
                    bw.Pad(0x10);
                }
            }
コード例 #10
0
        protected override void Write(BinaryWriterEx bw)
        {
            bw.WriteASCII("TAE ");

            bw.BigEndian = BigEndian;

            bw.WriteBoolean(BigEndian);
            bw.WriteByte(0);
            bw.WriteByte(0);

            if (Format == TAEFormat.DS1)
            {
                bw.VarintLong = false;
                bw.WriteByte(0);
            }
            else
            {
                bw.VarintLong = true;
                bw.WriteByte(0xFF);
            }

            if (Format == TAEFormat.DS1)
            {
                bw.WriteInt32(0x1000B);
            }
            else if (Format == TAEFormat.DS3 || Format == TAEFormat.SOTFS)
            {
                bw.WriteInt32(0x1000C);
            }
            else if (Format == TAEFormat.SDT)
            {
                bw.WriteInt32(0x1000D);
            }

            bw.ReserveInt32("FileSize");
            bw.WriteVarint(0x40);
            bw.WriteVarint(1);
            bw.WriteVarint(0x50);
            bw.WriteVarint(Format == TAEFormat.DS1 ? 0x70 : 0x80);

            if (Format == TAEFormat.DS1)
            {
                bw.WriteInt16(2);
                bw.WriteInt16(1);
            }
            else
            {
                bw.WriteVarint(EventBank);
            }

            bw.WriteVarint(0);

            //DeS also
            if (Format == TAEFormat.DS1)
            {
                bw.WriteInt64(0);
                bw.WriteInt64(0);
                bw.WriteInt64(0);
            }

            bw.WriteBytes(Flags);

            if (Format == TAEFormat.SOTFS)
            {
                bw.WriteByte(0);
                bw.WriteByte(1);
            }
            else
            {
                bw.WriteByte(1);
                bw.WriteByte(0);
            }

            for (int i = 0; i < 6; i++)
            {
                bw.WriteByte(0);
            }

            bw.WriteInt32(ID);
            bw.WriteInt32(Animations.Count);
            bw.ReserveVarint("AnimsOffset");
            bw.ReserveVarint("AnimGroupsOffset");
            bw.WriteVarint(Format == TAEFormat.DS1 ? 0x90 : 0xA0);
            bw.WriteVarint(Animations.Count);
            bw.ReserveVarint("FirstAnimOffset");
            if (Format == TAEFormat.DS1)
            {
                bw.WriteInt32(0);
            }
            bw.WriteVarint(1);
            bw.WriteVarint(Format == TAEFormat.DS1 ? 0x80 : 0x90);
            if (Format == TAEFormat.DS1)
            {
                bw.WriteInt64(0);
            }
            bw.WriteInt32(ID);
            bw.WriteInt32(ID);
            bw.WriteVarint(0x50);
            bw.WriteInt64(0);
            bw.WriteVarint(Format == TAEFormat.DS1 ? 0x98 : 0xB0);
            bw.ReserveVarint("SkeletonName");
            bw.ReserveVarint("SibName");

            if (Format != TAEFormat.SOTFS)
            {
                bw.WriteVarint(0);
                bw.WriteVarint(0);
            }

            bw.FillVarint("SkeletonName", bw.Position);
            if (!string.IsNullOrEmpty(SkeletonName))
            {
                bw.WriteUTF16(SkeletonName, true);
                if (Format != TAEFormat.DS1)
                {
                    bw.Pad(0x10);
                }
            }

            bw.FillVarint("SibName", bw.Position);
            if (!string.IsNullOrEmpty(SibName))
            {
                bw.WriteUTF16(SibName, true);
                if (Format != TAEFormat.DS1)
                {
                    bw.Pad(0x10);
                }
            }

            Animations.Sort((a1, a2) => a1.ID.CompareTo(a2.ID));

            var animOffsets = new List <long>(Animations.Count);

            if (Animations.Count == 0)
            {
                bw.FillVarint("AnimsOffset", 0);
            }
            else
            {
                bw.FillVarint("AnimsOffset", bw.Position);
                for (int i = 0; i < Animations.Count; i++)
                {
                    animOffsets.Add(bw.Position);
                    Animations[i].WriteHeader(bw, i);
                }
            }

            bw.FillVarint("AnimGroupsOffset", bw.Position);
            bw.ReserveVarint("AnimGroupsCount");
            bw.ReserveVarint("AnimGroupsOffset");
            int  groupCount = 0;
            long groupStart = bw.Position;

            for (int i = 0; i < Animations.Count; i++)
            {
                int firstIndex = i;
                bw.WriteInt32((int)Animations[i].ID);
                while (i < Animations.Count - 1 && Animations[i + 1].ID == Animations[i].ID + 1)
                {
                    i++;
                }
                bw.WriteInt32((int)Animations[i].ID);
                bw.WriteVarint(animOffsets[firstIndex]);
                groupCount++;
            }
            bw.FillVarint("AnimGroupsCount", groupCount);

            if (groupCount == 0)
            {
                bw.FillVarint("AnimGroupsOffset", 0);
            }
            else
            {
                bw.FillVarint("AnimGroupsOffset", groupStart);
            }

            if (Animations.Count == 0)
            {
                bw.FillVarint("FirstAnimOffset", 0);
            }
            else
            {
                bw.FillVarint("FirstAnimOffset", bw.Position);
                for (int i = 0; i < Animations.Count; i++)
                {
                    Animations[i].WriteBody(bw, i, Format);
                }
            }

            for (int i = 0; i < Animations.Count; i++)
            {
                Animation anim = Animations[i];
                anim.WriteAnimFile(bw, i, Format);
                Dictionary <float, long> timeOffsets = anim.WriteTimes(bw, i, Format);
                List <long> eventHeaderOffsets       = anim.WriteEventHeaders(bw, i, timeOffsets);
                anim.WriteEventData(bw, i, Format);
                anim.WriteEventGroupHeaders(bw, i, Format);
                anim.WriteEventGroupData(bw, i, eventHeaderOffsets, Format);
            }

            bw.FillInt32("FileSize", (int)bw.Position);
        }
コード例 #11
0
 internal void WriteHeader(BinaryWriterEx bw, int animIndex, int eventIndex, Dictionary <float, long> timeOffsets)
 {
     bw.WriteVarint(timeOffsets[StartTime]);
     bw.WriteVarint(timeOffsets[EndTime]);
     bw.ReserveVarint($"EventDataOffset{animIndex}:{eventIndex}");
 }
コード例 #12
0
 internal void WriteHeader(BinaryWriterEx bw, int i)
 {
     bw.WriteVarint(ID);
     bw.ReserveVarint($"AnimationOffset{i}");
 }