NominaOcculta/NominaOcculta/AppearanceRepository.cs

67 lines
1.7 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Logging;
using Lumina.Excel.GeneratedSheets;
namespace NominaOcculta;
internal class AppearanceRepository {
private Plugin Plugin { get; }
private List<ENpcBase> Npcs { get; }
private int Salt { get; } = new Random().Next();
private static readonly string[] Exclude = {
"Thancred",
"Y'shtola",
"Alphinaud",
"Alisaie",
"Urianger",
"Tataru",
"Minfilia",
"Lyse",
"Yda",
"Papalymo",
"Krile",
"Ryne",
"Estinien",
"Nanamo Ul Namo",
"G'raha Tia",
"Raubahn",
"Cid",
"Biggs",
"Wedge",
"Haurchefant",
"Merlwyb",
"Kan-E-Senna",
"Yugiri",
"Aymeric",
"Lahabrea",
"Igeyorhm",
"Hildibrand",
"Godbert",
};
internal AppearanceRepository(Plugin plugin) {
this.Plugin = plugin;
var names = this.Plugin.DataManager.GetExcelSheet<ENpcResident>()!;
this.Npcs = this.Plugin.DataManager.GetExcelSheet<ENpcBase>()!
.Where(row => row.BodyType == 1)
.Where(row => row.ModelChara.Row == 0)
.Where(row => row.ModelBody != 0)
.Where(row => row.ModelLegs != 0)
.Where(row => !Exclude.Contains(names.GetRow(row.RowId)?.Singular.RawString))
.ToList();
PluginLog.Log($"npcs: {this.Npcs.Count}");
}
private int GetNpcIndex(uint objectId) {
return new Random((int) (objectId + this.Salt)).Next(0, this.Npcs.Count);
}
internal ENpcBase GetNpc(uint objectId) {
return this.Npcs[this.GetNpcIndex(objectId)];
}
}