qstbak/Auspex/Auspex.Vfx.Internal/ActorBoundVfx.cs
2026-08-17 20:25:32 +10:00

64 lines
1.6 KiB
C#

using System;
using System.Numerics;
using System.Text;
using Auspex.Vfx.Native;
using Dalamud.Game.ClientState.Objects.Types;
namespace Auspex.Vfx.Internal;
public sealed class ActorBoundVfx : IDisposable
{
internal IGameObject target;
internal IGameObject source;
internal Vector3 scale;
internal Vector4 color;
internal unsafe VfxData* data;
public static ActorBoundVfx Create(string path, IGameObject target, IGameObject source, Vector3 scale, Vector4 color)
{
return new ActorBoundVfx(path, target, source, scale, color);
}
private unsafe ActorBoundVfx(string path, IGameObject target, IGameObject source, Vector3 scale, Vector4 color)
{
this.target = target;
this.source = source;
this.scale = scale;
this.color = color;
data = CreateGameObjectVfxInternal(path, target, source, scale, color);
}
public unsafe void Dispose()
{
if (data != null && data->Instance != null)
{
VfxNativeBridge.DestroyVfx(data);
}
data = null;
GC.SuppressFinalize(this);
}
private unsafe static VfxData* CreateGameObjectVfxInternal(string path, IGameObject target, IGameObject source, Vector3 scale, Vector4 color)
{
fixed (byte* bytes = Encoding.UTF8.GetBytes(path + "\0"))
{
VfxData* intPtr = VfxNativeBridge.CreateGameObjectVfxInternal(bytes, target.Address, source.Address, 1f, 0, 0, 1);
intPtr->Instance->Scale = scale;
intPtr->Instance->Color = color;
return intPtr;
}
}
public unsafe void UpdateColor(Vector4 color)
{
if (!(this.color == color))
{
this.color = color;
VfxNativeBridge.UpdateVfxColor(data->Instance, color.X, color.Y, color.Z, color.W);
}
}
}