From 60ba66b249fa3ad4caf859bd4ae991da20e5c372 Mon Sep 17 00:00:00 2001 From: Oleg Petruny Date: Fri, 13 Dec 2024 17:24:11 +0100 Subject: [PATCH] Minigame --- .../Private/CustomPlayerController.cpp | 2 ++ .../Lost_Edge/Private/Levels/LevelBase.cpp | 3 --- .../Minigame/AgeOfWar/AgeOfWarManager.cpp | 1 - .../Minigame/AgeOfWar/AgeOfWarUnit.cpp | 3 +-- .../Minigame/CrossyRoad/CrossyRoadManager.cpp | 1 - .../CrossyRoad/CrossyRoadObstacle.cpp | 1 - .../Minigame/Fishing/FishingManager.cpp | 1 - .../Lost_Edge/Private/Minigame/Minigame.cpp | 19 +++-------------- .../Lost_Edge/Private/Minigame/Minigame.h | 21 ++++++++++++------- .../Minigame/RythmClick/RythmClickManager.cpp | 1 - .../Minigame/SubwaySurf/SubwaySurfManager.cpp | 1 - .../SubwaySurf/SubwaySurfObstacle.cpp | 1 - .../Private/Widgets/AutohideWidget.cpp | 1 - .../Widgets/DialogueRowWidgetManager.cpp | 1 - .../Widgets/InteractableHintWidgetManager.cpp | 1 - .../Private/Widgets/JournalWidget.cpp | 1 - .../Widgets/MainMenu/MainMenuButtonWidget.cpp | 1 - .../Widgets/MainMenu/MainMenuWidget.cpp | 1 - .../Private/Widgets/QuickTimeEventWidget.cpp | 1 - .../Widgets/QuickTimeEventWidgetManager.cpp | 1 - .../ResolutionResponsiveUserWidget.cpp | 1 - .../Private/Widgets/WidgetsManager.cpp | 1 - .../WorldDilationResponsiveUserWidget.cpp | 1 - 23 files changed, 20 insertions(+), 46 deletions(-) diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomPlayerController.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomPlayerController.cpp index 3a292c3..1ce78c3 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomPlayerController.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomPlayerController.cpp @@ -27,6 +27,8 @@ void ACustomPlayerController::AppendInputContext(TSoftObjectPtr(GetLocalPlayer()); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Levels/LevelBase.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Levels/LevelBase.cpp index 15c7cd7..128707d 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Levels/LevelBase.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Levels/LevelBase.cpp @@ -23,9 +23,6 @@ void ALevelBase::BeginPlay() { AMainGameModeBase::leadLevel = TStrongObjectPtr{ this }; - for(TActorIterator it(GetWorld()); it; ++it) - ACustomPlayerController::AppendInputContext(it->GetInputMappings()); - ALevelScriptActor::BeginPlay(); BroadcastNewLevelBeginPlay(); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp index 659903b..25e6951 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "AgeOfWarManager.h" #include "Camera/CameraComponent.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp index 88a4826..d09c3bb 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp @@ -1,12 +1,11 @@ // Oleg Petruny proprietary. - #include "AgeOfWarUnit.h" +#include "Components/BoxComponent.h" #include "Components/StaticMeshComponent.h" #include "AgeOfWarManager.h" -#include namespace { diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp index b89df9b..31ab03a 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "CrossyRoadManager.h" #include "Camera/CameraComponent.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadObstacle.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadObstacle.cpp index ea3af7e..6b87dd7 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadObstacle.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadObstacle.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "CrossyRoadObstacle.h" #include "CrossyRoadManager.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Fishing/FishingManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Fishing/FishingManager.cpp index ac52d4a..f30d2b4 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Fishing/FishingManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Fishing/FishingManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "FishingManager.h" #include "EnhancedInputComponent.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.cpp index e8aee09..0920fac 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.cpp @@ -1,11 +1,8 @@ // Oleg Petruny proprietary. - #include "Minigame.h" -#include "EnhancedInputSubsystems.h" -#include "InputMappingContext.h" - +#include "CustomPlayerController.h" #include "PlayerBase.h" AMinigame::AMinigame() @@ -22,23 +19,13 @@ void AMinigame::End() OnEnd(); } -void AMinigame::Restart() -{} - -UInputMappingContext* AMinigame::GetInputMappings() -{ - return context.LoadSynchronous(); -} - void AMinigame::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate) { player = playerPawn; callback = delegate; - if(context) - if(auto PC = Cast(playerPawn->GetController())) - if(auto inputSubsystem = ULocalPlayer::GetSubsystem(PC->GetLocalPlayer())) - inputSubsystem->AddMappingContext(context.LoadSynchronous(), 0); + if(context.IsValid()) + ACustomPlayerController::AppendInputContext(context); OnStart(); } diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.h index 5c940c8..f1f7fdc 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/Minigame.h @@ -15,7 +15,14 @@ enum class EMinigameResult : uint8 DECLARE_DYNAMIC_DELEGATE_TwoParams(FMinigameEndCallback, EMinigameResult, result, int32, score); -UCLASS(Blueprintable, BlueprintType, MinimalAPI, Abstract) +/** + * Interface for all minigame classes. + * Any minigame is started/ended/restarted by executing Start()/End()/Restart() on specific instance. + * Each call is after broadcasted into a blueprint event also. + * On start the caller can pass a OnEndCallback delegate to receive result and score on a minigame end. + * Each minigame can have its own contextInput + */ +UCLASS(Abstract, Blueprintable, BlueprintType, MinimalAPI) class AMinigame : public AActor { GENERATED_BODY() @@ -25,21 +32,21 @@ public: UFUNCTION(BlueprintCallable) virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate); - UFUNCTION(BlueprintImplementableEvent) void OnStart(); UFUNCTION(BlueprintCallable) virtual void End(); - - UFUNCTION(BlueprintCallable) - virtual void Restart(); - UFUNCTION(BlueprintImplementableEvent) void OnEnd(); + UFUNCTION(BlueprintCallable) + virtual void Restart() {} + UFUNCTION(BlueprintImplementableEvent) + void OnRestart(); + UFUNCTION(BlueprintPure) - class UInputMappingContext* GetInputMappings(); + TSoftObjectPtr GetInputMappings() { return context; } protected: FMinigameEndCallback callback; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/RythmClick/RythmClickManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/RythmClick/RythmClickManager.cpp index 297e092..c664b22 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/RythmClick/RythmClickManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/RythmClick/RythmClickManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "RythmClickManager.h" #include "MainGameModeBase.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp index f89c289..35bde19 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "SubwaySurfManager.h" #include "Camera/CameraComponent.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfObstacle.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfObstacle.cpp index 5d0c284..254c31c 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfObstacle.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfObstacle.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "SubwaySurfObstacle.h" #include "SubwaySurfManager.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/AutohideWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/AutohideWidget.cpp index 9a9a46d..7fb9b72 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/AutohideWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/AutohideWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "AutohideWidget.h" #include "Animation/WidgetAnimation.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/DialogueRowWidgetManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/DialogueRowWidgetManager.cpp index 244c9b4..f046524 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/DialogueRowWidgetManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/DialogueRowWidgetManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "DialogueRowWidgetManager.h" #include "Blueprint/WidgetTree.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp index 2a468ca..da185b9 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "InteractableHintWidgetManager.h" #include "Blueprint/WidgetTree.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/JournalWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/JournalWidget.cpp index 3c7ebcf..ee24222 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/JournalWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/JournalWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "JournalWidget.h" #include "Blueprint/WidgetTree.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuButtonWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuButtonWidget.cpp index b6ef69e..153fc08 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuButtonWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuButtonWidget.cpp @@ -1,5 +1,4 @@ // Oleg Petruny proprietary. - #include "MainMenuButtonWidget.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp index 70e211a..e404e08 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "MainMenuWidget.h" #include "Animation/WidgetAnimation.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidget.cpp index b34b551..56923d7 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "QuickTimeEventWidget.h" #include "Animation/WidgetAnimation.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidgetManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidgetManager.cpp index dfce74d..142247c 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidgetManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/QuickTimeEventWidgetManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "QuickTimeEventWidgetManager.h" #include "Animation/UMGSequencePlayer.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveUserWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveUserWidget.cpp index 43fe3a5..fbfedde 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveUserWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/ResolutionResponsiveUserWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "ResolutionResponsiveUserWidget.h" #include "Components/PanelSlot.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp index 3c5b6e9..1bf8772 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "WidgetsManager.h" #include "Blueprint/UserWidget.h" diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WorldDilationResponsiveUserWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WorldDilationResponsiveUserWidget.cpp index 1216c89..e427bd5 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WorldDilationResponsiveUserWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/WorldDilationResponsiveUserWidget.cpp @@ -1,6 +1,5 @@ // Oleg Petruny proprietary. - #include "WorldDilationResponsiveUserWidget.h" #include "Animation/UMGSequencePlayer.h"