From 368575b715de09168e13f7e0c50803a659a232c1 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 16 Jan 2024 20:51:38 +0000 Subject: [PATCH] Move cmc to if statement --- Source/Nakatomi/PlayerCharacter.cpp | 32 ++++++++--------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 4a0b98a..89ed4b1 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -280,9 +280,7 @@ void APlayerCharacter::QuitCallback(const FInputActionInstance& Instance) void APlayerCharacter::SetSprintingCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->EnableSprint(); } @@ -290,9 +288,7 @@ void APlayerCharacter::SetSprintingCallback(const FInputActionInstance& Instance void APlayerCharacter::SetWalkingCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->DisableSprint(); } @@ -483,9 +479,7 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In { IsADS = true; - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->EnableAds(); } @@ -511,9 +505,7 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst { IsADS = false; - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->DisableAds(); } @@ -548,9 +540,7 @@ void APlayerCharacter::PauseCallback(const FInputActionInstance& Instance) void APlayerCharacter::BeginCrouchCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->EnableCrouch(); } @@ -558,9 +548,7 @@ void APlayerCharacter::BeginCrouchCallback(const FInputActionInstance& Instance) void APlayerCharacter::EndCrouchCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->DisableCrouch(); } @@ -568,9 +556,7 @@ void APlayerCharacter::EndCrouchCallback(const FInputActionInstance& Instance) void APlayerCharacter::BeginSlideCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->EnableSlide(); } @@ -578,9 +564,7 @@ void APlayerCharacter::BeginSlideCallback(const FInputActionInstance& Instance) void APlayerCharacter::EndSlideCallback(const FInputActionInstance& Instance) { - UNakatomiCMC* cmc = GetCharacterMovementComponent(); - - if (cmc) + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->DisableSlide(); }