private static void PrintBall(StringBuilder sb, string indention, Ball ball) { sb.AppendLine(indention + "[Ball]"); sb.AppendLine(indention + Indention + "[Name: " + ball.Name + "]"); sb.AppendLine(indention + Indention + "[FormationId: " + ball.FormationId + "]"); PrintBallHeader(sb, indention + Indention, ball.Header); if (ball.ExtraHeader != null) PrintBallExtraHeader(sb, indention + Indention, ball.ExtraHeader); if (ball.Data != null) PrintBallData(sb, indention + Indention, ball.Data); switch (ball.Header.Mode) { case BallMode.Goto: PrintGotoState(sb, indention + Indention, ball.GotoState); break; case BallMode.Warp: PrintWarpState(sb, indention + Indention, ball.WarpState); break; case BallMode.Missile: PrintMissileState(sb, indention + Indention, ball.MissileState); break; case BallMode.Formation: PrintFormationState(sb, indention + Indention, ball.FormationState); break; case BallMode.Follow: PrintFollowState(sb, indention + Indention, ball.FollowState); break; case BallMode.Mushroom: PrintMushroomState(sb, indention + Indention, ball.MushroomState); break; case BallMode.Troll: PrintTrollState(sb, indention + Indention, ball.TrollState); break; } if (ball.MiniBalls != null) foreach (var miniBall in ball.MiniBalls) PrintMiniBall(sb, indention + Indention, miniBall); }
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; }