mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Use HashSet to store texture guids instead of List
This commit is contained in:
parent
ef87606ba2
commit
b39038008d
1 changed files with 6 additions and 12 deletions
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Immutable;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Resources;
|
||||
|
@ -8,11 +7,10 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
|||
|
||||
public static class GameResourceHelper
|
||||
{
|
||||
private static readonly ImmutableList<string> textureGuids = ImmutableList<string>.Empty;
|
||||
private static readonly HashSet<string> textureGuids = new();
|
||||
|
||||
static GameResourceHelper()
|
||||
{
|
||||
List<string> guids = new();
|
||||
using Stream? guidStream = typeof(GameResourceHelper).Assembly.GetManifestResourceStream("LBPUnion.ProjectLighthouse.Servers.GameServer.textureGuids.txt");
|
||||
if (guidStream == null)
|
||||
{
|
||||
|
@ -26,21 +24,17 @@ public static class GameResourceHelper
|
|||
string? guid = reader.ReadLine();
|
||||
if (guid == null) continue;
|
||||
|
||||
guids.Add(guid);
|
||||
textureGuids.Add(guid);
|
||||
}
|
||||
textureGuids = ImmutableList.Create(guids.ToArray());
|
||||
}
|
||||
|
||||
public static bool IsValidTexture(string resource)
|
||||
{
|
||||
if (!FileHelper.IsResourceValid(resource)) return false;
|
||||
|
||||
if (resource.StartsWith("g"))
|
||||
{
|
||||
return textureGuids.Contains(resource[1..]);
|
||||
}
|
||||
if (resource.StartsWith("g")) return textureGuids.Contains(resource[1..]);
|
||||
|
||||
return LbpFile.FromHash(resource)?.FileType is LbpFileType.Png or LbpFileType.Jpeg or LbpFileType.Plan
|
||||
or LbpFileType.Painting or LbpFileType.Texture;
|
||||
return LbpFile.FromHash(resource)?.FileType is LbpFileType.Png or LbpFileType.Jpeg or LbpFileType.Painting
|
||||
or LbpFileType.Texture;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue