public void Init() { this.Stations = new List <AudioReference>(); this.StationsById = new Dictionary <uint, AudioReference>(); this.Modes = new List <AudioReference>(); var stationsRegEx = new Regex(@"music\\stations\\.*\.mp3"); foreach (var file in ContentManager.AllFiles) { if (stationsRegEx.IsMatch(file)) { var reference = new AudioReference { Type = AudioType.RADIO_STATION, FilePath = ContentManager.GetPath(file) }; Stations.Add(reference); var idString = Path.GetFileNameWithoutExtension(file); idString = idString.Substring(idString.LastIndexOf("_") + 1); var id = Convert.ToUInt32(idString, 16); reference.ID = id; StationsById.Add(id, reference); } } var tsoAudio = new DBPF(ContentManager.GetPath("TSOAudio.dat")); }
/// <summary> /// Initiates loading of world objects. /// </summary> public void Init() { Iffs = new FAR1Provider <Iff>(ContentManager, new IffCodec(), "objectdata\\objects\\objiff.far"); Sprites = new FAR1Provider <Iff>(ContentManager, new IffCodec(), new Regex(".*\\\\objspf.*\\.far")); TuningTables = new FAR1Provider <OTF>(ContentManager, new OTFCodec(), new Regex(".*\\\\objotf.*\\.far")); Iffs.Init(); TuningTables.Init(); Sprites.Init(); /** Load packingslip **/ Entries = new Dictionary <ulong, GameObjectReference>(); Cache = new Dictionary <ulong, GameObject>(); var packingslip = new XmlDataDocument(); packingslip.Load(ContentManager.GetPath("packingslips\\objecttable.xml")); var objectInfos = packingslip.GetElementsByTagName("I"); foreach (XmlNode objectInfo in objectInfos) { ulong FileID = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); Entries.Add(FileID, new GameObjectReference(this) { ID = FileID, FileName = objectInfo.Attributes["n"].Value }); } }
/// <summary> /// Initiates loading of floors. /// </summary> public void Init() { /** * TODO: We can make this lazy load a bit better. Inside the far archives we * could just keep far entry pointers rather than processing them. Assuming each file * in the far only contains 1 floor style. If its variable this may not be possible */ this.ById = new Dictionary <ushort, Floor>(); this.Floors = new List <Floor>(); var floorGlobalsPath = ContentManager.GetPath("objectdata/globals/floors.iff"); var floorGlobals = new Iff(floorGlobalsPath); /** There is a small handful of floors in a global file for some reason **/ ushort floorID = 1; for (ushort i = 1; i < 30; i++) { var far = floorGlobals.Get <SPR2>(i); var medium = floorGlobals.Get <SPR2>((ushort)(i + 256)); var near = floorGlobals.Get <SPR2>((ushort)(i + 512)); this.AddFloor(new Floor { ID = floorID, Far = far, Medium = medium, Near = near }); floorID++; } floorID = 256; var archives = new string[] { "housedata/floors/floors.far", "housedata/floors2/floors2.far", "housedata/floors3/floors3.far", "housedata/floors4/floors4.far" }; for (var i = 0; i < archives.Length; i++) { var archivePath = ContentManager.GetPath(archives[i]); var archive = new FAR1Archive(archivePath); var entries = archive.GetAllEntries(); foreach (var entry in entries) { var iff = new Iff(); var bytes = archive.GetEntry(entry); using (var stream = new MemoryStream(bytes)) { iff.Read(stream); } var far = iff.Get <SPR2>(1); var medium = iff.Get <SPR2>(257); var near = iff.Get <SPR2>(513); AddFloor(new Floor { ID = floorID, Near = near, Medium = medium, Far = far }); floorID++; } } }