public void LoadFile(string file) { var bundle = VfsManager.CreateBundle(Path.GetFileName(file)); var reader = new MWBundleReader(file, null); reader.Read(); }
public override void Init() { var locBundle = VfsManager.CreateBundle("LocationBundle"); var mapStream = VfsManager.CreateBundle("MapStream"); VfsManager.Instance.MountBundle("/tracks", locBundle); VfsManager.Instance.MountBundle("/tracks", mapStream); LocBundleId = locBundle.ID; MapStreamId = mapStream.ID; }
public void LoadMapStream() { var bundleFile = Path.Combine(_directory, "TRACKS", "L2RA.BUN"); var streamFile = Path.Combine(_directory, "TRACKS", "STREAML2RA.BUN"); var msr = new MWMapStreamReader( bundleFile, streamFile ); msr.Init(); msr.Read(); var sections = msr.GetSections(); foreach (var section in sections) { var sectionBundle = VfsManager.CreateBundle(section.Name); Console.WriteLine($"Reading section: {section.Name} @ 0x{section.Offset:X8}"); // Create a new reader var reader = new MWBundleReader(streamFile, new BundleReadOptions { StartPosition = section.Offset, EndPosition = section.Offset + section.Size }); var resources = reader.Read(); foreach (var resource in resources) { if (resource is TexturePack tpk) { sectionBundle.MountResource(VfsManager.CreateTexturePackResource(tpk)); } } VfsManager.Instance .FindBundle(msr.MapStreamId) .MountBundle(sectionBundle); } }
public static unsafe void Main(string[] args) { // VFS testing { var vfsManager = VfsManager.Instance; var bundle1 = VfsManager.CreateBundle("TestBundle"); var bundle2 = VfsManager.CreateBundle("TestBundle2"); var bundle3 = VfsManager.CreateBundle("TestBundle3"); bundle1.MountResource(VfsManager.CreateTexturePackResource()); bundle1.MountResource(VfsManager.CreateTexturePackResource()); bundle3.MountResource(VfsManager.CreateTexturePackResource()); vfsManager.MountBundle("/", bundle1); vfsManager.MountBundle("/Global", bundle1); vfsManager.MountBundle("/Global", bundle2); vfsManager.MountBundle("/Global/Test", bundle3); vfsManager.UnmountBundle($"/Global/Test/{bundle3.ID}"); } if (args.Length > 0) { // GameManager testing var gameManager = GameManager.Instance; gameManager.LoadGame(args[0]); if (args.Length > 1) { gameManager.GetLoader().LoadFile(args[1]); //Console.ReadKey(); } else { gameManager.GetLoader().LoadMapStream(); //Console.ReadKey(); //gameManager.GetLoader().LoadDatabase(); } } }
public void TestMounting() { var vfsManager = VfsManager.Instance; var bundle1 = VfsManager.CreateBundle("TestBundle1"); var testTpk1 = VfsManager.CreateTexturePackResource(); var bundle2 = VfsManager.CreateBundle("TestBundle2"); var testTpk2 = VfsManager.CreateTexturePackResource(); var bundle3 = VfsManager.CreateBundle("TestBundle3"); bundle1.MountResource(testTpk1); bundle2.MountResource(testTpk1); bundle2.MountResource(testTpk2); var bundle2Child = VfsManager.CreateBundle("Bundle2_Child"); bundle2Child.MountResource(testTpk1); bundle2.MountBundle(bundle2Child); vfsManager.MountBundle("/", bundle1); vfsManager.MountBundle("/test", bundle2); vfsManager.MountBundle("/test/nested/paths", bundle3); Assert.True(vfsManager.FindBundle(bundle1.ID, out _)); Assert.True(vfsManager.FindResource <TexturePackResource>(testTpk1.ID, out _)); Assert.Throws <Exception>(() => vfsManager.MountBundle("/", bundle1)); Assert.True(vfsManager.FindBundle(bundle2.ID, out _)); Assert.True(vfsManager.FindBundle(bundle3.ID, out _)); vfsManager.UnmountBundle($"/test/nested/paths/{bundle3.ID}"); Assert.False(vfsManager.FindBundle(bundle3.ID, out _)); // Assert.True(true); }