Level 2 #12

Merged
oleg.petruny merged 14 commits from Level2 into master 2025-04-25 21:17:42 +00:00
11 changed files with 49 additions and 29 deletions
Showing only changes of commit cb5a2a834f - Show all commits

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)(
[
capture = TextureTarget->GetResource()->TextureRHI,
world = GetWorld(),
view = view,
//output = _output->GetResource()->TextureRHI,
this
world = GetWorld(),
view = view,
//output = _output->GetResource()->TextureRHI,
this
]
(FRHICommandListImmediate& RHICmdList)
{
@ -238,7 +238,7 @@ void UInteractableScreenCapturer::Process()
(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)))
* view.CalculateProjectionMatrix())
.InverseFast();
.InverseFast(); // fast inverse errors about NIL matrix, aren't from here...
FVector worldLoc, worldDir;
for(int i = 1; i < components; ++i)
{

View File

@ -116,13 +116,19 @@ void APlayerBase::ResetInteractions()
activator->Rescan();
}
FVector APlayerBase::GetCameraLocation()
{
return camera->GetComponentLocation();
}
FVector APlayerBase::GetCameraDirection()
{
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()

View File

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

View File

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

View File

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