public void WriteTMAPInfoDescent1(DescentWriter bw, TMAPInfo tMAPInfo) { byte[] temp = new byte[13]; Array.Copy(tMAPInfo.filename, temp, tMAPInfo.filename.Length); bw.Write(temp, 0, 13); bw.WriteByte(tMAPInfo.Flags); bw.WriteFix(tMAPInfo.Lighting); bw.WriteFix(tMAPInfo.Damage); bw.WriteInt32(tMAPInfo.EClipNum); }
internal void WriteWClipDescent1(WClip clip, DescentWriter bw) { bw.WriteFix(clip.PlayTime); bw.WriteInt16(clip.NumFrames); for (int f = 0; f < 20; f++) { bw.WriteUInt16(clip.Frames[f]); } bw.WriteInt16(clip.OpenSound); bw.WriteInt16(clip.CloseSound); bw.WriteInt16(clip.Flags); var nameBytes = NameHelper.GetNameBytes(clip.Filename, 13); bw.Write(nameBytes); bw.WriteByte(clip.Pad); }
internal void WriteWeaponInfoDescent1(DescentWriter writer, Weapon weapon) { writer.WriteByte((byte)weapon.RenderType); writer.WriteByte((byte)weapon.ModelNum); writer.WriteByte((byte)weapon.ModelNumInner); writer.WriteByte((byte)(weapon.Persistent ? 1 : 0)); writer.WriteSByte(weapon.MuzzleFlashVClip); writer.WriteInt16(weapon.FiringSound); writer.WriteSByte(weapon.RobotHitVClip); writer.WriteInt16(weapon.RobotHitSound); writer.WriteSByte(weapon.WallHitVClip); writer.WriteInt16(weapon.WallHitSound); writer.WriteByte(weapon.FireCount); writer.WriteByte(weapon.AmmoUsage); writer.WriteSByte(weapon.WeaponVClip); writer.WriteByte((byte)(weapon.Destroyable ? 1 : 0)); writer.WriteByte((byte)(weapon.Matter ? 1 : 0)); writer.WriteByte((byte)weapon.Bounce); writer.WriteByte((byte)(weapon.HomingFlag ? 1 : 0)); writer.Write(weapon.Padding); writer.WriteFix(weapon.EnergyUsage); writer.WriteFix(weapon.FireWait); writer.WriteUInt16(weapon.Bitmap); writer.WriteFix(weapon.BlobSize); writer.WriteFix(weapon.FlashSize); writer.WriteFix(weapon.ImpactSize); for (int s = 0; s < 5; s++) { writer.WriteFix(weapon.Strength[s]); } for (int s = 0; s < 5; s++) { writer.WriteFix(weapon.Speed[s]); } writer.WriteFix(weapon.Mass); writer.WriteFix(weapon.Drag); writer.WriteFix(weapon.Thrust); writer.WriteFix(weapon.POLenToWidthRatio); writer.WriteFix(weapon.Light); writer.WriteFix(weapon.Lifetime); writer.WriteFix(weapon.DamageRadius); writer.WriteUInt16(weapon.CockpitPicture); }
public void WriteRobotDescent1(Robot robot, DescentWriter bw) { bw.WriteInt32(robot.ModelNum); bw.WriteInt32(robot.NumGuns); bw.WriteMany(Polymodel.MaxGuns, robot.GunPoints, (writer, a) => writer.WriteFixVector(a)); bw.WriteMany(8, robot.GunSubmodels, (writer, a) => writer.WriteByte(a)); bw.WriteInt16(robot.HitVClipNum); bw.WriteInt16(robot.HitSoundNum); bw.WriteInt16(robot.DeathVClipNum); bw.WriteInt16(robot.DeathSoundNum); bw.WriteInt16(robot.WeaponType); bw.WriteSByte(robot.ContainsID); bw.WriteSByte(robot.ContainsCount); bw.WriteSByte(robot.ContainsProbability); bw.WriteSByte(robot.ContainsType); bw.WriteInt32(robot.ScoreValue); bw.WriteFix(robot.Lighting); bw.WriteFix(robot.Strength); bw.WriteFix(robot.Mass); bw.WriteFix(robot.Drag); bw.WriteMany(Robot.NumDifficultyLevels, robot.FieldOfView, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.FiringWait, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.TurnTime, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.FirePower, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.Shield, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.MaxSpeed, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.CircleDistance, (writer, a) => writer.WriteFix(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.RapidfireCount, (writer, a) => writer.WriteSByte(a)); bw.WriteMany(Robot.NumDifficultyLevels, robot.EvadeSpeed, (writer, a) => writer.WriteSByte(a)); bw.WriteSByte((sbyte)robot.CloakType); bw.WriteSByte((sbyte)robot.AttackType); bw.WriteSByte((sbyte)robot.BossFlag); bw.WriteByte(robot.SeeSound); bw.WriteByte(robot.AttackSound); bw.WriteByte(robot.ClawSound); for (int v = 0; v < 9; v++) { for (int u = 0; u < 5; u++) { bw.WriteInt16(robot.AnimStates[v, u].NumJoints); bw.WriteInt16(robot.AnimStates[v, u].Offset); } } bw.WriteInt32(robot.Always0xABCD); }
public void Write(Stream stream) { DescentWriter descentWriter = new DescentWriter(stream); HAMDataWriter writer = new HAMDataWriter(); Int32 DataPointer = 0; // update this later on descentWriter.Write(DataPointer); // update this later on descentWriter.Write((Int32)numTextures); for (int i = 0; i < 800; i++) { descentWriter.Write((UInt16)Textures[i]); } for (int i = 0; i < 800; i++) { this.WriteTMAPInfoDescent1(descentWriter, TMapInfo[i]); } descentWriter.Write(SoundIDs); descentWriter.Write(AltSounds); descentWriter.Write((Int32)numVClips); //this value is bogus. rip for (int i = 0; i < 70; i++) { writer.WriteVClip(VClips[i], descentWriter); } descentWriter.Write((Int32)numEClips); for (int i = 0; i < 60; i++) { writer.WriteEClip(EClips[i], descentWriter); } descentWriter.Write((Int32)numWClips); for (int i = 0; i < 30; i++) { this.WriteWClipDescent1(WClips[i], descentWriter); } descentWriter.Write((Int32)numRobots); for (int i = 0; i < 30; i++) { this.WriteRobotDescent1(Robots[i], descentWriter); } descentWriter.Write((Int32)numJoints); for (int i = 0; i < 600; i++) { JointPos joint = Joints[i]; descentWriter.WriteInt16(joint.JointNum); descentWriter.WriteInt16(joint.Angles.P); descentWriter.WriteInt16(joint.Angles.B); descentWriter.WriteInt16(joint.Angles.H); } descentWriter.WriteInt32(numWeapons); for (int i = 0; i < 30; i++) { this.WriteWeaponInfoDescent1(descentWriter, Weapons[i]); } descentWriter.WriteInt32(numPowerups); for (int i = 0; i < 29; i++) { var powerup = this.Powerups[i]; descentWriter.WriteInt32(powerup.VClipNum); descentWriter.WriteInt32(powerup.HitSound); descentWriter.WriteFix(powerup.Size); descentWriter.WriteFix(powerup.Light); } descentWriter.WriteInt32(numModels); for (int i = 0; i < numModels; i++) { writer.WritePolymodel(Models[i], descentWriter); } for (int i = 0; i < numModels; i++) { descentWriter.Write(Models[i].InterpreterData, 0, Models[i].ModelIDTASize); } for (int i = 0; i < Gauges.Length; i++) { descentWriter.WriteUInt16(Gauges[i]); } for (int i = 0; i < 85; i++) { if (Models[i] == null) { descentWriter.WriteInt32(-1); } else { descentWriter.WriteInt32(Models[i].DyingModelnum); } } for (int i = 0; i < 85; i++) { if (Models[i] == null) { descentWriter.WriteInt32(-1); } else { descentWriter.WriteInt32(Models[i].DeadModelnum); } } for (int i = 0; i < 210; i++) { descentWriter.WriteUInt16(ObjBitmaps[i]); } for (int i = 0; i < 210; i++) { descentWriter.WriteUInt16(ObjBitmapPointers[i]); } descentWriter.WriteInt32(PlayerShip.ModelNum); descentWriter.WriteInt32(PlayerShip.DeathVClipNum); descentWriter.WriteFix(PlayerShip.Mass); descentWriter.WriteFix(PlayerShip.Drag); descentWriter.WriteFix(PlayerShip.MaxThrust); descentWriter.WriteFix(PlayerShip.ReverseThrust); descentWriter.WriteFix(PlayerShip.Brakes); descentWriter.WriteFix(PlayerShip.Wiggle); descentWriter.WriteFix(PlayerShip.MaxRotationThrust); for (int x = 0; x < 8; x++) { descentWriter.WriteFixVector(PlayerShip.GunPoints[x]); } descentWriter.WriteInt32(numCockpits); for (int i = 0; i < 4; i++) { descentWriter.WriteInt16((Int16)Cockpits[i]); } //heh descentWriter.Write(SoundIDs, 0, 250); descentWriter.Write(AltSounds, 0, 250); descentWriter.WriteInt32(numObjects); for (int i = 0; i < 100; i++) { descentWriter.Write((sbyte)ObjectTypes[i].type); } for (int i = 0; i < 100; i++) { descentWriter.Write((byte)ObjectTypes[i].id); } for (int i = 0; i < 100; i++) { descentWriter.WriteFix(ObjectTypes[i].strength); } descentWriter.WriteInt32(FirstMultiBitmapNum); descentWriter.WriteInt32(reactor.NumGuns); for (int y = 0; y < 4; y++) { descentWriter.WriteFixVector(reactor.GunPoints[y]); } for (int y = 0; y < 4; y++) { descentWriter.WriteFixVector(reactor.GunDirs[y]); } descentWriter.WriteInt32(exitModelnum); descentWriter.WriteInt32(destroyedExitModelnum); for (int i = 0; i < 1800; i++) { descentWriter.WriteInt16((Int16)BitmapXLATData[i]); } // // Go back to the start and update the DataPointer // DataPointer = (int)descentWriter.BaseStream.Position; descentWriter.BaseStream.Seek(0, SeekOrigin.Begin); descentWriter.Write((Int32)DataPointer); // update the data pointer // Return to where we were descentWriter.BaseStream.Seek(DataPointer, SeekOrigin.Begin); descentWriter.WriteInt32(Bitmaps.Count - 1); // Ignore the bogus one descentWriter.WriteInt32(Sounds.Count); int dynamicOffset = 0; for (int i = 1; i < Bitmaps.Count; i++) // Skip the bogus one { var bitmap = Bitmaps[i]; descentWriter.Write(bitmap.LocalName, 0, 8); descentWriter.WriteByte((byte)bitmap.DFlags); descentWriter.WriteByte((byte)bitmap.Width); descentWriter.WriteByte((byte)bitmap.Height); descentWriter.WriteByte((byte)bitmap.Flags); descentWriter.WriteByte((byte)bitmap.AverageIndex); descentWriter.WriteInt32(dynamicOffset); dynamicOffset += bitmap.GetSize(); } for (int i = 0; i < Sounds.Count; i++) { var sound = Sounds[i]; //var nameBytes = NameHelper.GetNameBytes(sound.name, 8); descentWriter.Write(sound.LocalName, 0, 8); descentWriter.WriteInt32(sound.Length); descentWriter.WriteInt32(sound.Length); descentWriter.WriteInt32(dynamicOffset); dynamicOffset += sound.Length; } for (int i = 1; i < Bitmaps.Count; i++) { Bitmaps[i].WriteImage(descentWriter); } for (int i = 0; i < Sounds.Count; i++) { descentWriter.Write(Sounds[i].Data); } }