Skip to content
Open

Apricot #1660

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions FFXIVClientStructs/Apricot/ApricotEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using FFXIVClientStructs.Apricot.Instance;
using FFXIVClientStructs.FFXIV.Client.Graphics.Vfx;

namespace FFXIVClientStructs.Apricot;

[GenerateInterop]
[StructLayout(LayoutKind.Explicit, Size = 0x2980)]
public unsafe partial struct ApricotEngine {
[FieldOffset(0x1128)] public DataContainer* Data;

[MemberFunction("E8 ?? ?? ?? ?? 4B 8B 0C 27")]
public static partial ApricotEngine* GetInstance();

[GenerateInterop(isInherited: true)]
[StructLayout(LayoutKind.Explicit, Size = 0x83030)]
public partial struct DataContainer {
[FieldOffset(0x2030), FixedSizeArray] internal FixedSizeArray2048<InstanceContainer> _instances;

public DocumentInstance* GetDocument(int index) => this._instances[index].Instance;

public DocumentInstance* GetDocument(VfxResourceHandle handle) => this.GetDocument((int)handle.Index);
}
}
8 changes: 8 additions & 0 deletions FFXIVClientStructs/Apricot/Data/Document.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace FFXIVClientStructs.Apricot.Data;

[StructLayout(LayoutKind.Explicit)]
public struct Document {
[FieldOffset(0x40)] public unsafe Particle* Particles;

[FieldOffset(0xE6)] public byte ParticleCount;
}
6 changes: 6 additions & 0 deletions FFXIVClientStructs/Apricot/Data/Particle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace FFXIVClientStructs.Apricot.Data;

[StructLayout(LayoutKind.Explicit, Size = 0x238)]
public struct Particle {
[FieldOffset(0x70)] public unsafe RgbFunctionCurve* Rgb;
}
26 changes: 26 additions & 0 deletions FFXIVClientStructs/Apricot/Data/RgbFunctionCurve.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Numerics;

namespace FFXIVClientStructs.Apricot.Data;

[StructLayout(LayoutKind.Explicit)]
public struct RgbFunctionCurve {
[FieldOffset(0x0)] public uint Data;
// not a fixed size array, not sure how else to handle this?
[FieldOffset(0x4), FixedSizeArray] internal unsafe fixed byte _keys[0x10];
Copy link
Collaborator

@Haselnussbomber Haselnussbomber Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you were looking for was FixedSizeArray2<Pointer<RgbKey>>.
But in this case, with a dynamic sized array, it probably won’t help much.

Copy link
Collaborator

@wolfcomp wolfcomp Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do

[FieldOffset(0x4)] public RgbKey* KeyPointer;

public Span<RgbKey> Keys => new Span(KeyPointer, KeyCount);

with looking at how the GetKey function works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you were looking for was FixedSizeArray2<Pointer<RgbKey>>. But in this case, with a dynamic sized array, it probably won’t help much.

Originally tried this with a FixedSizeArray1, but it throws a IndexOutOfRangeException beyond the first element.

Could do

[FieldOffset(0x4)] public RgbKey* KeyPointer;

public Span<RgbKey> Keys => new Span(KeyPointer, KeyCount);

with looking at how the GetKey function works

There isn't a pointer here, it's an inline array with a dynamic size.


public ushort KeyCount => (ushort)(this.Data >> 9);

public unsafe RgbKey* GetKey(int index) {
if (index < 0 || index >= this.KeyCount)
throw new IndexOutOfRangeException($"{index}");

fixed (void* ptr = this._keys)
return (RgbKey*)ptr + index;
}

[StructLayout(LayoutKind.Explicit, Size = 0x10)]
public struct RgbKey {
[FieldOffset(0x0)] public uint Data;
[FieldOffset(0x4)] public Vector3 Color;
}
}
20 changes: 20 additions & 0 deletions FFXIVClientStructs/Apricot/Instance/DocumentInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FFXIVClientStructs.Apricot.Data;

namespace FFXIVClientStructs.Apricot.Instance;

[StructLayout(LayoutKind.Explicit, Size = 0x500)]
public struct DocumentInstance {
[FieldOffset(0)] public unsafe nint* _vfTable;

[FieldOffset(0x1D4)] public float LocalTime;
[FieldOffset(0x1DC)] public float TimeScale;

[FieldOffset(0x1F8)] public unsafe DocumentInstance* Root;
[FieldOffset(0x200)] public unsafe DocumentInstance* Parent;
[FieldOffset(0x208)] public unsafe Document* Document;
[FieldOffset(0x210)] public unsafe DocumentInstance* Child;
[FieldOffset(0x218)] public unsafe DocumentInstance* ChildLast;
[FieldOffset(0x220)] public unsafe DocumentInstance* Sibling;

[FieldOffset(0x49D)] public byte State;
}
8 changes: 8 additions & 0 deletions FFXIVClientStructs/Apricot/InstanceContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using FFXIVClientStructs.Apricot.Instance;

namespace FFXIVClientStructs.Apricot;

[StructLayout(LayoutKind.Explicit, Size = 0x88)]
public struct InstanceContainer {
[FieldOffset(0)] public unsafe DocumentInstance* Instance;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace FFXIVClientStructs.FFXIV.Client.Graphics.Vfx;

[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct VfxResourceHandle {
[FieldOffset(0), CExporterUnion("Value")] public ulong Value;
[FieldOffset(0), CExporterUnion("Value")] public uint Id;
[FieldOffset(4), CExporterUnion("Value")] public uint Index;
Comment on lines +5 to +7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will export the unions as

union Value {
  uint64_t Value;
  uint32_t Id;
  uint32_t Index;
}

all which are at field offset 0

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace FFXIVClientStructs.FFXIV.Client.Graphics.Vfx;
[StructLayout(LayoutKind.Explicit, Size = 0xD0)]
public unsafe struct VfxResourceInstance {
[FieldOffset(0x08)] internal VfxResourceUnk* VfxResourceUnk;
[FieldOffset(0x60)] public VfxResourceHandle Handle;
}

[StructLayout(LayoutKind.Explicit, Size = 0x20)]
Expand Down