All checks were successful
Build and Release / Build (push) Successful in 25s
37 lines
1.7 KiB
C#
37 lines
1.7 KiB
C#
using Dalamud.Game;
|
|
using Lumina.Excel.Sheets;
|
|
using Lumina.Extensions;
|
|
using System;
|
|
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
|
|
namespace Glamaholic {
|
|
internal class DataCache {
|
|
public static Lazy<ImmutableList<Item>> EquippableItems { get; } =
|
|
new(() => Service.DataManager.GetExcelSheet<Item>(ClientLanguage.English)!
|
|
.Where(row => row.EquipSlotCategory.RowId != 0 &&
|
|
row.EquipSlotCategory.Value!.SoulCrystal == 0)
|
|
.ToImmutableList());
|
|
|
|
public static Lazy<ImmutableDictionary<string, byte>> StainLookup { get; } =
|
|
new (() =>
|
|
Service.DataManager.GetExcelSheet<Stain>(ClientLanguage.English)!
|
|
.Where(static row => row.RowId != 0 && !row.Name.IsEmpty)
|
|
.ToImmutableDictionary(static row =>
|
|
row.Name.ExtractText().Trim().ToLower(), static row => (byte) row.RowId));
|
|
|
|
public static Lazy<ImmutableList<(byte Id, string Name, uint Color, bool Gloss)>> AllStains { get; } =
|
|
new(() => Service.DataManager.GetExcelSheet<Stain>(ClientLanguage.English)!
|
|
.Where(row => row.RowId != 0 && !row.Name.IsEmpty)
|
|
.Select(row => ((byte)row.RowId, row.Name.ExtractText(), SeColorToRgba(row.Color), row.IsMetallic))
|
|
.ToImmutableList());
|
|
|
|
// Convert SE's BGR color format to RGBA
|
|
private static uint SeColorToRgba(uint color)
|
|
=> ((color & 0xFF) << 16) | ((color >> 16) & 0xFF) | (color & 0xFF00) | 0xFF000000;
|
|
|
|
public static int GetNumStainSlots(uint itemId) =>
|
|
Service.DataManager.GetExcelSheet<Item>(ClientLanguage.English)!.GetRowOrDefault(itemId)?.DyeCount ?? 0;
|
|
}
|
|
}
|