From 707804bf5439f19b737d813d5f03248d0353072d Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Mon, 9 Jan 2023 17:42:12 -0500 Subject: [PATCH] Main menu to in game flow --- .../Content/Characters/BP_GSCharacter.uasset | 4 +-- .../Content/Core/BP_GSDefaultGameMode.uasset | 4 +-- .../Content/Core/BP_GSGameState.uasset | 3 ++ GravityStomp/Content/Maps/Debug/Test.umap | 4 +-- .../Blueprints/BP_MainMenuGameMode.uasset | 4 +-- .../BP_MainMenuPlayerController.uasset | 4 +-- .../UI/MainMenu/Widgets/WBP_MainMenu.uasset | 4 +-- .../MainMenu/Widgets/WBP_PlayerLobby.uasset | 4 +-- .../Widgets/WBP_PlayerLobbySubMenu.uasset | 4 +-- .../Character/GSCharacter.cpp | 32 +++++++++++-------- .../GravityStompGame/Character/GSCharacter.h | 17 ++-------- .../GameModes/GSGameModeBase.cpp | 5 ++- .../GameModes/GSGameModeBase.h | 6 +--- .../Player/GSPlayerController.cpp | 2 ++ 14 files changed, 46 insertions(+), 51 deletions(-) create mode 100644 GravityStomp/Content/Core/BP_GSGameState.uasset diff --git a/GravityStomp/Content/Characters/BP_GSCharacter.uasset b/GravityStomp/Content/Characters/BP_GSCharacter.uasset index 754dc7a..a7ebf57 100644 --- a/GravityStomp/Content/Characters/BP_GSCharacter.uasset +++ b/GravityStomp/Content/Characters/BP_GSCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:72e794b6e5cdf8f2b5df8bb0d49686028b607a37e48b99197235ecf42c4d90a8 -size 35522 +oid sha256:d94c2241734b43189f5520ed0c9bde716f020b67b8231b139429e94a19549d35 +size 34717 diff --git a/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset b/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset index 75d5582..d0e31a7 100644 --- a/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset +++ b/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:71ac319d3c498105d343f0cc842f0e76c9d33533ebb6798a4ac660b7f60d1707 -size 19808 +oid sha256:e906267de0e2fe0870a99c5f5167ccec9b532b7cebc6db79158ae0a407f6926e +size 33169 diff --git a/GravityStomp/Content/Core/BP_GSGameState.uasset b/GravityStomp/Content/Core/BP_GSGameState.uasset new file mode 100644 index 0000000..3f1dcd1 --- /dev/null +++ b/GravityStomp/Content/Core/BP_GSGameState.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bcd95e5a0fa70b1811c8405218427e689bdc20b6e704b74bda3082eadbbae72 +size 35395 diff --git a/GravityStomp/Content/Maps/Debug/Test.umap b/GravityStomp/Content/Maps/Debug/Test.umap index 2a4d180..49ea4ac 100644 --- a/GravityStomp/Content/Maps/Debug/Test.umap +++ b/GravityStomp/Content/Maps/Debug/Test.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4870c44cb5b95b2a8c6e9d170e9858e0f6f21636819654518ae21c2697fc179a -size 47603 +oid sha256:cad996f813e5c2b6db3ad6c1b080ed5ca51ea72dc0c070cdac85afd5e253f48c +size 48549 diff --git a/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuGameMode.uasset b/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuGameMode.uasset index ea98f3b..a54ee40 100644 --- a/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuGameMode.uasset +++ b/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f32613660085a31606977e9f42fccb6f655acf9057c3f10363ed74ac27eec7fe -size 182479 +oid sha256:615a777c582778522176e7b572f9958c79750b0b0959ec5eb022375140b92671 +size 243549 diff --git a/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuPlayerController.uasset b/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuPlayerController.uasset index b01b4b9..cb415e1 100644 --- a/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuPlayerController.uasset +++ b/GravityStomp/Content/UI/MainMenu/Blueprints/BP_MainMenuPlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1989a05c6ffd0d0ebcb77e77884d7d546c437e9b4f4cf4df7a2459f95d49911 -size 44767 +oid sha256:38306a41c745140d8a12f5886f4672f92379d9b65fcc7b54ea0aaf260f15a4cc +size 67753 diff --git a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_MainMenu.uasset b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_MainMenu.uasset index f64d037..65b45b2 100644 --- a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_MainMenu.uasset +++ b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_MainMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc329117263ca254285b8de31b3e7d797f335c8683c52ede0126a27c1c4543f2 -size 233653 +oid sha256:427192b8572c38db17febb6419724365df2d97de9d5e9112b10b0c11d1a97397 +size 263855 diff --git a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobby.uasset b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobby.uasset index ea3f243..e4a6309 100644 --- a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobby.uasset +++ b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobby.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f735f8d5609b4ba99665cdd0ef0781a7e6f27fdc5b2c775eeec0541329c698f -size 45037 +oid sha256:dbbe42b9e378d1b0e93c4052c98738c400ab4774074dc03015627faacfef8404 +size 120368 diff --git a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobbySubMenu.uasset b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobbySubMenu.uasset index 88ffe50..ba9e092 100644 --- a/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobbySubMenu.uasset +++ b/GravityStomp/Content/UI/MainMenu/Widgets/WBP_PlayerLobbySubMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f4b90cac56917ff51f556738f10e95114e7c81338bf0d8b266f418bc9df1c22 -size 154621 +oid sha256:656696bb5cfa4906a10d93e68c0bcaaee6da41d209b15bb0d8d19995a091be5c +size 161105 diff --git a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp index 5bc0705..364b19a 100644 --- a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp +++ b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp @@ -39,19 +39,6 @@ AGSCharacter::AGSCharacter(const FObjectInitializer& ObjectInitializer) GetCharacterMovement()->MinAnalogWalkSpeed = 20.f; GetCharacterMovement()->BrakingDecelerationWalking = 2000.f; - // Create a camera boom (pulls in towards the player if there is a collision) - CameraBoom = CreateDefaultSubobject(TEXT("CameraBoom")); - CameraBoom->SetupAttachment(RootComponent); - CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character - CameraBoom->bUsePawnControlRotation = false; // Rotate the arm based on the controller - - CameraBoom->SetWorldRotation(FVector::ForwardVector.Rotation()); - - // Create a follow camera - FollowCamera = CreateDefaultSubobject(TEXT("FollowCamera")); - FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation - FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm - // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) // are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++) } @@ -126,3 +113,22 @@ void AGSCharacter::ChangeGravityDirection(const FInputActionValue& Value) GetCharacterMovement()->SetCharacterUpDirection(NewCharacterUpDirection); } + +void AGSCharacter::PawnClientRestart() +{ + Super::PawnClientRestart(); + + // Make sure that we have a valid PlayerController. + if (APlayerController* PC = Cast(GetController())) + { + // Get the Enhanced Input Local Player Subsystem from the Local Player related to our Player Controller. + if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem(PC->GetLocalPlayer())) + { + // PawnClientRestart can run more than once in an Actor's lifetime, so start by clearing out any leftover mappings. + Subsystem->ClearAllMappings(); + + // Add each mapping context, along with their priority values. Higher values outprioritize lower values. + Subsystem->AddMappingContext(DefaultMappingContext, 0); + } + } +} diff --git a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.h b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.h index 6f2c261..3cbe194 100644 --- a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.h +++ b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.h @@ -13,14 +13,6 @@ class AGSCharacter : public ACharacter { GENERATED_BODY() - /** Camera boom positioning the camera behind the character */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) - class USpringArmComponent* CameraBoom; - - /** Follow camera */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) - class UCameraComponent* FollowCamera; - /** MappingContext */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) class UInputMappingContext* DefaultMappingContext; @@ -45,17 +37,14 @@ protected: /** Called when the player changes the gravity direction */ void ChangeGravityDirection(const FInputActionValue& Value); +public: + virtual void PawnClientRestart() override; + protected: // APawn interface virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; // To add mapping context virtual void BeginPlay(); - -public: - /** Returns CameraBoom subobject **/ - FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } - /** Returns FollowCamera subobject **/ - FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } }; diff --git a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp index 30ba24c..99cedc8 100644 --- a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp +++ b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp @@ -15,8 +15,7 @@ AGSGameModeBase::AGSGameModeBase() TimeBetweenRounds = 20.0f; RoundTime = 600.0f; WarmupTime = 15.0f; - bWarmupEnabled = true; - bDelayedStart = bWarmupEnabled; + bDelayedStart = true; PlayerControllerClass = AGSPlayerController::StaticClass(); PlayerStateClass = AGSPlayerState::StaticClass(); @@ -253,7 +252,7 @@ void AGSGameModeBase::HandleMatchIsWaitingToStart() AGSGameState* GS = GetGameState(); if(GS && GS->GetRemainingTime() <= 0) { - if(bWarmupEnabled) + if(bDelayedStart) { GS->SetRemainingTime(WarmupTime); } diff --git a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h index b449cf3..ff6c782 100644 --- a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h +++ b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h @@ -117,11 +117,7 @@ protected: // duration of the pre-match/warmup period, in seconds UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Settings, meta = (ClampMin = 0)) - float WarmupTime;; - - // whether or not there is a warmup or the round should immediately start - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Settings) - bool bWarmupEnabled; + float WarmupTime; FTimerHandle TimerHandle_DefaultTimer; }; diff --git a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp index aff6915..d4e3d38 100644 --- a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp +++ b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp @@ -4,6 +4,8 @@ void AGSPlayerController::Client_GameStarted_Implementation() { + FInputModeGameOnly GameOnly; + SetInputMode(GameOnly); SetIgnoreMoveInput(false); // enable all actions on pawn