private void LoadMap(int worldIndex, int placeIndex) { Log.Info($"Map={worldIndex},{placeIndex}"); var fileName = Kernel.GetMapFileName(worldIndex, placeIndex); var entries = _dataContent.FileOpen(fileName).Using(Bar.Read); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "SK0")); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "SK1")); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "MAP")); _bobEntities = entries.ForEntry("out", Bar.EntryType.BgObjPlacement, BobDescriptor.Read)? .Select(x => new BobEntity(x))?.ToList() ?? new List <BobEntity>(); var bobModels = entries.ForEntries("BOB", Bar.EntryType.Model, Mdlx.Read).ToList(); var bobTextures = entries.ForEntries("BOB", Bar.EntryType.ModelTexture, ModelTexture.Read).ToList(); for (var i = 0; i < bobModels.Count; i++) { _bobModels.Add(new MeshGroup { MeshDescriptors = MeshLoader.FromKH2(bobModels[i]).MeshDescriptors, Textures = bobTextures[i].LoadTextures(_graphics.GraphicsDevice).ToArray() }); } }
public Kh2Map(GraphicsDevice graphics, IDataContent content, string path) { _graphics = graphics; var binarc = content.FileOpen(path).Using(Bar.Read); _skybox0MeshGroup = FromMdlx(graphics, binarc, "SK0") ?? Empty; _skybox1MeshGroup = FromMdlx(graphics, binarc, "SK1") ?? Empty; _mapMeshGroup = FromMdlx(graphics, binarc, "MAP") ?? Empty; _bobEntities = binarc.ForEntry("out", Bar.EntryType.BgObjPlacement, BobDescriptor.Read)? .Select(x => new BobEntity(x))?.ToList() ?? new List <BobEntity>(); var bobModels = binarc.ForEntries("BOB", Bar.EntryType.Model, Mdlx.Read).ToList(); var bobTextures = binarc.ForEntries("BOB", Bar.EntryType.ModelTexture, ModelTexture.Read).ToList(); _bobModels = new List <MeshGroup>(bobModels.Count); for (var i = 0; i < bobModels.Count; i++) { _bobModels.Add(new MeshGroup { MeshDescriptors = MeshLoader.FromKH2(bobModels[i]).MeshDescriptors, Textures = bobTextures[i].LoadTextures(graphics).ToArray() }); } }
private void LoadObjEntry(string name) { var model = _kernel.ObjEntries.FirstOrDefault(x => x.ModelName == name); if (model == null) { return; } var fileName = $"obj/{model.ModelName}.mdlx"; using var stream = _dataContent.FileOpen(fileName); var entries = Bar.Read(stream); var modelEntryName = entries.FirstOrDefault(x => x.Type == Bar.EntryType.Model)?.Name; _archiveManager.LoadArchive(entries); AddMesh(FromMdlx(_graphics.GraphicsDevice, _archiveManager, modelEntryName, "tim_")); }
public Stream FileOpen(string fileName) { var stream = _innerDataContext.FileOpen(fileName); if (stream == null) { return(null); } return(HdAsset.Read(stream).Stream); }
public IdxMultipleDataContent(IDataContent baseDataContent, Stream imgStream) { var dataContents = Constants.WorldIds .Select(worldId => $"000{worldId}.idx") .Select(fileName => baseDataContent.FileOpen(fileName)) .Where(stream => stream != null) .Select(stream => stream.Using(s => new IdxDataContent(s, imgStream))) .ToArray(); _dataContent = new MultipleDataContent(dataContents); }
public Stream FileOpen(string fileName) { var stream = _innerDataContext.FileOpen(fileName); if (stream == null) { throw new FileNotFoundException(fileName); } return(stream); }
private void LoadMap(int worldIndex, int placeIndex) { Log.Info($"Map={worldIndex},{placeIndex}"); string fileName; if (_kernel.IsReMix) { fileName = $"map/{Constants.WorldIds[worldIndex]}{placeIndex:D02}.map"; } else { fileName = $"map/{_kernel.Language}/{Constants.WorldIds[worldIndex]}{placeIndex:D02}.map"; } var entries = _dataContent.FileOpen(fileName).Using(Bar.Read); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "SK0")); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "SK1")); AddMesh(FromMdlx(_graphics.GraphicsDevice, entries, "MAP")); _bobEntities = entries.ForEntry("out", Bar.EntryType.BobDescriptor, BobDescriptor.Read)? .Select(x => new BobEntity(x))?.ToList() ?? new List <BobEntity>(); var bobModels = entries.ForEntries("BOB", Bar.EntryType.Model, Mdlx.Read).ToList(); var bobTextures = entries.ForEntries("BOB", Bar.EntryType.ModelTexture, ModelTexture.Read).ToList(); for (var i = 0; i < bobModels.Count; i++) { var bobMesh = MeshLoader.FromKH2(_graphics.GraphicsDevice, bobModels[i], bobTextures[i]); if (bobMesh != null) { _bobModels.Add(bobMesh); } } }
private T LoadFile <T>(string fileName, Func <Stream, T> action) { using var stream = _dataContent.FileOpen(fileName); return(action(stream)); }