private static Ball ReadBallFromStream(Stream str) { var ret = new Ball {Header = str.ReadStruct<BallHeader>()}; if (ret.Header.Mode != BallMode.Rigid) ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>(); if (ret.Header.Flags.HasFlag(BallFlag.IsFree)) ret.Data = str.ReadStruct<BallData>(); var reader = new BinaryReader(str); ret.FormationId = reader.ReadByte(); switch (ret.Header.Mode) { case BallMode.Follow: case BallMode.Orbit: ret.FollowState = str.ReadStruct<FollowState>(); break; case BallMode.Formation: ret.FormationState = str.ReadStruct<FormationState>(); break; case BallMode.Troll: ret.TrollState = str.ReadStruct<TrollState>(); break; case BallMode.Missile: ret.MissileState = str.ReadStruct<MissileState>(); break; case BallMode.Goto: ret.GotoState = str.ReadStruct<GotoState>(); break; case BallMode.Warp: ret.WarpState = str.ReadStruct<WarpState>(); break; case BallMode.Mushroom: ret.MushroomState = str.ReadStruct<MushroomState>(); break; case BallMode.Stop: case BallMode.Field: case BallMode.Rigid: // no extra data for these break; } if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls)) ret.MiniBalls = ReadMiniBalls(reader); ret.Name = ReadString(reader); return ret; }
public Chunk ReadChunk(Stream Stream) { var ChunkSize = (uint)Stream.ReadStruct<uint_be>(); //var ChunkType = (ushort)Stream.ReadStruct<ushort_be>(); var ChunkStream = Stream.ReadStream(ChunkSize); return new Chunk() { Size = ChunkSize, //Type = ChunkType, Stream = ChunkStream, }; }
public Pmf Load(Stream Stream) { this.Stream = Stream; Header = Stream.ReadStruct<HeaderStruct>(); var Chunk = ReadChunk(Stream.SliceWithLength(0x50)); InfoHeader = Chunk.Stream.ReadStruct<InfoHeaderStruct>(); /* Console.WriteLine("0x{0:X}", (ulong)InfoHeader.FirstTimestamp); Console.WriteLine("0x{0:X}", (ulong)InfoHeader.LastTimestamp); Console.WriteLine("{0}", (ulong)InfoHeader.Width); Console.WriteLine("{0}", (ulong)InfoHeader.Height); */ return this; }
private void ReadHeader(Stream str) { Header = str.ReadStruct<Header>(); if (Header.PacketType != 0 && Header.PacketType != 1) throw new InvalidDataException("Unknown packet type; expected 0 or 1, got " + Header.PacketType); }
private static Ball ReadBallFromStream(Stream str) { var ret = new Ball {Header = str.ReadStruct<BallHeader>()}; if (ret.Header.Mode != BallMode.Rigid) ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>(); if (ret.Header.Flags.HasFlag(BallFlag.IsFree)) ret.Data = str.ReadStruct<BallData>(); var reader = new BinaryReader(str); ret.FormationId = reader.ReadByte(); switch (ret.Header.Mode) { case BallMode.Follow: case BallMode.Orbit: ret.FollowState = str.ReadStruct<FollowState>(); break; case BallMode.Formation: ret.FormationState = str.ReadStruct<FormationState>(); break; case BallMode.Troll: ret.TrollState = str.ReadStruct<TrollState>(); break; case BallMode.Missile: ret.MissileState = str.ReadStruct<MissileState>(); break; case BallMode.Goto: ret.GotoState = str.ReadStruct<GotoState>(); break; case BallMode.Warp: ret.WarpState = str.ReadStruct<WarpState>(); break; case BallMode.Mushroom: ret.MushroomState = str.ReadStruct<MushroomState>(); break; case BallMode.Stop: case BallMode.Field: case BallMode.Rigid: // no extra data for these break; } if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls)) ret.MiniBalls = ReadMiniBalls(reader); // Crucible: // no more names in destiny data // most of them were invalid anyway, and slimitems have the name, so sensible change for CCP //ret.Name = ReadString(reader); return ret; }