mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
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:
parent
9dafc65975
commit
6d5503b3bc
6 changed files with 201 additions and 35 deletions
50
Glamourer.GameData/JobGroup.cs
Normal file
50
Glamourer.GameData/JobGroup.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue