public int CalcSize() { YkdFrames[] frames = Frames ?? new YkdFrames[0]; YkdOffsets offsets = new YkdOffsets {Offsets = new int[frames.Length]}; return NameSize + offsets.CalcSize() + frames.Sum(t => t.CalcSize()); }
public unsafe void ReadFromStream(Stream stream) { byte[] name = stream.EnsureRead(NameSize); fixed (byte* namePtr = &name[0]) Name = new string((sbyte*)namePtr, 0, NameSize, YkdFile.NamesEncoding).TrimEnd('\0'); Offsets = stream.ReadContent<YkdOffsets>(); Frames = new YkdFrames[Offsets.Count]; for (int i = 0; i < Frames.Length; i++) Frames[i] = stream.ReadContent<YkdFrames>(); }
public void ReadFromStream(Stream stream) { Header = stream.ReadContent<YkdHeader>(); Background = stream.ReadContent<YkdBlock>(); Offsets = stream.ReadContent<YkdOffsets>(); Blocks = new YkdBlock[Offsets.Count]; for (int i = 0; i < Blocks.Length; i++) { stream.SetPosition(Offsets[i]); Blocks[i] = stream.ReadContent<YkdBlock>(); } Resources = stream.ReadContent<YkdResources>(); }
public int CalcSize() { YkdBlockEntry[] entries = Entries ?? new YkdBlockEntry[0]; YkdOffsets offsets = new YkdOffsets {Offsets = new int[entries.Length]}; int result = 4 * 4 + TransformationMatrixSize + offsets.CalcSize() + entries.Sum(t => t.CalcSize()); if (ZeroTail != null) result += YkdBlockOptionalTail.Size; else if (Tails4 != null) result += Tails4.CalcSize(); else if (Tail56 != null) result += Tail56.Length * 4; return result; }
public void ReadFromStream(Stream stream) { Offsets = stream.ReadContent<YkdOffsets>(); Resources = new YkdResource[Offsets.Count]; for (int i = 0; i < Resources.Length; i++) { YkdResource resource = Resources[i] = new YkdResource(); stream.SetPosition(Offsets[i]); resource.ReadFromStream(stream); } if (!stream.IsEndOfStream()) throw new InvalidDataException(); }
public void ReadFromStream(Stream stream) { BinaryReader br = new BinaryReader(stream); IsFirstBlock = stream.Position == YkdHeader.Size; Type = br.ReadUInt32(); Index = br.ReadUInt32(); AssociatedIndex = br.ReadUInt32(); Unknown = br.ReadUInt32(); for (int i = 0; i < TransformationMatrix.Length; i++) TransformationMatrix[i] = br.ReadBigInt32(); Offsets = stream.ReadContent<YkdOffsets>(); Entries = new YkdBlockEntry[Offsets.Count]; for (int i = 0; i < Offsets.Count; i++) { stream.SetPosition(Offsets[i]); Entries[i] = stream.ReadContent<YkdBlockEntry>(); } if (!IsFirstBlock) { switch (Type) { case 0: ZeroTail = stream.ReadContent<YkdBlockOptionalTail>(); break; case 4: Tails4 = stream.ReadContent<YkdBlockOptionalTails>(); break; case 5: case 6: Tail56 = new int[12]; for (int i = 0; i < Tail56.Length; i++) Tail56[i] = br.ReadInt32(); break; } } }