Fix MoveInteractable input handling race condition

This commit is contained in:
Oleg Petruny 2024-10-11 12:08:09 +02:00 committed by Oleg Petruny
parent 5a562a42ea
commit c869f82fc0
24 changed files with 7 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 128 B

View File

@ -97,6 +97,7 @@ void UMoveInteractableModificator::Unbind_Implementation()
void UMoveInteractableModificator::TurnOnHolding()
{
FScopeLock lock1(&critical);
holding = true;
ProcessState();
distance = (player->GetCameraLocation() - actor->GetActorLocation()).Length();
@ -105,6 +106,7 @@ void UMoveInteractableModificator::TurnOnHolding()
}
void UMoveInteractableModificator::TurnOffHolding()
{
FScopeLock lock1(&critical);
holding = false;
ProcessState();
AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::Unhold);
@ -112,6 +114,7 @@ void UMoveInteractableModificator::TurnOffHolding()
void UMoveInteractableModificator::TurnOnRotating()
{
FScopeLock lock1(&critical);
rotating = true;
player->LockPlayer({ .camera = true });
ProcessState();
@ -120,6 +123,7 @@ void UMoveInteractableModificator::TurnOnRotating()
}
void UMoveInteractableModificator::TurnOffRotating()
{
FScopeLock lock1(&critical);
rotating = false;
player->UnlockPlayer({ .camera = true });
ProcessState();
@ -130,6 +134,7 @@ void UMoveInteractableModificator::ProcessState()
{
if(holding || rotating)
{
if(!actor->activationLockers.Contains(this))
actor->activationLockers.Add(this);
}
else

View File

@ -58,4 +58,5 @@ private:
bool rotating = false;
class AInteractable* actor = nullptr;
class APlayerBase* player = nullptr;
FCriticalSection critical;
};