mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Add some start for Evp Data.
This commit is contained in:
parent
8aec63d0be
commit
2010e02034
4 changed files with 128 additions and 60 deletions
68
Penumbra/Meta/Files/EvpFile.cs
Normal file
68
Penumbra/Meta/Files/EvpFile.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
|
||||
namespace Penumbra.Meta.Files;
|
||||
|
||||
|
||||
// EVP file structure:
|
||||
// [Identifier:3 bytes, EVP]
|
||||
// [NumModels:ushort]
|
||||
// NumModels x [ModelId:ushort]
|
||||
// Containing the relevant model IDs. Seems to be sorted.
|
||||
// NumModels x [DataArray]:512 Byte]
|
||||
// Containing Flags in each byte, 0x01 set for Body, 0x02 set for Helmet. Unsure where the index into this array comes from.
|
||||
public unsafe class EvpFile : MetaBaseFile
|
||||
{
|
||||
public const int FlagArraySize = 512;
|
||||
|
||||
[Flags]
|
||||
public enum EvpFlag : byte
|
||||
{
|
||||
None = 0x00,
|
||||
Body = 0x01,
|
||||
Head = 0x02,
|
||||
Both = Body | Head,
|
||||
}
|
||||
|
||||
public int NumModels
|
||||
=> Data[ 3 ];
|
||||
|
||||
public ReadOnlySpan< ushort > ModelSetIds
|
||||
=> new(Data + 4, NumModels);
|
||||
|
||||
public ushort ModelSetId( int idx )
|
||||
=> idx >= 0 && idx < NumModels ? ( ( ushort* )( Data + 4 ) )[ idx ] : ushort.MaxValue;
|
||||
|
||||
public ReadOnlySpan< EvpFlag > Flags( int idx )
|
||||
=> new(Data + 4 + idx * FlagArraySize, FlagArraySize);
|
||||
|
||||
public EvpFlag Flag( ushort modelSet, int arrayIndex )
|
||||
{
|
||||
if( arrayIndex is >= FlagArraySize or < 0 )
|
||||
{
|
||||
return EvpFlag.None;
|
||||
}
|
||||
|
||||
var ids = ModelSetIds;
|
||||
for( var i = 0; i < ids.Length; ++i )
|
||||
{
|
||||
var model = ids[ i ];
|
||||
if( model < modelSet )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( model > modelSet )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
return Flags( i )[ arrayIndex ];
|
||||
}
|
||||
|
||||
return EvpFlag.None;
|
||||
}
|
||||
|
||||
public EvpFile()
|
||||
: base( ( Interop.Structs.CharacterUtility.Index )1 ) // TODO: Name
|
||||
{ }
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ public unsafe class MetaBaseFile : IDisposable
|
|||
public CharacterUtility.InternalIndex Index { get; }
|
||||
|
||||
public MetaBaseFile( Interop.Structs.CharacterUtility.Index idx )
|
||||
=> Index = CharacterUtility.ReverseIndices[(int) idx];
|
||||
=> Index = CharacterUtility.ReverseIndices[ ( int )idx ];
|
||||
|
||||
protected (IntPtr Data, int Length) DefaultData
|
||||
=> Penumbra.CharacterUtility.DefaultResource( Index );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue