Fix gpose weapon type when redrawing is necessary.

This commit is contained in:
Ottermandias 2023-07-26 18:17:09 +02:00
parent 4fee749954
commit 4ac062fdc5
3 changed files with 8 additions and 3 deletions

View file

@ -42,6 +42,9 @@ public readonly unsafe struct Actor : IEquatable<Actor>
public static implicit operator nint(Actor actor)
=> actor.Address;
public bool IsGPoseOrCutscene
=> Index is >= (int)ScreenActor.CutsceneStart and < (int)ScreenActor.CutsceneEnd;
public ActorIdentifier GetIdentifier(ActorManager actors)
=> actors.FromObject(AsObject, out _, true, true, false);

View file

@ -45,5 +45,5 @@ public readonly struct ActorData
}
public ActorData OnlyGPose()
=> new(Objects.Where(o => o.Index is >= (int)ScreenActor.GPosePlayer and < (int)ScreenActor.CutsceneEnd).ToList(), Label);
=> new(Objects.Where(o => o.IsGPoseOrCutscene).ToList(), Label);
}

View file

@ -37,6 +37,7 @@ public class StateListener : IDisposable
private readonly FunModule _funModule;
private readonly HumanModelList _humans;
private readonly MovedEquipment _movedEquipment;
private readonly GPoseService _gpose;
private ActorIdentifier _creatingIdentifier = ActorIdentifier.Invalid;
private ActorState? _creatingState;
@ -51,7 +52,7 @@ public class StateListener : IDisposable
public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorService actors, Configuration config,
SlotUpdating slotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility,
HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans,
StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects)
StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gpose)
{
_manager = manager;
_items = items;
@ -69,6 +70,7 @@ public class StateListener : IDisposable
_applier = applier;
_movedEquipment = movedEquipment;
_objects = objects;
_gpose = gpose;
if (Enabled)
Subscribe();
@ -248,7 +250,7 @@ public class StateListener : IDisposable
{
// Only allow overwriting identical weapons
var newWeapon = state.ModelData.Weapon(slot);
if (baseType is FullEquipType.Unknown || baseType == state.ModelData.Item(slot).Type)
if (baseType is FullEquipType.Unknown || baseType == state.ModelData.Item(slot).Type || _gpose.InGPose && actor.IsGPoseOrCutscene)
actorWeapon = newWeapon;
else if (actorWeapon.Set.Value != 0)
actorWeapon = actorWeapon.With(newWeapon.Stain);