Example #1
0
        /// <summary>
        /// Returns the Description File for the passed Sim id
        /// </summary>
        /// <param name="simid">id of the Sim</param>
        /// <returns>The Description file for the Sim</returns>
        /// <remarks>
        /// If the Description file does not exist in
        /// the current Package, it will be added!
        /// </remarks>
        /// <exception cref="Exception">Thrown when ProcessData was not called.</exception>
        public SDesc GetDescriptionFile(uint simid)
        {
            if (package == null)
            {
                throw new Exception("No package loaded!");
            }

            SDesc sdesc = SDesc.FindForSimId(simid, package);

            if (sdesc == null)
            {
                sdesc       = new SDesc(null, null, null);
                sdesc.SimId = simid;
                sdesc.CharacterDescription.Age = 28;

                IPackedFileDescriptor[] files = package.FindFiles(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE);
                sdesc.Instance = 0;
                foreach (IPackedFileDescriptor pfd in files)
                {
                    if (pfd.Instance > sdesc.Instance)
                    {
                        sdesc.Instance = (ushort)pfd.Instance;
                    }
                }
                sdesc.Instance++;

                IPackedFileDescriptor fd = package.Add(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE, 0x0, FileDescriptor.Group, sdesc.Instance);
                sdesc.Save(fd);
            }

            return(sdesc);
        }