Esempio n. 1
0
        public void Init()
        {
            BCFProvider.Init();
            CFPProvider.Init();

            //scan system for named items

            var allBCFs = BCFProvider.ListGeneric();

            foreach (var bcf in allBCFs)
            {
                var file = (BCF)bcf.GetThrowawayGeneric();
                foreach (var anim in file.Animations)
                {
                    AnimHostBCF[anim.Name.ToLowerInvariant()] = Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/'));
                }
                foreach (var skin in file.Appearances)
                {
                    SkinHostBCF[skin.Name.ToLowerInvariant()] = Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/'));
                }
                foreach (var skel in file.Skeletons)
                {
                    SkelHostBCF.Add(skel.Name.ToLowerInvariant(), Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/')));
                }
            }
        }
Esempio n. 2
0
        public void Init()
        {
            BCFProvider.Init();
            CFPProvider.Init();

            //scan system for named items

            var allBCFs = BCFProvider.ListGeneric();

            foreach (var bcf in allBCFs)
            {
                var file = (BCF)bcf.GetThrowawayGeneric();
                foreach (var anim in file.Animations)
                {
                    AnimHostBCF[anim.Name.ToLowerInvariant()]  = Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/'));
                    AnimRealCase[anim.Name.ToLowerInvariant()] = anim.Name;
                }
                foreach (var skin in file.Appearances)
                {
                    SkinHostBCF[skin.Name.ToLowerInvariant()] = Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/'));
                }
                foreach (var skel in file.Skeletons)
                {
                    SkelHostBCF.Add(skel.Name.ToLowerInvariant(), Path.GetFileName(bcf.ToString().ToLowerInvariant().Replace('\\', '/')));
                }
            }

            foreach (var item in SkinHostBCF.Keys)
            {
                if (char.IsDigit(item[1]) && char.IsDigit(item[2]) && char.IsDigit(item[3]))
                {
                    var uindex = item.IndexOf('_');
                    if (uindex == -1)
                    {
                        uindex = item.Length;
                    }
                    var type = item.Substring(4, uindex - 4);
                    if (type.EndsWith("lgt") || type.EndsWith("med") || type.EndsWith("drk"))
                    {
                        type = type.Substring(0, type.Length - 3);
                    }
                    AddItem(item[0].ToString(), type, item);
                    if ((item[0] == 'b') && (type.EndsWith("fat") || type.EndsWith("fit") || type.EndsWith("skn")))
                    {
                        type = type.Substring(0, type.Length - 3);
                        AddItem(item[0].ToString(), type, item);
                    }
                }
            }
        }
        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>();
                var slots   = file.List <SLOT>();
                if (objects != null)
                {
                    foreach (var obj in objects)
                    {
                        Entries[obj.GUID] = new GameObjectReference(this)
                        {
                            FileName        = Path.GetFileName(iff.ToString().Replace('\\','/')),
                            ID              = obj.GUID,
                            Name            = obj.ChunkLabel,
                            Source          = GameObjectSource.Far,
                            Group           = (short)obj.MasterID,
                            SubIndex        = obj.SubIndex,
                            GlobalSimObject = obj.ObjectType == OBJDType.SimType && obj.Global == 1
                        };
                        if (obj.ObjectType == OBJDType.Person)
                        {
                            PersonGUIDs.Add(obj.GUID);
                        }

                        //does this object appear in the catalog?
                        if ((obj.FunctionFlags > 0 || obj.BuildModeType > 0) && obj.Disabled == 0 && (obj.MasterID == 0 || obj.SubIndex == -1))
                        {
                            //todo: more than one of these set? no normal game objects do this
                            //todo: room sort
                            var cat = (sbyte)Math.Log(obj.FunctionFlags,2);
                            if (obj.FunctionFlags == 0)
                            {
                                cat = (sbyte)(obj.BuildModeType + 7);
                            }
                            var item = new ObjectCatalogItem()
                            {
                                Category     = (sbyte)(cat), //0-7 buy categories. 8-15 build mode categories
                                GUID         = obj.GUID,
                                DisableLevel = 0,
                                Price        = obj.Price,
                                Name         = obj.ChunkLabel,

                                Subsort        = (byte)obj.FunctionSubsort,
                                CommunitySort  = (byte)obj.CommunitySubsort,
                                DowntownSort   = (byte)obj.DTSubsort,
                                MagictownSort  = (byte)obj.MTSubsort,
                                StudiotownSort = (byte)obj.STSubsort,
                                VacationSort   = (byte)obj.VacationSubsort
                            };
                            ItemsByCategory[item.Category].Add(item);
                            ItemsByGUID[item.GUID] = item;
                        }
                    }
                }
            }

            var globalSims = Entries.Values.Where(x => x.GlobalSimObject);

            ControllerObjects.Clear();
            ControllerObjects.AddRange(globalSims);

            ContentManager.Neighborhood.LoadCharacters(false);
        }
Esempio n. 4
0
        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
                        });
                    }
                }
            }
        }