From 9939750049945ce6dd0d9d1593e4662d7e30ae29 Mon Sep 17 00:00:00 2001 From: Asgard Date: Wed, 29 Jan 2025 18:11:09 -0700 Subject: [PATCH 1/3] Goop demo --- Brio/Brio.cs | 1 + .../Actor/ActorDebugCapability.cs | 7 ++- Brio/Game/Actor/ActorVFXService.cs | 51 +++++++++++++++++++ Brio/UI/Widgets/Actor/ActorDebugWidget.cs | 22 ++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Brio/Game/Actor/ActorVFXService.cs diff --git a/Brio/Brio.cs b/Brio/Brio.cs index f646f768..0ee2e9fe 100644 --- a/Brio/Brio.cs +++ b/Brio/Brio.cs @@ -134,6 +134,7 @@ private static ServiceCollection SetupServices(DalamudServices dalamudServices) serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); diff --git a/Brio/Capabilities/Actor/ActorDebugCapability.cs b/Brio/Capabilities/Actor/ActorDebugCapability.cs index fd782320..c8442604 100644 --- a/Brio/Capabilities/Actor/ActorDebugCapability.cs +++ b/Brio/Capabilities/Actor/ActorDebugCapability.cs @@ -1,6 +1,7 @@ using Brio.Capabilities.Posing; using Brio.Config; using Brio.Entities.Actor; +using Brio.Game.Actor; using Brio.UI.Widgets.Actor; using System.Collections.Generic; @@ -12,10 +13,12 @@ internal class ActorDebugCapability : ActorCharacterCapability public bool IsDebug => _configService.IsDebug; private readonly ConfigurationService _configService; + private readonly ActorVFXService _vfxService; - public ActorDebugCapability(ActorEntity parent, ConfigurationService configService) : base(parent) + public ActorDebugCapability(ActorEntity parent, ConfigurationService configService, ActorVFXService actorVFXService) : base(parent) { _configService = configService; + _vfxService = actorVFXService; Widget = new ActorDebugWidget(this); } @@ -30,4 +33,6 @@ public Dictionary SkeletonStacks return []; } } + + public ActorVFXService VFXService => _vfxService; } diff --git a/Brio/Game/Actor/ActorVFXService.cs b/Brio/Game/Actor/ActorVFXService.cs new file mode 100644 index 00000000..a8cc5580 --- /dev/null +++ b/Brio/Game/Actor/ActorVFXService.cs @@ -0,0 +1,51 @@ +using Dalamud.Game; +using NativeGameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject; +using System; +using Dalamud.Game.ClientState.Objects.Types; +using Brio.Game.Actor.Extensions; + +namespace Brio.Game.Actor; + +internal unsafe class ActorVFXService : IDisposable +{ + + private delegate* unmanaged _createActorVfx; + + private delegate* unmanaged _vfxDtor; + + + public ActorVFXService(ISigScanner scanner) + { + var vfxCreateAddress = scanner.ScanText("E8 ?? ?? ?? ?? 48 8B D8 48 85 C0 74 ?? 0F B6 57 ?? 48 8B C8 C0 EA"); + _createActorVfx = (delegate* unmanaged)vfxCreateAddress; + + var cleanupRenderAddress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 8B FA 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 48 8B D3"); + _vfxDtor = (delegate* unmanaged)cleanupRenderAddress; + } + + public nint CreateActorVFX(string vfxName, IGameObject actor, IGameObject? target = null) + { + if(target == null) + target = actor; + + return CreateActorVFX(vfxName, actor.Native(), target.Native()); + } + + public nint CreateActorVFX(string vfxName, NativeGameObject* actor, NativeGameObject* target = null) + { + if(target == null) + target = actor; + + return _createActorVfx(vfxName, actor, target, -1, 0, 0, 0); + } + + public void DestroyVFX(nint vfxInstance) + { + if(vfxInstance != 0) + _vfxDtor(vfxInstance); + } + + public unsafe void Dispose() + { + } +} diff --git a/Brio/UI/Widgets/Actor/ActorDebugWidget.cs b/Brio/UI/Widgets/Actor/ActorDebugWidget.cs index fa51ff03..f284961c 100644 --- a/Brio/UI/Widgets/Actor/ActorDebugWidget.cs +++ b/Brio/UI/Widgets/Actor/ActorDebugWidget.cs @@ -12,6 +12,9 @@ internal class ActorDebugWidget(ActorDebugCapability capability) : Widget Capability.IsDebug ? WidgetFlags.DrawBody : WidgetFlags.None; + // TODO: Store this properly in a list or whatever so it can be cleaned up + private static nint _spawnedGoopInstance; + public unsafe override void DrawBody() { using(var tabBar = ImRaii.TabBar("###debug_tabs")) @@ -62,6 +65,25 @@ public unsafe override void DrawBody() } } } + + using(var vfxTab = ImRaii.TabItem("Goop Demo")) + { + if(vfxTab.Success) + { + if(ImGui.Button("Create Goop")) + { + // TODO: Store this properly in a list or whatever so it can be cleaned up + _spawnedGoopInstance = Capability.VFXService.CreateActorVFX("vfx/common/eff/c0101_stlp_mim_gre_c0r1.avfx", Capability.GameObject); + + } + + if(ImGui.Button("Destroy Goop")) + { + Capability.VFXService.DestroyVFX(_spawnedGoopInstance); + _spawnedGoopInstance = 0; + } + } + } } } } From 82a8c7d935d15e9338564fabb407a172d08e25e9 Mon Sep 17 00:00:00 2001 From: Asgard Date: Wed, 29 Jan 2025 18:13:06 -0700 Subject: [PATCH 2/3] Rename var --- Brio/Game/Actor/ActorVFXService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Brio/Game/Actor/ActorVFXService.cs b/Brio/Game/Actor/ActorVFXService.cs index a8cc5580..6e59d5ff 100644 --- a/Brio/Game/Actor/ActorVFXService.cs +++ b/Brio/Game/Actor/ActorVFXService.cs @@ -19,8 +19,8 @@ public ActorVFXService(ISigScanner scanner) var vfxCreateAddress = scanner.ScanText("E8 ?? ?? ?? ?? 48 8B D8 48 85 C0 74 ?? 0F B6 57 ?? 48 8B C8 C0 EA"); _createActorVfx = (delegate* unmanaged)vfxCreateAddress; - var cleanupRenderAddress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 8B FA 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 48 8B D3"); - _vfxDtor = (delegate* unmanaged)cleanupRenderAddress; + var vfxDetourAddress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 8B FA 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 48 8B D3"); + _vfxDtor = (delegate* unmanaged)vfxDetourAddress; } public nint CreateActorVFX(string vfxName, IGameObject actor, IGameObject? target = null) From 71a27006e2087e71c874e44679abc3abeeaa6522 Mon Sep 17 00:00:00 2001 From: Asgard Date: Wed, 29 Jan 2025 18:19:30 -0700 Subject: [PATCH 3/3] Typo --- Brio/Game/Actor/ActorVFXService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Brio/Game/Actor/ActorVFXService.cs b/Brio/Game/Actor/ActorVFXService.cs index 6e59d5ff..15d5631e 100644 --- a/Brio/Game/Actor/ActorVFXService.cs +++ b/Brio/Game/Actor/ActorVFXService.cs @@ -19,8 +19,8 @@ public ActorVFXService(ISigScanner scanner) var vfxCreateAddress = scanner.ScanText("E8 ?? ?? ?? ?? 48 8B D8 48 85 C0 74 ?? 0F B6 57 ?? 48 8B C8 C0 EA"); _createActorVfx = (delegate* unmanaged)vfxCreateAddress; - var vfxDetourAddress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 8B FA 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 48 8B D3"); - _vfxDtor = (delegate* unmanaged)vfxDetourAddress; + var vfxDtorAddress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 8B FA 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 01 48 8B D3"); + _vfxDtor = (delegate* unmanaged)vfxDtorAddress; } public nint CreateActorVFX(string vfxName, IGameObject actor, IGameObject? target = null)