minion/pet/companion/mount rework

This commit is contained in:
Stanley Dimant
2022-07-22 02:11:35 +02:00
parent 75885473ad
commit 9d9aac6bb3
14 changed files with 403 additions and 152 deletions

View File

@@ -3,12 +3,15 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using MareSynchronos.API;
using MareSynchronos.Factories;
namespace MareSynchronos.Models
{
[JsonObject(MemberSerialization.OptIn)]
public class CharacterData
{
[JsonProperty]
public ObjectKind Kind { get; set; }
public List<FileReplacement> FileReplacements { get; set; } = new();
[JsonProperty]
@@ -37,6 +40,7 @@ namespace MareSynchronos.Models
{
return new CharacterCacheDto()
{
ObjectKind = Kind,
FileReplacements = FileReplacements.Where(f => f.HasFileReplacement).GroupBy(f => f.Hash).Select(g =>
{
return new FileReplacementDto()

View File

@@ -0,0 +1,57 @@
using System;
using MareSynchronos.API;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using System.Runtime.InteropServices;
namespace MareSynchronos.Models
{
internal class PlayerAttachedObject
{
private readonly Func<IntPtr> getAddress;
public unsafe Character* Character => (Character*)Address;
public ObjectKind ObjectKind { get; }
public IntPtr Address { get; set; }
public IntPtr DrawObjectAddress { get; set; }
public IntPtr CurrentAddress => getAddress.Invoke();
public PlayerAttachedObject(ObjectKind objectKind, IntPtr address, IntPtr drawObjectAddress, Func<IntPtr> getAddress)
{
ObjectKind = objectKind;
Address = address;
DrawObjectAddress = drawObjectAddress;
this.getAddress = getAddress;
}
public byte[] EquipSlotData { get; set; } = new byte[40];
public byte[] CustomizeData { get; set; } = new byte[26];
public unsafe bool CompareAndUpdateEquipment(byte* equipSlotData, byte* customizeData)
{
bool hasChanges = false;
for (int i = 0; i < EquipSlotData.Length; i++)
{
var data = Marshal.ReadByte((IntPtr)equipSlotData, i);
if (EquipSlotData[i] != data)
{
EquipSlotData[i] = data;
hasChanges = true;
}
}
for (int i = 0; i < CustomizeData.Length; i++)
{
var data = Marshal.ReadByte((IntPtr)customizeData, i);
if (CustomizeData[i] != data)
{
CustomizeData[i] = data;
hasChanges = true;
}
}
return hasChanges;
}
}
}