Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT/DEMO: Goop demo #120

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions Brio/Brio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private static ServiceCollection SetupServices(DalamudServices dalamudServices)
serviceCollection.AddSingleton<ActorSpawnService>();
serviceCollection.AddSingleton<ActorRedrawService>();
serviceCollection.AddSingleton<ActorAppearanceService>();
serviceCollection.AddSingleton<ActorVFXService>();
serviceCollection.AddSingleton<ActionTimelineService>();
serviceCollection.AddSingleton<GPoseService>();
serviceCollection.AddSingleton<CommandHandlerService>();
Expand Down
7 changes: 6 additions & 1 deletion Brio/Capabilities/Actor/ActorDebugCapability.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
}
Expand All @@ -30,4 +33,6 @@ public Dictionary<string, int> SkeletonStacks
return [];
}
}

public ActorVFXService VFXService => _vfxService;
}
51 changes: 51 additions & 0 deletions Brio/Game/Actor/ActorVFXService.cs
Original file line number Diff line number Diff line change
@@ -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<string, NativeGameObject*, NativeGameObject*, float, byte, ushort, byte, nint> _createActorVfx;

private delegate* unmanaged<nint, void> _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<string, NativeGameObject*, NativeGameObject*, float, byte, ushort, byte, nint>)vfxCreateAddress;

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<nint, void>)vfxDtorAddress;
}

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()
{
}
}
22 changes: 22 additions & 0 deletions Brio/UI/Widgets/Actor/ActorDebugWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ internal class ActorDebugWidget(ActorDebugCapability capability) : Widget<ActorD

public override WidgetFlags Flags => 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"))
Expand Down Expand Up @@ -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;
}
}
}
}
}
}
Expand Down
Loading