Example #1
0
 // Methods
 public override void Read(BINAReader reader, BINAHeader header = null)
 {
     for (uint i = 0; i < CaptionCount; ++i)
     {
         reader.FixPadding(8);
         Captions[i] = new Caption(reader);
     }
 }
Example #2
0
        public const uint Signature   = 0x4658434F; // FXCO in ASCII

        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new BINAReader(fileStream);

            Header = reader.ReadHeader();

            uint sig = reader.ReadUInt32();

            if (sig != Signature)
            {
                throw new InvalidSignatureException("FXCO",
                                                    Encoding.ASCII.GetString(BitConverter.GetBytes(sig)));
            }

            uint  unknown1        = reader.ReadUInt32(); // Version number?
            ulong instanceCount   = reader.ReadUInt64();
            ulong instancesOffset = reader.ReadUInt64();

            ulong shapesCount  = reader.ReadUInt64();
            ulong shapesOffset = reader.ReadUInt64();

            ulong unknownCount  = reader.ReadUInt64();
            ulong unknownOffset = reader.ReadUInt64();

            // Instances
            reader.JumpTo((long)instancesOffset, false);
            for (uint i = 0; i < instanceCount; ++i)
            {
                reader.FixPadding(8);
                ulong nameOffset   = reader.ReadUInt64();
                byte  unknownFlag1 = reader.ReadByte();
                byte  unknownFlag2 = reader.ReadByte();
                byte  unknownFlag3 = reader.ReadByte();
                byte  unknownFlag4 = reader.ReadByte();

                var   vect1        = reader.ReadVector3(); // Position or size?
                ulong instPadding1 = reader.ReadUInt64();
                uint  instPadding2 = reader.ReadUInt32();
                uint  instUnknown1 = reader.ReadUInt32();

                ulong instPadding3 = reader.ReadUInt64();
                ulong instPadding4 = reader.ReadUInt64();
                ulong instPadding5 = reader.ReadUInt64();
                ulong instPadding6 = reader.ReadUInt64();

                ulong unknownString1 = reader.ReadUInt64();  // Always "none"?
                var   vect2          = reader.ReadVector3(); // Position or size?
                uint  instUnknown2   = reader.ReadUInt32();  // Always 0x00000080?
                uint  instPadding7   = reader.ReadUInt32();
                uint  instUnknown3   = reader.ReadUInt32();  // Always 0x00000080?

                float instUnknown4 = reader.ReadSingle();    // Always 1?
            }

            // Unknown
            reader.JumpTo((long)unknownOffset, false);
            for (uint i = 0; i < unknownCount; ++i)
            {
                ulong uk1 = reader.ReadUInt64(); // Maybe 8 indices?
            }

            // Shapes
            reader.JumpTo((long)shapesOffset, false);
            for (uint i = 0; i < shapesCount; ++i)
            {
                uint shapeUnknown1 = reader.ReadUInt32();
                uint shapeUnknown2 = reader.ReadUInt32();
                var  shapeUnknown3 = reader.ReadVector3();
                var  shapeUnknown4 = reader.ReadVector3();
            }
        }
        protected SetObjectParam ReadParameter(BINAReader reader, SetObjectTypeParam param)
        {
            FixPadding(reader, param.DataType);

            // Special Param Types
            if (param is SetObjectTypeParamGroup group)
            {
                var g           = new SetObjectParamGroup(group.Padding);
                var groupParams = g.Parameters;

                foreach (var p in group.Parameters)
                {
                    groupParams.Add(ReadParameter(reader, p));
                }

                reader.FixPadding(group.Padding ?? 16);
                return(g);
            }
            else if (param.DataType == typeof(ObjectReference[]))
            {
                long  arrOffset  = reader.ReadInt64();
                ulong arrLength  = reader.ReadUInt64();
                ulong arrLength2 = reader.ReadUInt64();
                long  curPos     = reader.BaseStream.Position;

                if (arrLength != arrLength2)
                {
                    Console.WriteLine(
                        "WARNING: ArrLength ({0}) != ArrLength2 ({1})",
                        arrLength, arrLength2);
                }

                var arr = new ObjectReference[arrLength];
                if (arrLength > 0 && arrOffset > 0)
                {
                    reader.JumpTo(arrOffset, false);
                    for (uint i = 0; i < arrLength; ++i)
                    {
                        arr[i] = new ObjectReference(reader);
                    }

                    reader.JumpTo(curPos);
                }

                return(new SetObjectParam(param.DataType, arr));
            }
            else if (param.DataType == typeof(ObjectReference))
            {
                return(new SetObjectParam(typeof(ObjectReference),
                                          new ObjectReference(reader)));
            }
            else if (param.DataType == typeof(string))
            {
                var  stringParam   = new SetObjectParam(typeof(string), string.Empty);
                long offset        = reader.ReadInt64();
                long stringPadding = reader.ReadInt64();

                if (offset > 0)
                {
                    long curPos = reader.BaseStream.Position;
                    reader.JumpTo(offset, false);
                    stringParam.Data = reader.ReadNullTerminatedString();
                    reader.JumpTo(curPos);
                }

                if (stringPadding != 0)
                {
                    Console.WriteLine("WARNING: String Padding != 0 ({0:X})!!", stringPadding);
                }

                //reader.FixPadding(16);
                return(stringParam);
            }

            // Data
            var objParam = new SetObjectParam(param.DataType,
                                              reader.ReadByType(param.DataType));

            // Post-Param Padding
            if (param.DataType == typeof(Vector3))
            {
                uint vecPadding = reader.ReadUInt32();
                if (vecPadding != 0)
                {
                    Console.WriteLine("WARNING: Vector Padding != 0 ({0:X})!!", vecPadding);
                }
            }

            return(objParam);
        }