Update to API4, use IPC instead of API-project. Replace Actor in most visible names with Object, Character or Player..

This commit is contained in:
Ottermandias 2021-08-27 17:51:51 +02:00
parent 3680d2b63f
commit 4dfc2cf665
60 changed files with 812 additions and 740 deletions

View file

@ -0,0 +1,14 @@
namespace Penumbra.GameData.Enums
{
public enum RedrawType
{
WithoutSettings,
WithSettings,
OnlyWithSettings,
Unload,
RedrawWithoutSettings,
RedrawWithSettings,
AfterGPoseWithSettings,
AfterGPoseWithoutSettings,
}
}

View file

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
@ -13,9 +15,9 @@ namespace Penumbra.GameData
internal static ObjectIdentification? Identification;
internal static readonly GamePathParser GamePathParser = new();
public static IObjectIdentifier GetIdentifier( DalamudPluginInterface pi )
public static IObjectIdentifier GetIdentifier( DataManager dataManager, ClientLanguage clientLanguage )
{
Identification ??= new ObjectIdentification( pi );
Identification ??= new ObjectIdentification( dataManager, clientLanguage );
return Identification;
}

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Dalamud.Plugin;
using Dalamud.Logging;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Penumbra.GameData.Util;

View file

@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Dalamud.Plugin;
using Dalamud;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
@ -63,9 +64,9 @@ namespace Penumbra.GameData
}
}
public ObjectIdentification( DalamudPluginInterface plugin )
public ObjectIdentification( DataManager dataManager, ClientLanguage clientLanguage )
{
var items = plugin.Data.GetExcelSheet< Item >( plugin.ClientState.ClientLanguage );
var items = dataManager.GetExcelSheet< Item >( clientLanguage )!;
SortedList< ulong, HashSet< Item > > weapons = new();
SortedList< ulong, HashSet< Item > > equipment = new();
foreach( var item in items )
@ -112,7 +113,7 @@ namespace Penumbra.GameData
}
_actions = new Dictionary< string, HashSet< Action > >();
foreach( var action in plugin.Data.GetExcelSheet< Action >( plugin.ClientState.ClientLanguage )
foreach( var action in dataManager.GetExcelSheet< Action >( clientLanguage )!
.Where( a => a.Name.ToString().Any() ) )
{
var startKey = action.AnimationStart?.Value?.Name?.Value?.Key.ToString() ?? string.Empty;

View file

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<LangVersion>preview</LangVersion>
<PlatformTarget>x64</PlatformTarget>
<AssemblyTitle>Penumbra.GameData</AssemblyTitle>
<Company>absolute gangstas</Company>
<Product>Penumbra</Product>

View file

@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs
{
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public readonly struct ActorArmor
public readonly struct CharacterArmor
{
public readonly SetId Set;
public readonly byte Variant;

View file

@ -1,14 +1,13 @@
using System;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Actors.Types;
using Penumbra.GameData.Enums;
using Dalamud.Game.ClientState.Objects.Types;
// Read the customization data regarding weapons and displayable equipment from an actor struct.
// Stores the data in a 56 bytes, i.e. 7 longs for easier comparison.
namespace Penumbra.GameData.Structs
{
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public class ActorEquipment
public class CharacterEquipment
{
public const int MainWeaponOffset = 0x0F08;
public const int OffWeaponOffset = 0x0F70;
@ -16,24 +15,24 @@ namespace Penumbra.GameData.Structs
public const int EquipmentSlots = 10;
public const int WeaponSlots = 2;
public ActorWeapon MainHand;
public ActorWeapon OffHand;
public ActorArmor Head;
public ActorArmor Body;
public ActorArmor Hands;
public ActorArmor Legs;
public ActorArmor Feet;
public ActorArmor Ears;
public ActorArmor Neck;
public ActorArmor Wrists;
public ActorArmor RFinger;
public ActorArmor LFinger;
public CharacterWeapon MainHand;
public CharacterWeapon OffHand;
public CharacterArmor Head;
public CharacterArmor Body;
public CharacterArmor Hands;
public CharacterArmor Legs;
public CharacterArmor Feet;
public CharacterArmor Ears;
public CharacterArmor Neck;
public CharacterArmor Wrists;
public CharacterArmor RFinger;
public CharacterArmor LFinger;
public ushort IsSet; // Also fills struct size to 56, a multiple of 8.
public ActorEquipment()
public CharacterEquipment()
=> Clear();
public ActorEquipment( Actor actor )
public CharacterEquipment( Character actor )
: this( actor.Address )
{ }
@ -43,40 +42,40 @@ namespace Penumbra.GameData.Structs
: $"({MainHand}) | ({OffHand}) | ({Head}) | ({Body}) | ({Hands}) | ({Legs}) | "
+ $"({Feet}) | ({Ears}) | ({Neck}) | ({Wrists}) | ({LFinger}) | ({RFinger})";
public bool Equal( Actor rhs )
=> CompareData( new ActorEquipment( rhs ) );
public bool Equal( Character rhs )
=> CompareData( new CharacterEquipment( rhs ) );
public bool Equal( ActorEquipment rhs )
public bool Equal( CharacterEquipment rhs )
=> CompareData( rhs );
public bool CompareAndUpdate( Actor rhs )
=> CompareAndOverwrite( new ActorEquipment( rhs ) );
public bool CompareAndUpdate( Character rhs )
=> CompareAndOverwrite( new CharacterEquipment( rhs ) );
public bool CompareAndUpdate( ActorEquipment rhs )
public bool CompareAndUpdate( CharacterEquipment rhs )
=> CompareAndOverwrite( rhs );
private unsafe ActorEquipment( IntPtr actorAddress )
private unsafe CharacterEquipment( IntPtr actorAddress )
{
IsSet = 1;
var actorPtr = ( byte* )actorAddress.ToPointer();
fixed( ActorWeapon* main = &MainHand, off = &OffHand )
fixed( CharacterWeapon* main = &MainHand, off = &OffHand )
{
Buffer.MemoryCopy( actorPtr + MainWeaponOffset, main, sizeof( ActorWeapon ), sizeof( ActorWeapon ) );
Buffer.MemoryCopy( actorPtr + OffWeaponOffset, off, sizeof( ActorWeapon ), sizeof( ActorWeapon ) );
Buffer.MemoryCopy( actorPtr + MainWeaponOffset, main, sizeof( CharacterWeapon ), sizeof( CharacterWeapon ) );
Buffer.MemoryCopy( actorPtr + OffWeaponOffset, off, sizeof( CharacterWeapon ), sizeof( CharacterWeapon ) );
}
fixed( ActorArmor* equipment = &Head )
fixed( CharacterArmor* equipment = &Head )
{
Buffer.MemoryCopy( actorPtr + EquipmentOffset, equipment, EquipmentSlots * sizeof( ActorArmor ),
EquipmentSlots * sizeof( ActorArmor ) );
Buffer.MemoryCopy( actorPtr + EquipmentOffset, equipment, EquipmentSlots * sizeof( CharacterArmor ),
EquipmentSlots * sizeof( CharacterArmor ) );
}
}
public unsafe void Clear()
{
fixed( ActorWeapon* main = &MainHand )
fixed( CharacterWeapon* main = &MainHand )
{
var structSizeEights = ( 2 + EquipmentSlots * sizeof( ActorArmor ) + WeaponSlots * sizeof( ActorWeapon ) ) / 8;
var structSizeEights = ( 2 + EquipmentSlots * sizeof( CharacterArmor ) + WeaponSlots * sizeof( CharacterWeapon ) ) / 8;
for( ulong* ptr = ( ulong* )main, end = ptr + structSizeEights; ptr != end; ++ptr )
{
*ptr = 0;
@ -84,11 +83,11 @@ namespace Penumbra.GameData.Structs
}
}
private unsafe bool CompareAndOverwrite( ActorEquipment rhs )
private unsafe bool CompareAndOverwrite( CharacterEquipment rhs )
{
var structSizeEights = ( 2 + EquipmentSlots * sizeof( ActorArmor ) + WeaponSlots * sizeof( ActorWeapon ) ) / 8;
var structSizeEights = ( 2 + EquipmentSlots * sizeof( CharacterArmor ) + WeaponSlots * sizeof( CharacterWeapon ) ) / 8;
var ret = true;
fixed( ActorWeapon* data1 = &MainHand, data2 = &rhs.MainHand )
fixed( CharacterWeapon* data1 = &MainHand, data2 = &rhs.MainHand )
{
var ptr1 = ( ulong* )data1;
var ptr2 = ( ulong* )data2;
@ -105,10 +104,10 @@ namespace Penumbra.GameData.Structs
return ret;
}
private unsafe bool CompareData( ActorEquipment rhs )
private unsafe bool CompareData( CharacterEquipment rhs )
{
var structSizeEights = ( 2 + EquipmentSlots * sizeof( ActorArmor ) + WeaponSlots * sizeof( ActorWeapon ) ) / 8;
fixed( ActorWeapon* data1 = &MainHand, data2 = &rhs.MainHand )
var structSizeEights = ( 2 + EquipmentSlots * sizeof( CharacterArmor ) + WeaponSlots * sizeof( CharacterWeapon ) ) / 8;
fixed( CharacterWeapon* data1 = &MainHand, data2 = &rhs.MainHand )
{
var ptr1 = ( ulong* )data1;
var ptr2 = ( ulong* )data2;
@ -126,7 +125,7 @@ namespace Penumbra.GameData.Structs
public unsafe void WriteBytes( byte[] array, int offset = 0 )
{
fixed( ActorWeapon* data = &MainHand )
fixed( CharacterWeapon* data = &MainHand )
{
Marshal.Copy( new IntPtr( data ), array, offset, 56 );
}
@ -141,7 +140,7 @@ namespace Penumbra.GameData.Structs
public unsafe void FromBytes( byte[] array, int offset = 0 )
{
fixed( ActorWeapon* data = &MainHand )
fixed( CharacterWeapon* data = &MainHand )
{
Marshal.Copy( array, offset, new IntPtr( data ), 56 );
}

View file

@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs
{
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public readonly struct ActorWeapon
public readonly struct CharacterWeapon
{
public readonly SetId Set;
public readonly WeaponType Type;

View file

@ -65,7 +65,7 @@ namespace Penumbra.GameData.Util
return idx == -1 ? _path : idx == _path.Length - 1 ? "" : _path.Substring( idx + 1 );
}
public int CompareTo( object rhs )
public int CompareTo( object? rhs )
{
return rhs switch
{