Add GPose Together (#82)

* add api glue

* most of gpose together impl

* more cleanup and impl

* more impl

* minor fixes and chara name abbreviations

---------

Co-authored-by: Stanley Dimant <root.darkarchon@outlook.com>
This commit is contained in:
rootdarkarchon
2025-01-19 16:19:06 +01:00
committed by Loporrit
parent c835854fb6
commit 93aff198f2
15 changed files with 1351 additions and 22 deletions

View File

@@ -95,7 +95,7 @@ public sealed class IpcCallerBrio : IIpcCaller
if (gameObject == null) return default;
var data = await _dalamudUtilService.RunOnFrameworkThread(() => _brioGetModelTransform.InvokeFunc(gameObject)).ConfigureAwait(false);
if (data.Item1 == null || data.Item2 == null || data.Item3 == null) return default;
_logger.LogDebug("Getting Transform from Actor {actor}", gameObject.Name.TextValue);
//_logger.LogDebug("Getting Transform from Actor {actor}", gameObject.Name.TextValue);
return new WorldData()
{

View File

@@ -39,7 +39,7 @@ public unsafe class VfxSpawnManager : DisposableMediatorSubscriberBase
});
mareMediator.Subscribe<GposeEndMessage>(this, (msg) =>
{
ChangeSpawnVisibility(0.5f);
RestoreSpawnVisiblity();
});
mareMediator.Subscribe<CutsceneStartMessage>(this, (msg) =>
{
@@ -47,19 +47,27 @@ public unsafe class VfxSpawnManager : DisposableMediatorSubscriberBase
});
mareMediator.Subscribe<CutsceneEndMessage>(this, (msg) =>
{
ChangeSpawnVisibility(0.5f);
RestoreSpawnVisiblity();
});
}
private unsafe void RestoreSpawnVisiblity()
{
foreach (var vfx in _spawnedObjects)
{
((VfxStruct*)vfx.Value.Address)->Alpha = vfx.Value.Visibility;
}
}
private unsafe void ChangeSpawnVisibility(float visibility)
{
foreach (var vfx in _spawnedObjects)
{
((VfxStruct*)vfx.Value)->Alpha = visibility;
((VfxStruct*)vfx.Value.Address)->Alpha = visibility;
}
}
private readonly Dictionary<Guid, nint> _spawnedObjects = [];
private readonly Dictionary<Guid, (nint Address, float Visibility)> _spawnedObjects = [];
private VfxStruct* SpawnStatic(string path, Vector3 pos, Quaternion rotation, float r, float g, float b, float a, Vector3 scale)
{
@@ -106,17 +114,29 @@ public unsafe class VfxSpawnManager : DisposableMediatorSubscriberBase
Guid guid = Guid.NewGuid();
Logger.LogDebug("Spawned VFX at {pos}, {rot}: 0x{ptr:X}", position, rotation, (nint)vfx);
_spawnedObjects[guid] = (nint)vfx;
_spawnedObjects[guid] = ((nint)vfx, a);
return guid;
}
public void DespawnObject(Guid id)
public unsafe void MoveObject(Guid id, Vector3 newPosition)
{
if (_spawnedObjects.Remove<Guid, nint>(id, out var vfx))
if (_spawnedObjects.TryGetValue(id, out var vfxValue))
{
Logger.LogDebug("Despawning {obj:X}", vfx);
_staticVfxRemove((VfxStruct*)vfx);
if (vfxValue.Address == nint.Zero) return;
var vfx = (VfxStruct*)vfxValue.Address;
vfx->Position = newPosition with { Y = newPosition.Y + 1 };
vfx->Flags |= 2;
}
}
public void DespawnObject(Guid? id)
{
if (id == null) return;
if (_spawnedObjects.Remove(id.Value, out var value))
{
Logger.LogDebug("Despawning {obj:X}", value.Address);
_staticVfxRemove((VfxStruct*)value.Address);
}
}
@@ -125,7 +145,7 @@ public unsafe class VfxSpawnManager : DisposableMediatorSubscriberBase
foreach (var obj in _spawnedObjects.Values)
{
Logger.LogDebug("Despawning {obj:X}", obj);
_staticVfxRemove((VfxStruct*)obj);
_staticVfxRemove((VfxStruct*)obj.Address);
}
}