Example #1
0
        public Descent1PIGFile(bool macPig = false, bool loadData = true)
        {
            Textures  = new ushort[800];
            TMapInfo  = new TMAPInfo[800];
            SoundIDs  = new byte[250];
            AltSounds = new byte[250];
            VClips    = new VClip[70];
            EClips    = new EClip[60];
            WClips    = new WClip[30];
            Robots    = new Robot[30];
            Joints    = new JointPos[600];
            Weapons   = new Weapon[30];
            Models    = new Polymodel[85];
            if (macPig)
            {
                Gauges = new ushort[85];
            }
            else
            {
                Gauges = new ushort[80];
            }
            ObjBitmaps        = new ushort[210];
            ObjBitmapPointers = new ushort[210];
            Cockpits          = new ushort[4];
            ObjectTypes       = new EditorObjectDefinition[100];
            Powerups          = new Powerup[29];
            BitmapXLATData    = new ushort[1800];
            reactor           = new Reactor();

            Bitmaps = new List <PIGImage>();
            Sounds  = new List <SoundData>();

            this.big      = macPig;
            this.LoadData = loadData;
        }
Example #2
0
        public TMAPInfo Clone()
        {
            TMAPInfo info = (TMAPInfo)MemberwiseClone();

            info.filename = new byte[13];
            Array.Copy(filename, info.filename, 13);
            return(info);
        }
Example #3
0
 public void WriteTMAPInfo(TMAPInfo tmapinfo, BinaryWriter bw)
 {
     bw.Write(tmapinfo.Flags);
     bw.Write(new byte[3]);
     bw.Write(tmapinfo.Lighting.value);
     bw.Write(tmapinfo.Damage.value);
     bw.Write(tmapinfo.EClipNum);
     bw.Write(tmapinfo.DestroyedID);
     bw.Write(tmapinfo.SlideU);
     bw.Write(tmapinfo.SlideV);
 }
Example #4
0
        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);
        }
        public TMAPInfo ReadTMAPInfoDescent1(BinaryReader br)
        {
            TMAPInfo mapinfo = new TMAPInfo();

            byte[] temp = br.ReadBytes(13);
            Array.Copy(temp, mapinfo.filename, 13);
            mapinfo.Flags    = br.ReadByte();
            mapinfo.Lighting = new Fix(br.ReadInt32());
            mapinfo.Damage   = new Fix(br.ReadInt32());
            mapinfo.EClipNum = (short)br.ReadInt32();

            return(mapinfo);
        }
        public TMAPInfo ReadTMAPInfo(BinaryReader br)
        {
            TMAPInfo mapinfo = new TMAPInfo();

            mapinfo.Flags = br.ReadByte();
            br.ReadBytes(3);
            mapinfo.Lighting    = new Fix(br.ReadInt32());
            mapinfo.Damage      = new Fix(br.ReadInt32());
            mapinfo.EClipNum    = br.ReadInt16();
            mapinfo.DestroyedID = br.ReadInt16();
            mapinfo.SlideU      = br.ReadInt16();
            mapinfo.SlideV      = br.ReadInt16();

            return(mapinfo);
        }
Example #7
0
 public PSXDatFile()
 {
     Textures          = new ushort[800];
     TMapInfo          = new TMAPInfo[800];
     Sounds            = new byte[250];
     AltSounds         = new byte[250];
     VClips            = new VClip[70];
     EClips            = new EClip[60];
     WClips            = new WClip[30];
     Robots            = new Robot[30];
     Joints            = new JointPos[600];
     Weapons           = new Weapon[30];
     Models            = new Polymodel[85];
     Gauges            = new ushort[80];
     ObjBitmaps        = new ushort[210];
     ObjBitmapPointers = new ushort[210];
     Cockpits          = new ushort[4];
     ObjectTypes       = new EditorObjectDefinition[100];
     Powerups          = new Powerup[29];
     BitmapXLATData    = new ushort[1800];
     reactor           = new Reactor();
 }
Example #8
0
        public void Write(Stream stream)
        {
            HAMDataWriter writer = new HAMDataWriter();
            BinaryWriter  bw     = new BinaryWriter(stream);

            bw.Write(558711112);
            bw.Write(Version);
            int returnPoint = (int)bw.BaseStream.Position;

            if (Version < 3)
            {
                bw.Write(0);
            }
            bw.Write(Textures.Count);
            for (int x = 0; x < Textures.Count; x++)
            {
                ushort texture = Textures[x];
                bw.Write(texture);
            }
            for (int x = 0; x < TMapInfo.Count; x++)
            {
                TMAPInfo texture = TMapInfo[x];
                writer.WriteTMAPInfo(texture, bw);
            }

            //Always write 254 sounds, for convenience.
            bw.Write(254);
            for (int x = 0; x < Sounds.Length; x++)
            {
                byte sound = Sounds[x];
                bw.Write(sound);
            }
            for (int x = 0; x < Sounds.Length; x++)
            {
                byte sound = AltSounds[x];
                bw.Write(sound);
            }
            bw.Write(VClips.Count);
            for (int x = 0; x < VClips.Count; x++)
            {
                writer.WriteVClip(VClips[x], bw);
            }
            bw.Write(EClips.Count);
            for (int x = 0; x < EClips.Count; x++)
            {
                writer.WriteEClip(EClips[x], bw);
            }
            bw.Write(WClips.Count);
            for (int x = 0; x < WClips.Count; x++)
            {
                writer.WriteWClip(WClips[x], bw);
            }
            bw.Write(Robots.Count);
            for (int x = 0; x < Robots.Count; x++)
            {
                writer.WriteRobot(Robots[x], bw);
            }
            bw.Write(Joints.Count);
            for (int x = 0; x < Joints.Count; x++)
            {
                JointPos joint = Joints[x];
                bw.Write(joint.JointNum);
                bw.Write(joint.Angles.P);
                bw.Write(joint.Angles.B);
                bw.Write(joint.Angles.H);
            }
            bw.Write(Weapons.Count);
            if (Version < 3)
            {
                for (int x = 0; x < Weapons.Count; x++)
                {
                    writer.WriteWeaponV2(Weapons[x], bw);
                }
            }
            else
            {
                for (int x = 0; x < Weapons.Count; x++)
                {
                    writer.WriteWeapon(Weapons[x], bw);
                }
            }
            bw.Write(Powerups.Count);
            for (int x = 0; x < Powerups.Count; x++)
            {
                Powerup powerup = Powerups[x];
                bw.Write(powerup.VClipNum);
                bw.Write(powerup.HitSound);
                bw.Write(powerup.Size.value);
                bw.Write(powerup.Light.value);
            }
            bw.Write(Models.Count);
            for (int x = 0; x < Models.Count; x++)
            {
                writer.WritePolymodel(Models[x], bw);
            }
            for (int x = 0; x < Models.Count; x++)
            {
                bw.Write(Models[x].InterpreterData);
            }
            for (int x = 0; x < Models.Count; x++)
            {
                int modelnum = Models[x].DyingModelnum;
                bw.Write(modelnum);
            }
            for (int x = 0; x < Models.Count; x++)
            {
                int modelnum = Models[x].DeadModelnum;
                bw.Write(modelnum);
            }
            bw.Write(Gauges.Count);
            for (int x = 0; x < Gauges.Count; x++)
            {
                ushort gague = Gauges[x];
                bw.Write(gague);
            }
            for (int x = 0; x < Gauges.Count; x++)
            {
                ushort gague = GaugesHires[x];
                bw.Write(gague);
            }
            //Always write exactly 600 ObjBitmaps, the limit in Descent 2, to conform to the original data files.
            //Can be optimized if you need to save a kb of data I guess
            bw.Write(600);
            for (int x = 0; x < 600; x++)
            {
                if (x < ObjBitmaps.Count)
                {
                    bw.Write(ObjBitmaps[x]);
                }
                else
                {
                    bw.Write((ushort)0);
                }
            }
            for (int x = 0; x < 600; x++)
            {
                if (x < ObjBitmapPointers.Count)
                {
                    bw.Write(ObjBitmapPointers[x]);
                }
                else
                {
                    bw.Write((ushort)0);
                }
            }
            writer.WritePlayerShip(PlayerShip, bw);
            bw.Write(Cockpits.Count);
            for (int x = 0; x < Cockpits.Count; x++)
            {
                ushort cockpit = Cockpits[x];
                bw.Write(cockpit);
            }
            bw.Write(FirstMultiBitmapNum);
            bw.Write(Reactors.Count);
            for (int x = 0; x < Reactors.Count; x++)
            {
                Reactor reactor = Reactors[x];
                bw.Write(reactor.ModelNum);
                bw.Write(reactor.NumGuns);
                for (int y = 0; y < 8; y++)
                {
                    bw.Write(reactor.GunPoints[y].X.value);
                    bw.Write(reactor.GunPoints[y].Y.value);
                    bw.Write(reactor.GunPoints[y].Z.value);
                }
                for (int y = 0; y < 8; y++)
                {
                    bw.Write(reactor.GunDirs[y].X.value);
                    bw.Write(reactor.GunDirs[y].Y.value);
                    bw.Write(reactor.GunDirs[y].Z.value);
                }
            }
            bw.Write(PlayerShip.MarkerModel);
            if (Version < 3)
            {
                bw.Write(ExitModelnum);
                bw.Write(DestroyedExitModelnum);
            }
            for (int x = 0; x < 2620; x++)
            {
                bw.Write(BitmapXLATData[x]);
            }
            int ptr = (int)bw.BaseStream.Position;

            if (Version < 3)
            {
                bw.BaseStream.Seek(returnPoint, SeekOrigin.Begin);
                bw.Write(ptr);
                bw.BaseStream.Seek(ptr, SeekOrigin.Begin);
                bw.Write(sounddata);
            }
            //bw.Dispose(); //[ISB] disposing a BinaryWriter seems to close the underlying stream. That's nice.
        }