Exemplo n.º 1
0
 private void CreateLocalLists()
 {
     foreach (Robot robot in BaseFile.ReplacedRobots)
     {
         ReplacedRobots.Add(robot);
     }
     foreach (JointPos joint in BaseFile.ReplacedJoints)
     {
         ReplacedJoints.Add(joint);
     }
     foreach (Polymodel model in BaseFile.ReplacedModels)
     {
         ReplacedModels.Add(model);
     }
     foreach (ReplacedBitmapElement bm in BaseFile.ReplacedObjBitmaps)
     {
         ReplacedObjBitmaps.Add(bm);
     }
     foreach (ReplacedBitmapElement bm in BaseFile.ReplacedObjBitmapPtrs)
     {
         ReplacedObjBitmapPtrs.Add(bm);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Loads an HXM file from a given stream.
        /// </summary>
        /// <param name="stream">The stream to load the HXM data from.</param>
        public void Read(Stream stream)
        {
            BinaryReader br;

            br = new BinaryReader(stream);

            HAMDataReader data = new HAMDataReader();

            int sig = br.ReadInt32();
            int ver = br.ReadInt32();

            if (sig != 559435080)
            {
                br.Dispose();
                throw new InvalidDataException("HXMFile::Read: HXM file has bad header.");
            }
            if (ver != 1)
            {
                br.Dispose();
                throw new InvalidDataException(string.Format("HXMFile::Read: HXM file has bad version. Got {0}, but expected 1", ver));
            }

            int replacedRobotCount = br.ReadInt32();

            for (int x = 0; x < replacedRobotCount; x++)
            {
                int   replacementID = br.ReadInt32();
                Robot robot         = data.ReadRobot(br);
                robot.replacementID = replacementID;
                ReplacedRobots.Add(robot);
            }
            int replacedJointCount = br.ReadInt32();

            for (int x = 0; x < replacedJointCount; x++)
            {
                int      replacementID = br.ReadInt32();
                JointPos joint         = new JointPos();
                joint.JointNum      = br.ReadInt16();
                joint.Angles.P      = br.ReadInt16();
                joint.Angles.B      = br.ReadInt16();
                joint.Angles.H      = br.ReadInt16();
                joint.ReplacementID = replacementID;
                ReplacedJoints.Add(joint);
            }
            int modelsToReplace = br.ReadInt32();

            for (int x = 0; x < modelsToReplace; x++)
            {
                int       replacementID = br.ReadInt32();
                Polymodel model         = data.ReadPolymodelInfo(br);
                model.ReplacementID   = replacementID;
                model.InterpreterData = br.ReadBytes(model.ModelIDTASize);
                ReplacedModels.Add(model);
                model.DyingModelnum = br.ReadInt32();
                model.DeadModelnum  = br.ReadInt32();
            }
            int objBitmapsToReplace = br.ReadInt32();

            for (int x = 0; x < objBitmapsToReplace; x++)
            {
                ReplacedBitmapElement objBitmap = new ReplacedBitmapElement();
                objBitmap.ReplacementID = br.ReadInt32();
                objBitmap.Data          = br.ReadUInt16();
                ReplacedObjBitmaps.Add(objBitmap);
                //Console.WriteLine("Loading replacement obj bitmap, replacing slot {0} with {1} ({2})", objBitmap.replacementID, objBitmap.data, baseFile.piggyFile.images[objBitmap.data].name);
            }
            int objBitmapPtrsToReplace = br.ReadInt32();

            for (int x = 0; x < objBitmapPtrsToReplace; x++)
            {
                ReplacedBitmapElement objBitmap = new ReplacedBitmapElement();
                objBitmap.ReplacementID = br.ReadInt32();
                objBitmap.Data          = br.ReadUInt16();
                ReplacedObjBitmapPtrs.Add(objBitmap);
            }
        }