Level 3 Custom companion cube actors

This commit is contained in:
Oleg Petruny 2025-06-23 19:47:02 +02:00
parent aa6dad4e05
commit 20654327c0
15 changed files with 52 additions and 14 deletions

Binary file not shown.

Binary file not shown.

View File

@ -53,7 +53,7 @@ TArray<FString> UContentLoader::ParseDirectoryIndex(const TArray<uint8>& content
if(contentType == httpContentTypeHtml) if(contentType == httpContentTypeHtml)
{ {
std::string contentHtml{ reinterpret_cast<const char*>(content.GetData()), static_cast<size_t>(content.Num()) }; std::string contentHtml{ reinterpret_cast<const char*>(content.GetData()), static_cast<size_t>(content.Num()) };
std::regex hrefRegex(R"(<a href="((?!\.)[^"]+))"); std::regex hrefRegex(R"(<a href="((?!\.)[^"]+.pak))");
std::smatch match; std::smatch match;
auto it = contentHtml.cbegin(); auto it = contentHtml.cbegin();
auto end = contentHtml.cend(); auto end = contentHtml.cend();
@ -96,9 +96,11 @@ FString UContentLoader::SelectContentByMethod(const TArray<FString>& content, co
} }
} }
void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback, const EContentDownloadMethod method) void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback, const FString& directory, const EContentDownloadMethod method)
{ {
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Requesting pak http index at %s."), pakIndexUrl); const FString url = FString::Printf(TEXT("%s%s/"), pakIndexUrl, *directory);
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Requesting pak http index at %s."), *url);
FHttpRequestCompleteDelegate indexRequestCallback; FHttpRequestCompleteDelegate indexRequestCallback;
indexRequestCallback.BindLambda([=, this](FHttpRequestPtr request, FHttpResponsePtr response, bool successful) indexRequestCallback.BindLambda([=, this](FHttpRequestPtr request, FHttpResponsePtr response, bool successful)
@ -151,10 +153,10 @@ void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback,
}); });
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to download pak %s from index."), *pakToDownload); UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to download pak %s from index."), *pakToDownload);
HttpGet(FString::Printf(TEXT("%s%s"), pakIndexUrl, *pakToDownload), pakDownloadCallback); HttpGet(FString::Printf(TEXT("%s%s"), *url, *pakToDownload), pakDownloadCallback);
}); });
HttpGet(pakIndexUrl, indexRequestCallback); HttpGet(url, indexRequestCallback);
} }
UClass* UContentLoader::LoadPak(const FString& pakFilePath) UClass* UContentLoader::LoadPak(const FString& pakFilePath)

View File

@ -27,7 +27,7 @@ class UContentLoader : public UGameInstanceSubsystem
public: public:
UFUNCTION(BlueprintCallable, Category = "ContentLoader") UFUNCTION(BlueprintCallable, Category = "ContentLoader")
void DownloadPak(FContentDownloadedCallback downloadedCallback, const EContentDownloadMethod method = EContentDownloadMethod::NonRepeatRandom); void DownloadPak(FContentDownloadedCallback downloadedCallback, const FString& directory = "", const EContentDownloadMethod method = EContentDownloadMethod::NonRepeatRandom);
UFUNCTION(BlueprintCallable, Category = "ContentLoader") UFUNCTION(BlueprintCallable, Category = "ContentLoader")
UClass* LoadPak(const FString& pakFilePath); UClass* LoadPak(const FString& pakFilePath);

View File

@ -225,6 +225,9 @@ void UDialogueManager::BeginDestroy()
void UDialogueManager::OnDialogueEnd() void UDialogueManager::OnDialogueEnd()
{ {
if(!IsValid(this))
return;
timersLock.Lock(); timersLock.Lock();
timers.RemoveAt(leadDialogueTimerId); timers.RemoveAt(leadDialogueTimerId);
timersLock.Unlock(); timersLock.Unlock();

View File

@ -144,6 +144,11 @@ void UMoveInteractableModificator::TurnOnRotating()
FScopeLock lock1(&critical); FScopeLock lock1(&critical);
rotating = true; rotating = true;
player->LockPlayer({ .camera = true }); player->LockPlayer({ .camera = true });
if(positionUpdateType == PositionUpdateType::Physics)
{
primitive->SetEnableGravity(false);
//primitive->UpdatePhysicsVolume(false);
}
ProcessState(); ProcessState();
AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 1, EInputAnimatedWidgetAnimation::Hold); AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 1, EInputAnimatedWidgetAnimation::Hold);
OnRotating.Broadcast(); OnRotating.Broadcast();
@ -153,6 +158,11 @@ void UMoveInteractableModificator::TurnOffRotating()
FScopeLock lock1(&critical); FScopeLock lock1(&critical);
rotating = false; rotating = false;
player->UnlockPlayer({ .camera = true }); player->UnlockPlayer({ .camera = true });
if(positionUpdateType == PositionUpdateType::Physics)
{
primitive->SetEnableGravity(true);
//primitive->UpdatePhysicsVolume(false);
}
ProcessState(); ProcessState();
AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 1, EInputAnimatedWidgetAnimation::Unhold); AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 1, EInputAnimatedWidgetAnimation::Unhold);
} }
@ -187,6 +197,8 @@ void UMoveInteractableModificator::UpdatePosition()
auto camLoc = player->GetCameraLocation(); auto camLoc = player->GetCameraLocation();
auto dir = player->GetCameraDirection(); auto dir = player->GetCameraDirection();
auto newLoc = camLoc + dir * distance; auto newLoc = camLoc + dir * distance;
if(actor)
newLoc += actor->GetTransform().GetRotation().RotateVector(originOffset * actor->GetTransform().GetScale3D());
auto rot = actor->GetActorQuat(); auto rot = actor->GetActorQuat();
bool blocked = MoveIsBlocked(newLoc, rot) || player->nearScanner->ComponentOverlapComponent(primitive, newLoc, actor->GetActorQuat(), {}); bool blocked = MoveIsBlocked(newLoc, rot) || player->nearScanner->ComponentOverlapComponent(primitive, newLoc, actor->GetActorQuat(), {});

View File

@ -37,6 +37,9 @@ public:
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FRotatingMoveInteractableModificatorActivatedDelegate OnRotating; FRotatingMoveInteractableModificatorActivatedDelegate OnRotating;
UPROPERTY(EditDefaultsOnly)
FVector originOffset;
protected: protected:
float distance = 0; float distance = 0;
float minDistance = 100.0f; float minDistance = 100.0f;

View File

@ -160,7 +160,7 @@ void UWidgetsManager::AddOverlayWidget(UUserWidget* widget)
void UWidgetsManager::RemoveOverlayWidget(UUserWidget* widget) void UWidgetsManager::RemoveOverlayWidget(UUserWidget* widget)
{ {
overlayWidgetsInstances.Remove(widget); overlayWidgetsInstances.Remove(widget);
widget->RemoveFromViewport(); widget->RemoveFromParent();
} }
@ -189,7 +189,7 @@ void UWidgetsManager::SwitchCheatMenu()
void UWidgetsManager::ShowCheatMenu() void UWidgetsManager::ShowCheatMenu()
{ {
if(cheatMenuWidget || mainMenuWidget->Visibility == ESlateVisibility::Visible) if(cheatMenuWidget || mainMenuWidget->GetVisibility() == ESlateVisibility::Visible)
return; return;
if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0)) if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0))