mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
I dunno if I'll need this.
This commit is contained in:
parent
977fc059c4
commit
c335a853b2
3 changed files with 69 additions and 1 deletions
|
|
@ -100,6 +100,9 @@ public class ItemManager : IDisposable
|
|||
return item;
|
||||
}
|
||||
|
||||
public EquipItem Resolve(FullEquipType type, CustomItemId id)
|
||||
=> id.IsItem ? Resolve(type, id.Item) : EquipItem.FromId(id);
|
||||
|
||||
public EquipItem Identify(EquipSlot slot, SetId id, Variant variant)
|
||||
{
|
||||
slot = slot.ToSlot();
|
||||
|
|
|
|||
65
Glamourer/State/WeaponState.cs
Normal file
65
Glamourer/State/WeaponState.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using Glamourer.Events;
|
||||
using Glamourer.Services;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
namespace Glamourer.State;
|
||||
|
||||
/// <remarks>Currently unused.</remarks>
|
||||
public unsafe struct WeaponState
|
||||
{
|
||||
private fixed ulong _weapons[FullEquipTypeExtensions.NumWeaponTypes];
|
||||
private fixed byte _sources[FullEquipTypeExtensions.NumWeaponTypes];
|
||||
|
||||
public CustomItemId? this[FullEquipType type]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ToIndex(type, out var idx))
|
||||
return null;
|
||||
|
||||
var weapon = _weapons[idx];
|
||||
if (weapon == 0)
|
||||
return null;
|
||||
|
||||
return new CustomItemId(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
public EquipItem Get(ItemManager items, EquipItem value)
|
||||
{
|
||||
var id = this[value.Type];
|
||||
if (id == null)
|
||||
return value;
|
||||
|
||||
var item = items.Resolve(value.Type, id.Value);
|
||||
return item.Type != value.Type ? value : item;
|
||||
}
|
||||
|
||||
public void Set(FullEquipType type, EquipItem value, StateChanged.Source source)
|
||||
{
|
||||
if (!ToIndex(type, out var idx))
|
||||
return;
|
||||
|
||||
_weapons[idx] = value.Id.Id;
|
||||
_sources[idx] = (byte)source;
|
||||
}
|
||||
|
||||
public void RemoveFixedDesignSources()
|
||||
{
|
||||
for (var i = 0; i < FullEquipTypeExtensions.NumWeaponTypes; ++i)
|
||||
{
|
||||
if (_sources[i] is (byte) StateChanged.Source.Fixed)
|
||||
_sources[i] = (byte) StateChanged.Source.Manual;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ToIndex(FullEquipType type, out int index)
|
||||
{
|
||||
index = ToIndex(type);
|
||||
return index is >= 0 and < FullEquipTypeExtensions.NumWeaponTypes;
|
||||
}
|
||||
|
||||
private static int ToIndex(FullEquipType type)
|
||||
=> (int)type - FullEquipTypeExtensions.WeaponTypesOffset;
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 54b56ada57529221d3fc812193ffe65c424c1521
|
||||
Subproject commit 0c0554e7c482fac35110c3375e890540ee31abb3
|
||||
Loading…
Add table
Add a link
Reference in a new issue