Maybe fix visor state issue.

This commit is contained in:
Ottermandias 2024-04-04 14:01:58 +02:00
parent 3d421881f6
commit 8375abd6cb
4 changed files with 11 additions and 4 deletions

View file

@ -12,7 +12,7 @@ namespace Glamourer.Events;
/// </list> /// </list>
/// </summary> /// </summary>
public sealed class VisorStateChanged() public sealed class VisorStateChanged()
: EventWrapperRef2<Model, bool, VisorStateChanged.Priority>(nameof(VisorStateChanged)) : EventWrapperRef3<Model, bool, bool, VisorStateChanged.Priority>(nameof(VisorStateChanged))
{ {
public enum Priority public enum Priority
{ {

View file

@ -93,7 +93,7 @@ public unsafe class MetaService : IDisposable
private void ToggleVisorDetour(DrawDataContainer* drawData, bool value) private void ToggleVisorDetour(DrawDataContainer* drawData, bool value)
{ {
Actor actor = drawData->Parent; Actor actor = drawData->Parent;
_visorEvent.Invoke(actor.Model, ref value); _visorEvent.Invoke(actor.Model, true, ref value);
Glamourer.Log.Verbose($"[MetaService] Toggle Visor triggered with 0x{(nint)drawData:X} {value} for {actor.Utf8Name}."); Glamourer.Log.Verbose($"[MetaService] Toggle Visor triggered with 0x{(nint)drawData:X} {value} for {actor.Utf8Name}.");
_toggleVisorHook.Original(drawData, value); _toggleVisorHook.Original(drawData, value);
} }

View file

@ -52,7 +52,7 @@ public class VisorService : IDisposable
var originalOn = on; var originalOn = on;
// Invoke an event that can change the requested value // Invoke an event that can change the requested value
// and also control whether the function should be called at all. // and also control whether the function should be called at all.
Event.Invoke(human, ref on); Event.Invoke(human, false, ref on);
Glamourer.Log.Excessive( Glamourer.Log.Excessive(
$"[SetVisorState] Invoked from game on 0x{human:X} switching to {on} (original {originalOn})."); $"[SetVisorState] Invoked from game on 0x{human:X} switching to {on} (original {originalOn}).");

View file

@ -568,7 +568,7 @@ public class StateListener : IDisposable
} }
/// <summary> Handle visor state changes made by the game. </summary> /// <summary> Handle visor state changes made by the game. </summary>
private void OnVisorChange(Model model, ref bool value) private unsafe void OnVisorChange(Model model, bool game, ref bool value)
{ {
// Skip updates when in customize update. // Skip updates when in customize update.
if (ChangeCustomizeService.InUpdate.InMethod) if (ChangeCustomizeService.InUpdate.InMethod)
@ -578,6 +578,13 @@ public class StateListener : IDisposable
// We do not need to handle fixed designs, // We do not need to handle fixed designs,
// since a fixed design would already have established state-tracking. // since a fixed design would already have established state-tracking.
var actor = _penumbra.GameObjectFromDrawObject(model); var actor = _penumbra.GameObjectFromDrawObject(model);
// Only actually change anything if the actor state changed,
// when equipping headgear the method is called with the current draw object state,
// which corrupts Glamourer's assumed game state otherwise.
if (!game && actor.AsCharacter->DrawData.IsVisorToggled != value)
return;
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return; return;