コード例 #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('\\', '/')));
                }
            }
        }
コード例 #2
0
        public void InitTS1()
        {
            var floorGlobalsPath = Path.Combine(ContentManager.TS1BasePath, "GameData/floors.iff");
            var floorGlobals     = new IffFile(floorGlobalsPath);

            FloorGlobals = floorGlobals;

            var buildGlobalsPath = Path.Combine(ContentManager.TS1BasePath, "GameData/Build.iff");

            BuildGlobals = new IffFile(buildGlobalsPath); //todo: centralize?

            InitGlobals();

            //load *.flr iffs from both the TS1 provider and folder

            ushort floorID = 256;
            var    files   = new FileProvider <IffFile>(ContentManager, new IffCodec(), new Regex(".*/Floors.*\\.flr"));

            files.UseTS1 = true;
            var ts1 = new TS1SubProvider <IffFile>(ContentManager.TS1Global, ".flr");

            files.Init();
            ts1.Init();
            var compo = new CompositeProvider <IffFile>(new List <IContentProvider <IffFile> >()
            {
                ts1,
                files
            });

            Floors = compo;
            var all = compo.ListGeneric();

            foreach (var entry in all)
            {
                var iff = (IffFile)entry.GetThrowawayGeneric();
                DynamicFloorFromID[Path.GetFileNameWithoutExtension(entry.ToString().Replace('\\', '/')).ToLowerInvariant()] = floorID;
                var catStrings = iff.Get <STR>(0);

                Entries.Add(floorID, new FloorReference(this)
                {
                    ID       = floorID,
                    FileName = Path.GetFileName(entry.ToString().Replace('\\', '/')).ToLowerInvariant(),

                    Name        = catStrings.GetString(0),
                    Price       = int.Parse(catStrings.GetString(1)),
                    Description = catStrings.GetString(2)
                });

                floorID++;
            }
            NumFloors = floorID;
        }
コード例 #3
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);
                    }
                }
            }
        }
コード例 #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>();
                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);
        }
コード例 #5
0
        public void Init()
        {
            //somewhat different from TSO audio - need to scan content for .hot files, then load them all
            //hot contains EVT, tracks, hitlists and patches...
            //...which are added to our global database.

            WAVSounds.Init();
            MP3Sounds.Init();
            XASounds.Init();
            UTKSounds.Init();

            var FilePattern = new Regex(@".*\.hot");

            List <string> matchedFiles = new List <string>();

            foreach (var file in ContentManager.TS1AllFiles)
            {
                if (FilePattern.IsMatch(file.Replace('\\', '/')))
                {
                    matchedFiles.Add(file);
                }
            }
            foreach (var file in matchedFiles)
            {
                //load associated HIT, HSM
                var cFile = Path.Combine(ContentManager.TS1BasePath, file);
                var bPath = cFile.Substring(0, cFile.Length - 4); //path without .hot extension

                var hsm = new HSM(PathCaseTools.Insensitive(bPath + ".hsm"));
                var hit = new HITFile(PathCaseTools.Insensitive(bPath + ".hit"));
                var hot = new Hot(cFile, hsm);

                var group = new HITResourceGroup()
                {
                    hsm = hsm, hit = hit, hot = hot
                };

                foreach (var trk in hot.Tracks)
                {
                    if (TracksById.ContainsKey(trk.Key) && TracksById[trk.Key].SubroutineID != trk.Value.SubroutineID)
                    {
                    }
                    TracksById[trk.Key] = trk.Value;
                }

                foreach (var patch in hot.Patches)
                {
                    if (PatchesById.ContainsKey(patch.Key) && patch.Value.Filename != PatchesById[patch.Key].Filename)
                    {
                    }
                    PatchesById[patch.Key] = patch.Value;
                }

                foreach (var hls in hot.Hitlists)
                {
                    if (HitlistsById.ContainsKey(hls.Key) && HitlistsById[hls.Key].IDs.Count != hls.Value.IDs.Count)
                    {
                    }
                    HitlistsById[hls.Key] = hls.Value;
                }

                foreach (var evt in hot.Events)
                {
                    _Events[evt.Key] = new HITEventRegistration()
                    {
                        Name      = evt.Value.Name,
                        EventType = (FSO.Files.HIT.HITEvents)evt.Value.EventType,
                        TrackID   = evt.Value.TrackID,
                        ResGroup  = group
                    };
                }
            }
            var musics   = Events.Where(x => x.Value.EventType == HITEvents.kSetMusicMode).Select(x => x.Key + ": " + x.Value.TrackID).ToList();
            var stations = Events.Where(x => x.Value.EventType == HITEvents.kTurnOnTV).Select(x => x.Key + ": " + x.Value.TrackID.ToString()).ToList();
            //.Select(x => x.Key + ": " + new string(new char[] { (char)(x.Value.TrackID & 0xFF), (char)((x.Value.TrackID >> 8) & 0xFF), (char)((x.Value.TrackID >> 16) & 0xFF), (char)((x.Value.TrackID >> 24) & 0xFF) })).ToList();
        }
コード例 #6
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
                        });
                    }
                }
            }
        }