Esempio n. 1
0
 public void Read(IStream s, uint version)
 {
     if (version <= Kfm.VER_KFM_1_2_4b)
     {
         action_name = Nif.ReadString(s);
     }
     action_filename = Nif.ReadString(s);
     unk_int1        = Nif.ReadUInt(s);
     events          = new KfmEvent[Nif.ReadUInt(s)]; //: .Resize
     foreach (var it in events)
     {
         it.Read(s, version);
     }
     unk_int2 = Nif.ReadUInt(s);
 }
Esempio n. 2
0
 public void Read(IStream s, uint version)
 {
     unk_int = Nif.ReadUInt(s);
     event_  = Nif.ReadString(s);
 }
Esempio n. 3
0
        public uint Read(IStream s) // returns Kfm version
        {
            //--Read Header--//
            var header_string = new byte[64];
            var headerstr     = s.GetLine(header_string, 64);

            // make sure this is a KFM file
            if (headerstr.Substring(0, 26) != ";Gamebryo KFM File Version")
            {
                version = Nif.VER_INVALID;
                return(version);
            }
            // supported versions
            if (headerstr == ";Gamebryo KFM File Version 2.0.0.0b")
            {
                version = VER_KFM_2_0_0_0b;
            }
            else if (headerstr == ";Gamebryo KFM File Version 1.2.4b")
            {
                version = VER_KFM_1_2_4b;
            }
            //else if ( headerstr == ";Gamebryo KFM File Version 1.0" ) version = VER_KFM_1_0;
            //else if ( headerstr == ";Gamebryo KFM File Version 1.0\r" ) version = VER_KFM_1_0; // Windows eol style
            else
            {
                version = Nif.VER_UNSUPPORTED;
                return(version);
            }
            //--Read remainder--//
            if (version == VER_KFM_1_0)
            {
                // TODO write a parser
            }
            else
            {
                if (version >= VER_KFM_2_0_0_0b)
                {
                    unk_byte = Nif.ReadByte(s);
                }
                else
                {
                    unk_byte = 1;
                }
                nif_filename = Nif.ReadString(s);
                master       = Nif.ReadString(s);
                unk_int1     = Nif.ReadUInt(s);
                unk_int2     = Nif.ReadUInt(s);
                unk_float1   = Nif.ReadFloat(s);
                unk_float2   = Nif.ReadFloat(s);
                actions      = new KfmAction[Nif.ReadUInt(s)]; //: .Resize(
                unk_int3     = Nif.ReadUInt(s);
                foreach (var it in actions)
                {
                    it.Read(s, version);
                }
            }

            // Retrieve action names
            if (version >= VER_KFM_2_0_0_0b)
            {
                var model_name = nif_filename.Substring(0, nif_filename.Length - 4); // strip .nif extension
                foreach (var it in actions)
                {
                    var action_name = it.action_filename.Substring(0, it.action_filename.Length - 3); // strip .kf extension
                    if (action_name.IndexOf(model_name + "_") == 0)
                    {
                        action_name = action_name.Substring(model_name.Length + 1);
                    }
                    if (action_name.IndexOf(master + "_") == 0)
                    {
                        action_name = action_name.Substring(master.Length + 1);
                    }
                    it.action_name = action_name;
                }
            }
            return(version);
        }