-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up logic for caching Dead Space MTLB file paths by ID.
- Loading branch information
1 parent
08983b7
commit 803303a
Showing
12 changed files
with
179 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
FinModelUtility/Formats/Visceral/Visceral/src/api/MtlbFileIdsDictionary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using fin.io; | ||
|
||
using schema.binary; | ||
|
||
namespace visceral.api { | ||
public class MtlbFileIdsDictionary : IReadOnlyFileIdsDictionary { | ||
private readonly IReadOnlyFileIdsDictionary impl_; | ||
|
||
public MtlbFileIdsDictionary(IReadOnlyTreeDirectory baseDirectory, | ||
ISystemFile fileIdsFile) { | ||
|
||
|
||
if (fileIdsFile.Exists) { | ||
this.impl_ = new FileIdsDictionary(baseDirectory, fileIdsFile); | ||
} else { | ||
var impl = new FileIdsDictionary(baseDirectory); | ||
this.impl_ = impl; | ||
foreach (var mtlbFile in baseDirectory.GetFilesWithFileType( | ||
".mtlb", | ||
true)) { | ||
using var br = mtlbFile.OpenReadAsBinary(Endianness.LittleEndian); | ||
br.Position = 8; | ||
var id = br.ReadUInt32(); | ||
impl.AddFile(id, mtlbFile); | ||
} | ||
|
||
this.Save(fileIdsFile); | ||
} | ||
} | ||
|
||
public IEnumerable<IReadOnlyTreeFile> this[uint id] => this.impl_[id]; | ||
|
||
public void Save(IGenericFile fileIdsFile) => this.impl_.Save(fileIdsFile); | ||
} | ||
} |
Oops, something went wrong.