Example #1
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                Interactions = new TTABInteraction[io.ReadUInt16()];
                var version = io.ReadUInt16();
                IOProxy iop;
                if (version != 9 && version != 10) iop = new TTABNormal(io);
                else iop = new TTABFieldEncode(io); //haven't guaranteed that this works, since none of the objects in the test lot use it.

                for (int i = 0; i < Interactions.Length; i++)
                {
                    var result = new TTABInteraction();
                    result.ActionFunction = iop.ReadUInt16();
                    result.TestFunction = iop.ReadUInt16();
                    result.MotiveEntries = new TTABMotiveEntry[iop.ReadUInt32()];
                    result.Flags = iop.ReadUInt32();
                    result.TTAIndex = iop.ReadUInt32();
                    if (version > 6) result.AttenuationCode = iop.ReadUInt32();
                    result.AttenuationValue = iop.ReadFloat();
                    result.AutonomyThreshold = iop.ReadUInt32();
                    result.JoiningIndex = iop.ReadInt32();
                    for (int j = 0; j < result.MotiveEntries.Length; j++)
                    {
                        var motive = new TTABMotiveEntry();
                        if (version > 6) motive.EffectRangeMinimum = iop.ReadInt16();
                        motive.EffectRangeMaximum = iop.ReadInt16();
                        if (version > 6) motive.PersonalityModifier = iop.ReadUInt16();
                        result.MotiveEntries[j] = motive;
                    }
                    if (version > 9) result.Unknown = iop.ReadUInt32();
                    Interactions[i] = result;
                }
            }
        }
Example #2
0
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         Interactions = new TTABInteraction[io.ReadUInt16()];
         var     version = io.ReadUInt16();
         IOProxy iop;
         if (version != 9 && version != 10)
         {
             iop = new TTABNormal(io);
         }
         else
         {
             iop = new TTABFieldEncode(io);  //haven't guaranteed that this works, since none of the objects in the test lot use it.
         }
         for (int i = 0; i < Interactions.Length; i++)
         {
             var result = new TTABInteraction();
             result.ActionFunction = iop.ReadUInt16();
             result.TestFunction   = iop.ReadUInt16();
             result.MotiveEntries  = new TTABMotiveEntry[iop.ReadUInt32()];
             result.Flags          = iop.ReadUInt32();
             result.TTAIndex       = iop.ReadUInt32();
             if (version > 6)
             {
                 result.AttenuationCode = iop.ReadUInt32();
             }
             result.AttenuationValue  = iop.ReadFloat();
             result.AutonomyThreshold = iop.ReadUInt32();
             result.JoiningIndex      = iop.ReadInt32();
             for (int j = 0; j < result.MotiveEntries.Length; j++)
             {
                 var motive = new TTABMotiveEntry();
                 if (version > 6)
                 {
                     motive.EffectRangeMinimum = iop.ReadInt16();
                 }
                 motive.EffectRangeMaximum = iop.ReadInt16();
                 if (version > 6)
                 {
                     motive.PersonalityModifier = iop.ReadUInt16();
                 }
                 result.MotiveEntries[j] = motive;
             }
             if (version > 9)
             {
                 result.Unknown = iop.ReadUInt32();
             }
             Interactions[i] = result;
         }
     }
 }