mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Add support for modelchara id and extended arrays.
This commit is contained in:
parent
1f4685f505
commit
afc987432a
3 changed files with 89 additions and 55 deletions
|
|
@ -4,60 +4,55 @@ using Dalamud.Game.ClientState.Objects.Enums;
|
|||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
|
||||
namespace Penumbra.PlayerWatch
|
||||
namespace Penumbra.PlayerWatch;
|
||||
|
||||
public static class CharacterFactory
|
||||
{
|
||||
public static class CharacterFactory
|
||||
private static ConstructorInfo? _characterConstructor;
|
||||
|
||||
private static void Initialize()
|
||||
{
|
||||
private static ConstructorInfo? _characterConstructor;
|
||||
|
||||
private static void Initialize()
|
||||
_characterConstructor ??= typeof(Character).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new[]
|
||||
{
|
||||
_characterConstructor ??= typeof( Character ).GetConstructor( BindingFlags.NonPublic | BindingFlags.Instance, null, new[]
|
||||
{
|
||||
typeof( IntPtr ),
|
||||
}, null )!;
|
||||
}
|
||||
|
||||
private static Character Character( IntPtr address )
|
||||
{
|
||||
Initialize();
|
||||
return ( Character )_characterConstructor?.Invoke( new object[]
|
||||
{
|
||||
address,
|
||||
} )!;
|
||||
}
|
||||
|
||||
public static Character? Convert( GameObject? actor )
|
||||
{
|
||||
if( actor == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return actor switch
|
||||
{
|
||||
PlayerCharacter p => p,
|
||||
BattleChara b => b,
|
||||
_ => actor.ObjectKind switch
|
||||
{
|
||||
ObjectKind.BattleNpc => Character( actor.Address ),
|
||||
ObjectKind.Companion => Character( actor.Address ),
|
||||
ObjectKind.Retainer => Character( actor.Address ),
|
||||
ObjectKind.EventNpc => Character( actor.Address ),
|
||||
_ => null,
|
||||
},
|
||||
};
|
||||
}
|
||||
typeof(IntPtr),
|
||||
}, null)!;
|
||||
}
|
||||
|
||||
public static class GameObjectExtensions
|
||||
private static Character Character(IntPtr address)
|
||||
{
|
||||
private const int ModelTypeOffset = 0x01B4;
|
||||
|
||||
public static unsafe int ModelType( this GameObject actor )
|
||||
=> *( int* )( actor.Address + ModelTypeOffset );
|
||||
|
||||
public static unsafe void SetModelType( this GameObject actor, int value )
|
||||
=> *( int* )( actor.Address + ModelTypeOffset ) = value;
|
||||
Initialize();
|
||||
return (Character)_characterConstructor?.Invoke(new object[]
|
||||
{
|
||||
address,
|
||||
})!;
|
||||
}
|
||||
}
|
||||
|
||||
public static Character? Convert(GameObject? actor)
|
||||
{
|
||||
if (actor == null)
|
||||
return null;
|
||||
|
||||
return actor switch
|
||||
{
|
||||
PlayerCharacter p => p,
|
||||
BattleChara b => b,
|
||||
_ => actor.ObjectKind switch
|
||||
{
|
||||
ObjectKind.BattleNpc => Character(actor.Address),
|
||||
ObjectKind.Companion => Character(actor.Address),
|
||||
ObjectKind.Retainer => Character(actor.Address),
|
||||
ObjectKind.EventNpc => Character(actor.Address),
|
||||
_ => null,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class GameObjectExtensions
|
||||
{
|
||||
public static unsafe uint ModelType(this Character actor)
|
||||
=> (uint) ((FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)actor.Address)->CharacterData.ModelCharaId;
|
||||
|
||||
public static unsafe void SetModelType(this Character actor, uint value)
|
||||
=> ((FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)actor.Address)->CharacterData.ModelCharaId = (int) value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue