public void LoadCharacters(bool clearLast)
        {
            var objs = (TS1ObjectProvider)ContentManager.WorldObjects;

            if (objs.Entries == null)
            {
                return;
            }
            if (clearLast)
            {
                foreach (var obj in objs.Entries.Where(x => x.Value.Source == GameObjectSource.User))
                {
                    objs.RemoveObject((uint)obj.Key);
                    objs.PersonGUIDs.Add((uint)obj.Key);
                }
            }

            NextSim = 0;
            var path  = Path.Combine(UserPath, "Characters/");
            var files = Directory.EnumerateFiles(path);

            foreach (var filename in files)
            {
                if (Path.GetExtension(filename) != ".iff")
                {
                    return;
                }

                int userID;
                var name = Path.GetFileName(filename);
                if (name.Length > 8 && int.TryParse(name.Substring(4, 5), out userID) && userID >= NextSim)
                {
                    NextSim = userID + 1;
                }

                var file = new IffFile(filename);
                file.MarkThrowaway();

                var objects = file.List <OBJD>();
                if (objects != null)
                {
                    foreach (var obj in objects)
                    {
                        objs.Entries[obj.GUID] = new GameObjectReference(objs)
                        {
                            FileName = filename,
                            ID       = obj.GUID,
                            Name     = obj.ChunkLabel,
                            Source   = GameObjectSource.User,
                            Group    = (short)obj.MasterID,
                            SubIndex = obj.SubIndex
                        };
                        if (obj.ObjectType == OBJDType.Person)
                        {
                            objs.PersonGUIDs.Add(obj.GUID);
                        }
                    }
                }
            }
        }
        public void Init()
        {
            GameObjects.Init();

            Entries = new Dictionary<ulong, GameObjectReference>();
            Cache = new TimedReferenceCache<ulong, GameObject>();

            ItemsByGUID = new Dictionary<uint, ObjectCatalogItem>();
            ItemsByCategory = new List<ObjectCatalogItem>[30];
            for (int i = 0; i < 30; i++) ItemsByCategory[i] = new List<ObjectCatalogItem>();

            var allIffs = GameObjects.ListGeneric();
            foreach (var iff in allIffs)
            {
                var file = (IffFile)iff.GetThrowawayGeneric();
                file.MarkThrowaway();
                var objects = file.List<OBJD>();
                if (objects != null)
                {
                    foreach (var obj in objects)
                    {
                        Entries.Add(obj.GUID, new GameObjectReference(this)
                        {
                            FileName = iff.ToString(),
                            ID = obj.GUID,
                            Name = obj.ChunkLabel,
                            Source = GameObjectSource.Far,
                            Group = (short)obj.MasterID,
                            SubIndex = obj.SubIndex
                        });

                        //does this object appear in the catalog?
                        if (obj.FunctionFlags > 0 && (obj.MasterID == 0 || obj.SubIndex == -1))
                        {
                            var cat = (sbyte)Math.Log(obj.FunctionFlags, 2);
                            var item = new ObjectCatalogItem()
                            {
                                Category = (sbyte)(cat + 11), //debug for now
                                GUID = obj.GUID,
                                DisableLevel = 0,
                                Price = obj.Price,
                                Name = obj.ChunkLabel
                            };
                            ItemsByCategory[item.Category].Add(item);
                            ItemsByGUID[item.GUID] = item;
                        }
                    }
                }
            }

            var path = Path.Combine(ContentManager.TS1BasePath, "UserData/Characters/");
            var files = Directory.EnumerateFiles(path);
            foreach (var filename in files)
            {
                if (Path.GetExtension(filename) != ".iff") return;
                var file = new IffFile(filename);
                file.MarkThrowaway();
                var objects = file.List<OBJD>();
                if (objects != null)
                {
                    foreach (var obj in objects)
                    {
                        Entries.Add(obj.GUID, new GameObjectReference(this)
                        {
                            FileName = filename,
                            ID = obj.GUID,
                            Name = obj.ChunkLabel,
                            Source = GameObjectSource.Standalone,
                            Group = (short)obj.MasterID,
                            SubIndex = obj.SubIndex
                        });
                    }
                }
            }
        }