Allow multiple fixed designs for a single character to be active, and check jobs. Use the job-group with fewer entries if they are overlapping, and the first added if they have the same number of entries.

This commit is contained in:
Ottermandias 2021-10-09 13:47:24 +02:00
parent 9dafc65975
commit 6d5503b3bc
6 changed files with 201 additions and 35 deletions

View file

@ -11,6 +11,8 @@ namespace Glamourer
{
private static Dictionary<byte, Stain>? _stains;
private static Dictionary<EquipSlot, List<Item>>? _itemsBySlot;
private static Dictionary<byte, Job>? _jobs;
private static Dictionary<ushort, JobGroup>? _jobGroups;
private static SortedList<uint, ModelChara>? _models;
public static IReadOnlyDictionary<uint, ModelChara> Models(DataManager dataManager)
@ -84,5 +86,53 @@ namespace Glamourer
_itemsBySlot[EquipSlot.LFinger] = _itemsBySlot[EquipSlot.RFinger];
return _itemsBySlot;
}
public static IReadOnlyDictionary<byte, Job> Jobs(DataManager dataManager)
{
if (_jobs != null)
return _jobs;
var sheet = dataManager.GetExcelSheet<ClassJob>()!;
_jobs = sheet.ToDictionary(j => (byte)j.RowId, j => new Job(j));
return _jobs;
}
public static IReadOnlyDictionary<ushort, JobGroup> JobGroups(DataManager dataManager)
{
if (_jobGroups != null)
return _jobGroups;
var sheet = dataManager.GetExcelSheet<ClassJobCategory>()!;
var jobs = dataManager.GetExcelSheet<ClassJob>()!;
static bool ValidIndex(uint idx)
{
if (idx > 0 && idx < 36)
return true;
return idx switch
{
91 => true,
92 => true,
96 => true,
98 => true,
99 => true,
111 => true,
112 => true,
129 => true,
149 => true,
150 => true,
156 => true,
157 => true,
158 => true,
159 => true,
_ => false,
};
}
_jobGroups = sheet.Where(j => ValidIndex(j.RowId))
.ToDictionary(j => (ushort) j.RowId, j => new JobGroup(j, jobs));
return _jobGroups;
}
}
}

21
Glamourer.GameData/Job.cs Normal file
View file

@ -0,0 +1,21 @@
using Lumina.Excel.GeneratedSheets;
namespace Glamourer
{
public readonly struct Job
{
public readonly string Name;
public readonly string Abbreviation;
public readonly ClassJob Base;
public uint Id
=> Base.RowId;
public Job(ClassJob job)
{
Base = job;
Name = job.Name.ToString();
Abbreviation = job.Abbreviation.ToString();
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using System.Diagnostics;
using System.Linq;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
namespace Glamourer
{
public readonly struct JobGroup
{
public readonly string Name;
private readonly ulong _flags;
public readonly int Count;
public readonly uint Id;
public JobGroup(ClassJobCategory group, ExcelSheet<ClassJob> jobs)
{
Count = 0;
_flags = 0ul;
Id = group.RowId;
Name = group.Name.ToString();
Debug.Assert(jobs.RowCount < 64);
foreach (var job in jobs)
{
var abbr = job.Abbreviation.ToString();
if (!abbr.Any())
continue;
var prop = group.GetType().GetProperty(abbr);
Debug.Assert(prop != null);
if (!(bool) prop.GetValue(group)!)
continue;
++Count;
_flags |= 1ul << (int) job.RowId;
}
}
public bool Fits(Job job)
=> Fits(job.Id);
public bool Fits(uint jobId)
{
var flag = 1ul << (int)jobId;
return (flag & _flags) != 0;
}
}
}