bug fix & Level2 without end dialogue

This commit is contained in:
Oleg Petruny 2025-04-18 10:09:46 +02:00
parent c3f07fcd6e
commit cb5a2a834f
11 changed files with 49 additions and 29 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -105,10 +105,10 @@ void UInteractableScreenCapturer::Process()
ENQUEUE_RENDER_COMMAND(GetInteractablesFromScreen)( ENQUEUE_RENDER_COMMAND(GetInteractablesFromScreen)(
[ [
capture = TextureTarget->GetResource()->TextureRHI, capture = TextureTarget->GetResource()->TextureRHI,
world = GetWorld(), world = GetWorld(),
view = view, view = view,
//output = _output->GetResource()->TextureRHI, //output = _output->GetResource()->TextureRHI,
this this
] ]
(FRHICommandListImmediate& RHICmdList) (FRHICommandListImmediate& RHICmdList)
{ {
@ -238,7 +238,7 @@ void UInteractableScreenCapturer::Process()
(FTranslationMatrix(-(view.Location)) (FTranslationMatrix(-(view.Location))
* (FInverseRotationMatrix(view.Rotation) * FMatrix(FPlane(0, 0, 1, 0), FPlane(1, 0, 0, 0), FPlane(0, 1, 0, 0), FPlane(0, 0, 0, 1))) * (FInverseRotationMatrix(view.Rotation) * FMatrix(FPlane(0, 0, 1, 0), FPlane(1, 0, 0, 0), FPlane(0, 1, 0, 0), FPlane(0, 0, 0, 1)))
* view.CalculateProjectionMatrix()) * view.CalculateProjectionMatrix())
.InverseFast(); .InverseFast(); // fast inverse errors about NIL matrix, aren't from here...
FVector worldLoc, worldDir; FVector worldLoc, worldDir;
for(int i = 1; i < components; ++i) for(int i = 1; i < components; ++i)
{ {

View File

@ -116,13 +116,19 @@ void APlayerBase::ResetInteractions()
activator->Rescan(); activator->Rescan();
} }
FVector APlayerBase::GetCameraLocation()
{
return camera->GetComponentLocation();
}
FVector APlayerBase::GetCameraDirection() FVector APlayerBase::GetCameraDirection()
{ {
return camera->GetForwardVector(); return camera->GetForwardVector();
} }
FVector APlayerBase::GetCameraLocation()
void APlayerBase::SetTransform(const FTransform transform)
{ {
return camera->GetComponentLocation(); SetActorLocation(transform.GetLocation(), false, nullptr, ETeleportType::ResetPhysics);
Controller->SetControlRotation(transform.GetRotation().Rotator());
} }
void APlayerBase::SwitchToCameraPawn() void APlayerBase::SwitchToCameraPawn()

View File

@ -57,6 +57,9 @@ public:
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
FVector GetCameraDirection(); FVector GetCameraDirection();
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Set Player Transform"))
void SetTransform(const FTransform transform);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void LockPlayer(const FPlayerLock lock); void LockPlayer(const FPlayerLock lock);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)

View File

@ -10,6 +10,11 @@
#include "PlayerBase.h" #include "PlayerBase.h"
#include "Widgets/WidgetsManager.h" #include "Widgets/WidgetsManager.h"
namespace
{
constexpr float failBlockAfterBegin = 0.2f;
}
int32 Event::counter = 0; int32 Event::counter = 0;
Event::Event() Event::Event()
@ -33,38 +38,31 @@ inline int32 Event::GetId()
void UQuickTimeEventManager::ShowQuickTimeEvent(FQuickTimeEventEnqueProperties properties) void UQuickTimeEventManager::ShowQuickTimeEvent(FQuickTimeEventEnqueProperties properties)
{ {
UE_LOG(LogTemp, Log, TEXT("ShowQuickTimeEvent Start"));
OnFirstEventInit(); OnFirstEventInit();
FScopeLock lock1(&lock); FScopeLock lock1(&lock);
CreateEvent(properties, false); CreateEvent(properties, false);
UE_LOG(LogTemp, Log, TEXT("ShowQuickTimeEvent End"));
} }
void UQuickTimeEventManager::EnqueQuickTimeEvent(FQuickTimeEventEnqueProperties properties) void UQuickTimeEventManager::EnqueQuickTimeEvent(FQuickTimeEventEnqueProperties properties)
{ {
UE_LOG(LogTemp, Log, TEXT("EnqueQuickTimeEvent Start"));
OnFirstEventInit(); OnFirstEventInit();
{ {
FScopeLock lock1(&lock); FScopeLock lock1(&lock);
nextEvents.Enqueue(properties); nextEvents.Enqueue(properties);
} }
ShowNextEvent(); ShowNextEvent();
UE_LOG(LogTemp, Log, TEXT("EnqueQuickTimeEvent End"));
} }
void UQuickTimeEventManager::ShowNextEvent() void UQuickTimeEventManager::ShowNextEvent()
{ {
UE_LOG(LogTemp, Log, TEXT("ShowNextEvent Start"));
FScopeLock lock1(&lock); FScopeLock lock1(&lock);
FQuickTimeEventEnqueProperties properties; FQuickTimeEventEnqueProperties properties;
nextEvents.Dequeue(properties); nextEvents.Dequeue(properties);
CreateEvent(properties, true); CreateEvent(properties, true);
UE_LOG(LogTemp, Log, TEXT("ShowNextEvent End"));
} }
void UQuickTimeEventManager::OnEventEnd(int32 id, EQuickTimeEventResult result) void UQuickTimeEventManager::OnEventEnd(int32 id, EQuickTimeEventResult result)
{ {
UE_LOG(LogTemp, Log, TEXT("OnEventEnd Start"));
FScopeLock lock1(&lock); FScopeLock lock1(&lock);
Event event; Event event;
if(!events.RemoveAndCopyValue(id, event)) if(!events.RemoveAndCopyValue(id, event))
@ -78,7 +76,6 @@ void UQuickTimeEventManager::OnEventEnd(int32 id, EQuickTimeEventResult result)
if(event.sequence && !nextEvents.IsEmpty()) if(event.sequence && !nextEvents.IsEmpty())
{ {
ShowNextEvent(); ShowNextEvent();
UE_LOG(LogTemp, Log, TEXT("OnEventEnd End"));
return; return;
} }
@ -90,8 +87,8 @@ void UQuickTimeEventManager::OnEventEnd(int32 id, EQuickTimeEventResult result)
PC->onAnyKeyReleased.RemoveDynamic(this, &UQuickTimeEventManager::OnInputReleased); PC->onAnyKeyReleased.RemoveDynamic(this, &UQuickTimeEventManager::OnInputReleased);
} }
UCommonFunctions::ExitSlowMotion(); UCommonFunctions::ExitSlowMotion();
inputBinded = false;
} }
UE_LOG(LogTemp, Log, TEXT("OnEventEnd End"));
} }
void UQuickTimeEventManager::OnInput(const FKey& key, bool released) void UQuickTimeEventManager::OnInput(const FKey& key, bool released)
@ -124,6 +121,10 @@ void UQuickTimeEventManager::OnInput(const FKey& key, bool released)
if(released) if(released)
return; return;
// events failed
if(sequenceBeginTimeStamp + failBlockAfterBegin > GetWorld()->GetTimeSeconds())
return;
if(auto WM = AMainGameModeBase::GetWidgetsManager()) if(auto WM = AMainGameModeBase::GetWidgetsManager())
{ {
while(events.Num() > 0) while(events.Num() > 0)
@ -141,24 +142,25 @@ void UQuickTimeEventManager::OnInput(const FKey& key, bool released)
void UQuickTimeEventManager::OnInputPressed(FKey key) void UQuickTimeEventManager::OnInputPressed(FKey key)
{ {
if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D) //if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D)
return; // return;
OnInput(key, false); OnInput(key, false);
} }
void UQuickTimeEventManager::OnInputReleased(FKey key) void UQuickTimeEventManager::OnInputReleased(FKey key)
{ {
if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D) //if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D)
return; // return;
OnInput(key, true); OnInput(key, true);
} }
void UQuickTimeEventManager::OnFirstEventInit() void UQuickTimeEventManager::OnFirstEventInit()
{ {
if(!events.IsEmpty()) if(!events.IsEmpty() || inputBinded)
return; return;
inputBinded = true;
if(auto PC = ACustomPlayerController::Get()) if(auto PC = ACustomPlayerController::Get())
{ {
@ -168,6 +170,7 @@ void UQuickTimeEventManager::OnFirstEventInit()
PC->onAnyKeyReleased.AddDynamic(this, &UQuickTimeEventManager::OnInputReleased); PC->onAnyKeyReleased.AddDynamic(this, &UQuickTimeEventManager::OnInputReleased);
}); });
} }
sequenceBeginTimeStamp = GetWorld()->GetTimeSeconds();
UCommonFunctions::EnterSlowMotion(); UCommonFunctions::EnterSlowMotion();
} }

View File

@ -92,4 +92,6 @@ protected:
TQueue<FQuickTimeEventEnqueProperties> nextEvents; TQueue<FQuickTimeEventEnqueProperties> nextEvents;
TMap<int32, Event> events; TMap<int32, Event> events;
FCriticalSection lock; FCriticalSection lock;
float sequenceBeginTimeStamp = 0; // used to block player fails right at begin
bool inputBinded = false;
}; };