Пример #1
0
        /// <summary>
        /// Loads all Available Description Files in the Package
        /// </summary>
        protected void LoadDescriptions()
        {
            bysimid    = new Hashtable();
            byinstance = new Hashtable();
            bool didwarndoubleguid = false;

            if (BasePackage == null)
            {
                return;
            }

            IPackedFileDescriptor[] files = BasePackage.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE);

            foreach (IPackedFileDescriptor pfd in files)
            {
                //SDesc sdesc = new SDesc(this.names, this.famnames, this);
                LinkedSDesc sdesc = new LinkedSDesc();
                sdesc.ProcessData(pfd, BasePackage);

                if (bysimid.ContainsKey((uint)sdesc.SimId) || byinstance.ContainsKey((ushort)sdesc.Instance))
                {
                    if (!didwarndoubleguid)
                    {
                        Helper.ExceptionMessage(new Warning("A Sim was found Twice!", "The Sim with GUID 0x" + Helper.HexString(sdesc.SimId) + " (inst=0x" + Helper.HexString(sdesc.Instance) + ") exists more than once. This could result in  Problems during the Gameplay!"));
                        didwarndoubleguid = true;
                    }
                }

                bysimid[(uint)sdesc.SimId]         = sdesc;
                byinstance[(ushort)sdesc.Instance] = sdesc;
            }
        }
Пример #2
0
        /// <summary>
        /// Loads all package Files in the directory and scans them for Name Informations
        /// </summary>
        public void LoadSimsFromFolder()
        {
            names = new Hashtable();
            if (BasePackage == null)
            {
                return;
            }

            SimPe.PackedFiles.Wrapper.Fami fami = new SimPe.PackedFiles.Wrapper.Fami(null);
            Hashtable al = new Hashtable();

            foreach (uint type in fami.AssignableTypes)
            {
                IPackedFileDescriptor[] list = BasePackage.FindFiles(type);

                foreach (IPackedFileDescriptor pfd in list)
                {
                    fami.ProcessData(pfd, BasePackage);
                    al[(ushort)pfd.Instance] = fami.Name;

                    foreach (uint simid in fami.Members)
                    {
                        Alias a = new Alias(simid, fami.Name);
                        if (!names.Contains(simid))
                        {
                            names.Add(simid, a);
                        }
                    }
                }
            }            //foreach

            ///add unlisted Sims
            foreach (SimPe.PackedFiles.Wrapper.SDesc sdesc in FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance.Values)
            {
                //load extern Fami Name
                if (!names.Contains(sdesc.SimId))
                {
                    if (sdesc.Package.SaveFileName.Trim().ToLower() != BasePackage.SaveFileName.Trim().ToLower())
                    {
                        SimPe.Interfaces.Files.IPackageFile pkg = sdesc.Package;
                        if (pkg != null)
                        {
                            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(fami.AssignableTypes[0], 0, Data.MetaData.LOCAL_GROUP, sdesc.FamilyInstance);
                            if (pfd != null)
                            {
                                fami.ProcessData(pfd, pkg);
                                Alias a = new Alias(sdesc.SimId, fami.Name);
                                names.Add(sdesc.SimId, a);
                            }
                        }
                    }
                    else
                    {
                        object o = al[sdesc.FamilyInstance];
                        if (o != null)
                        {
                            Alias a = new Alias(sdesc.SimId, o.ToString());
                            names.Add(sdesc.SimId, a);
                        }
                    }
                }
            }

            al.Clear();

            /*names = new Alias[al.Count];
             * al.CopyTo(names);*/
        }