Inheritance: System.IO.BinaryReader
示例#1
0
 public SoundBankFile(SoundBank parent, EndianReader reader)
 {
     ParentBank = parent;
     ID = reader.ReadUInt32();
     Offset = reader.ReadInt32();
     Size = reader.ReadInt32();
 }
示例#2
0
 public SoundPathPoint(EndianReader reader)
 {
     X = reader.ReadSingle();
     reader.Skip(4); // Unknown
     Y = reader.ReadSingle();
     Duration = reader.ReadInt32();
 }
        public SoundBankMusicTrack(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(0xC);
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
示例#4
0
 public SoundPackFile(SoundPack parent, EndianReader reader)
 {
     ParentPack = parent;
     ID = reader.ReadUInt32();
     reader.Skip(4); // Flags?
     Size = reader.ReadInt32();
     Offset = reader.ReadInt32();
     FolderID = reader.ReadInt32();
 }
示例#5
0
        public SoundBankVoice(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(4);
            StorageType = (SoundStorageType)reader.ReadInt32();
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
示例#6
0
        public SoundBankEvent(EndianReader reader, uint id)
        {
            ID = id;

            // Read the action list
            int numActions = reader.ReadInt32();
            ActionIDs = new uint[numActions];
            for (int i = 0; i < numActions; i++)
                ActionIDs[i] = reader.ReadUInt32();
        }
示例#7
0
        public SoundBankAction(EndianReader reader, uint id)
        {
            ID = id;

            Type = (SoundBankActionType)reader.ReadSByte();
            Scope = (SoundBankActionScope)reader.ReadSByte();
            ObjectID = reader.ReadUInt32();

            // TODO: read parameters and state/switch group IDs
        }
示例#8
0
        public StateGroup(EndianReader reader)
        {
            ID = reader.ReadUInt32();
            ChangeMoment = (StateGroupChangeMoment)reader.ReadSByte();

            // Read custom states
            short numCustomStates = reader.ReadInt16();
            CustomStates = new CustomState[numCustomStates];
            for (short i = 0; i < numCustomStates; i++)
                CustomStates[i] = new CustomState(reader);
        }
示例#9
0
        private void ReadFiles(EndianReader reader)
        {
            // The file table comes after the folder list and padding
            reader.SeekTo(FolderListStart + _folderListSize);

            // Align 4
            reader.SeekTo((reader.Position + 3) & ~3);

            // TODO: Load these into separate lists or something to make stuff easier
            ReadFileTable(reader); // Sound banks
            ReadFileTable(reader); // Global files
        }
示例#10
0
        public SoundBankActorMixer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Actor-mixers are just a list of children
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
示例#11
0
        public RTPC(EndianReader reader)
        {
            XAxisParameterID = reader.ReadUInt32();
            YAxisType = (RTPCYAxisType)reader.ReadInt32();

            reader.Skip(5);
            short numPoints = reader.ReadInt16();
            Points = new RTPCPoint[numPoints];

            // Read points
            for (byte i = 0; i < numPoints; i++)
                Points[i] = new RTPCPoint(reader);
        }
        public SoundBankMusicPlaylist(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
        public SoundBankSequenceContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // hax
            reader.Skip(0x18);

            // Read child IDs
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
        public SoundBankMusicSwitchContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            // TODO: this is pretty similar to SoundBankMusicPlaylist,
            // maybe this can be factored out into a common class somehow?
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
示例#15
0
        public Vertex(EndianReader reader, XmlNode formatNode)
            : this()
        {
            if (!formatNode.HasChildNodes)
                throw new NotSupportedException(formatNode.Attributes["type"].Value + ":" + formatNode.Attributes["name"].Value + " has an empty definition.");
            
            var origin = (int)reader.Position;

            foreach (XmlNode val in formatNode.ChildNodes)
            {
                reader.SeekTo(origin + Convert.ToInt32(val.Attributes["offset"].Value, 16));
                Values.Add(new VertexValue(val, reader));
            }

            FormatName = formatNode.Attributes["name"].Value;
        }
示例#16
0
        public SoundInfo(EndianReader reader)
        {
            OverrideParentEffectSettings = (reader.ReadByte() != 0);

            ReadEffects(reader);

            BusID = reader.ReadUInt32();
            ParentID = reader.ReadUInt32();

            OverrideParentPrioritySettings = (reader.ReadByte() != 0);
            OffsetPriorityAtMaxDistance = (reader.ReadByte() != 0);

            byte numParameters = reader.ReadByte();
            // TODO: actually store the parameter values instead of skipping over them
            reader.Skip(numParameters);
            reader.Skip(numParameters * 4);

            sbyte unknownCount = reader.ReadSByte();
            if (unknownCount > 0)
            {
                reader.Skip(unknownCount);
                reader.Skip(unknownCount * 8);
            }

            ReadPositioningInfo(reader);

            // Read auxiliary send settings
            OverrideParentGameDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            UseGameDefinedAuxiliarySends = (reader.ReadByte() != 0);
            OverrideParentUserDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            ReadUserDefinedAuxiliarySends(reader);

            bool unknown = (reader.ReadByte() != 0);
            /*if (unknown)
                reader.Skip(4);*/

            // Read voice settings
            LimitMethod = (SoundLimitMethod)reader.ReadSByte();
            VirtualVoiceBehavior = (SoundVirtualVoiceBehavior)reader.ReadSByte();
            OverrideParentPlaybackLimitSettings = (reader.ReadByte() != 0);
            OverrideParentVirtualVoiceSettings = (reader.ReadByte() != 0);

            ReadStateGroups(reader);
            ReadRTPCs(reader);

            reader.Skip(4); // I think this is part of the sound info data...
        }
示例#17
0
        public Block_0503(EndianReader reader)
            : base(reader, 0x0503)
        {
            reader.ReadInt16(); //0D03
            reader.ReadInt32(); //EOB

            DataCount = reader.ReadInt32();
            unk0 = reader.ReadInt16(); //always 3
            unk1 = reader.ReadByte(); //0, 2 or 3

            if (unk1 != 3)
            {
                for (int i = 0; i < DataCount; i++)
                {
                    var m11 = reader.ReadSingle();
                    var m12 = reader.ReadSingle();
                    var m13 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m21 = reader.ReadSingle();
                    var m22 = reader.ReadSingle();
                    var m23 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m31 = reader.ReadSingle();
                    var m32 = reader.ReadSingle();
                    var m33 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m41 = reader.ReadSingle();
                    var m42 = reader.ReadSingle();
                    var m43 = reader.ReadSingle();
                    reader.ReadSingle(); //1.0f

                    Data.Add(
                        new Matrix4x3(
                            m11, m12, m13,
                            m21, m22, m23,
                            m31, m32, m33,
                            m41, m42, m43));
                }
            }

            //technically not part of the block
            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address
        }
示例#18
0
 private void ReadSeekOffsets(EndianReader reader, int blockSize)
 {
     int numEntries = blockSize / 4; // The block is just an array of uint32s, one for each packet size
     SeekOffsets = new int[numEntries];
     for (int i = 0; i < numEntries; i++)
         SeekOffsets[i] = reader.ReadInt32();
 }
示例#19
0
 private void ReadUserDefinedAuxiliarySends(EndianReader reader)
 {
     HasUserDefinedAuxiliarySends = (reader.ReadByte() != 0);
     if (HasUserDefinedAuxiliarySends)
     {
         AuxiliaryBusIDs = new uint[4];
         for (int i = 0; i < 4; i++)
             AuxiliaryBusIDs[i] = reader.ReadUInt32();
     }
     else
     {
         AuxiliaryBusIDs = new uint[0];
     }
 }
示例#20
0
 private void ReadStateGroups(EndianReader reader)
 {
     int numStateGroups = reader.ReadInt32();
     StateGroups = new StateGroup[numStateGroups];
     for (int i = 0; i < numStateGroups; i++)
         StateGroups[i] = new StateGroup(reader);
 }
示例#21
0
 private void ReadRTPCs(EndianReader reader)
 {
     short numRtpcs = reader.ReadInt16();
     RTPCs = new RTPC[numRtpcs];
     for (short i = 0; i < numRtpcs; i++)
         RTPCs[i] = new RTPC(reader);
 }
示例#22
0
        private void ReadPositioningInfo(EndianReader reader)
        {
            HasPositioning = (reader.ReadByte() != 0);
            if (!HasPositioning)
                return;

            PositionType = (SoundPositionType)reader.ReadByte();
            if (PositionType == SoundPositionType.Position2D)
            {
                EnablePanner = (reader.ReadByte() != 0);
            }
            else
            {
                PositionSourceType = (SoundPositionSourceType)reader.ReadInt32();
                AttenuationID = reader.ReadUInt32();
                EnableSpatialization = (reader.ReadByte() != 0);

                if (PositionSourceType == SoundPositionSourceType.UserDefined)
                {
                    PlayType = (SoundPlayType)reader.ReadInt32();
                    Loop = (reader.ReadByte() != 0);
                    TransitionTime = reader.ReadUInt32();
                    FollowListenerOrientation = (reader.ReadByte() != 0);

                    ReadPaths(reader);
                }
                else if (PositionSourceType == SoundPositionSourceType.GameDefined)
                {
                    UpdateEachFrame = (reader.ReadByte() != 0);
                }
            }
        }
示例#23
0
 private void ReadPaths(EndianReader reader)
 {
     ReadPathPoints(reader);
     ReadPathDefinitions(reader);
     ReadPathRandomness(reader);
 }
示例#24
0
 private void ReadPathRandomness(EndianReader reader)
 {
     PathRandomness = new SoundPathRandomRange[Paths.Length];
     for (int i = 0; i < Paths.Length; i++)
         PathRandomness[i] = new SoundPathRandomRange(reader);
 }
示例#25
0
 private void ReadPathPoints(EndianReader reader)
 {
     int numPathPoints = reader.ReadInt32();
     PathPoints = new SoundPathPoint[numPathPoints];
     for (int i = 0; i < numPathPoints; i++)
         PathPoints[i] = new SoundPathPoint(reader);
 }
示例#26
0
 private void ReadPathDefinitions(EndianReader reader)
 {
     int numPaths = reader.ReadInt32();
     Paths = new SoundPath[numPaths];
     for (int i = 0; i < numPaths; i++)
         Paths[i] = new SoundPath(reader);
 }
示例#27
0
 public RTPCPoint(EndianReader reader)
 {
     X = reader.ReadSingle();
     Y = reader.ReadSingle();
     CurveShape = (RTPCCurveShape)reader.ReadInt32();
 }
示例#28
0
 /// <summary>
 /// Loads RIFX data from a stream.
 /// </summary>
 /// <param name="reader">The EndianReader to read from.</param>
 /// <param name="size">The size of the data to read.</param>
 public RIFX(EndianReader reader, int size)
 {
     ReadHeader(reader);
     ReadBlocks(reader, size);
 }
示例#29
0
        public VertexValue(XmlNode Node, EndianReader reader)
        {
            if (Convert.ToInt32(Node.Attributes["stream"].Value) > 0) throw new NotSupportedException("Multi-streamed vertices not supported");
            Type = (ValueType)Enum.Parse(typeof(ValueType), Node.Attributes["type"].Value);
            Usage = Node.Attributes["usage"].Value;
            UsageIndex = Convert.ToInt32(Node.Attributes["usageIndex"].Value);
            
            switch (Type)
            {
                case ValueType.Float32_2:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_3:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_4:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Int8_N4:
                    Data = new Vector((float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F);
                    break;

                case ValueType.UInt8_2:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), 0, 0);
                    break;

                case ValueType.UInt8_3:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), 0);
                    break;

                case ValueType.UInt8_4:
                    Data = Vector.FromUByte4(reader.ReadUInt32());
                    break;

                case ValueType.UInt8_N2:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0, 0);
                    break;

                case ValueType.UInt8_N3:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0);
                    break;

                case ValueType.UInt8_N4:
                    Data = Vector.FromUByteN4(reader.ReadUInt32());
                    break;

                case ValueType.Int16_N3:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, 0);
                    break;

                case ValueType.Int16_N4:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF);
                    break;

                case ValueType.UInt16_2:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_4:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_N2:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.UInt16_N4:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.DecN4:
                    Data = Vector.FromDecN4(reader.ReadUInt32());
                    break;

                case ValueType.UDecN4:
                    Data = Vector.FromUDecN4(reader.ReadUInt32());
                    break;

                case ValueType.DHenN3:
                    Data = Vector.FromDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.UDHenN3:
                    Data = Vector.FromUDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.HenDN3:
                    Data = Vector.FromHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.UHenDN3:
                    Data = Vector.FromUHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.Float16_2:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.Float16_4:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.D3DColour:
                    reader.ReadUInt32();
                    break;
            }
        }
示例#30
0
 private void ReadEffects(EndianReader reader)
 {
     byte numEffects = reader.ReadByte();
     if (numEffects > 0)
     {
         EffectBypassMask = reader.ReadByte();
         EffectIDs = new uint[numEffects];
         for (byte i = 0; i < numEffects; i++)
         {
             reader.Skip(1); // Effect index, useless
             EffectIDs[i] = reader.ReadUInt32();
             reader.Skip(2);
         }
     }
     else
     {
         EffectIDs = new uint[0];
     }
 }