Skip to content

Commit

Permalink
Code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dyanikoglu committed Dec 1, 2020
1 parent 3c8da75 commit 8263750
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 51 deletions.
5 changes: 4 additions & 1 deletion Source/ALSV4_CPP/Private/Character/AI/ALSAIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ AALSAIController::AALSAIController()
static ConstructorHelpers::FObjectFinder<UBehaviorTree> BehaviourDefault(
TEXT("/ALSV4_CPP/AdvancedLocomotionV4/Blueprints/CharacterLogic/AI/ALS_BT_AICharacter"));

Behaviour = BehaviourDefault.Object;
if (BehaviourDefault.Succeeded())
{
Behaviour = BehaviourDefault.Object;
}
}

void AALSAIController::OnPossess(APawn* InPawn)
Expand Down
10 changes: 5 additions & 5 deletions Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ void AALSBaseCharacter::SetAcceleration(const FVector& NewAcceleration)
void AALSBaseCharacter::RagdollUpdate(float DeltaTime)
{
// Set the Last Ragdoll Velocity.
FVector NewRagdollVel = GetMesh()->GetPhysicsLinearVelocity(FName(TEXT("root")));
const FVector NewRagdollVel = GetMesh()->GetPhysicsLinearVelocity(FName(TEXT("root")));
LastRagdollVelocity = (NewRagdollVel != FVector::ZeroVector || IsLocallyControlled())
? NewRagdollVel
: LastRagdollVelocity / 2;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void AALSBaseCharacter::UpdateDynamicMovementSettingsStandalone(EALSGait Allowed
{
// Get the Current Movement Settings.
CurrentMovementSettings = GetTargetMovementSettings();
float NewMaxSpeed = CurrentMovementSettings.GetSpeedForGait(AllowedGait);
const float NewMaxSpeed = CurrentMovementSettings.GetSpeedForGait(AllowedGait);

// Update the Acceleration, Deceleration, and Ground Friction using the Movement Curve.
// This allows for fine control over movement behavior at each speed (May not be suitable for replication).
Expand All @@ -1036,7 +1036,7 @@ void AALSBaseCharacter::UpdateDynamicMovementSettingsNetworked(EALSGait AllowedG
{
// Get the Current Movement Settings.
CurrentMovementSettings = GetTargetMovementSettings();
float NewMaxSpeed = CurrentMovementSettings.GetSpeedForGait(AllowedGait);
const float NewMaxSpeed = CurrentMovementSettings.GetSpeedForGait(AllowedGait);

// Update the Character Max Walk Speed to the configured speeds based on the currently Allowed Gait.
if (IsLocallyControlled() || HasAuthority())
Expand Down Expand Up @@ -1489,8 +1489,8 @@ void AALSBaseCharacter::GetControlForwardRightVector(FVector& Forward, FVector&

FVector AALSBaseCharacter::GetPlayerMovementInput() const
{
FVector Forward;
FVector Right;
FVector Forward = FVector::ZeroVector;
FVector Right = FVector::ZeroVector;
GetControlForwardRightVector(Forward, Right);
return (Forward + Right).GetSafeNormal();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ALSV4_CPP/Private/Character/ALSCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void AALSCharacter::RagdollEnd()

ECollisionChannel AALSCharacter::GetThirdPersonTraceParams(FVector& TraceOrigin, float& TraceRadius)
{
FName CameraSocketName = bRightShoulder ? TEXT("TP_CameraTrace_R") : TEXT("TP_CameraTrace_L");
const FName CameraSocketName = bRightShoulder ? TEXT("TP_CameraTrace_R") : TEXT("TP_CameraTrace_L");
TraceOrigin = GetMesh()->GetSocketLocation(CameraSocketName);
TraceRadius = 15.0f;
return ECC_Camera;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void UALSCharacterAnimInstance::UpdateMovementValues(float DeltaSeconds)
VelocityBlend.L = FMath::FInterpTo(VelocityBlend.L, TargetBlend.L, DeltaSeconds, Config.VelocityBlendInterpSpeed);
VelocityBlend.R = FMath::FInterpTo(VelocityBlend.R, TargetBlend.R, DeltaSeconds, Config.VelocityBlendInterpSpeed);

// Set the Diagnal Scale Amount.
// Set the Diagonal Scale Amount.
Grounded.DiagonalScaleAmount = CalculateDiagonalScaleAmount();

// Set the Relative Acceleration Amount and Interp the Lean Amount.
Expand Down
37 changes: 19 additions & 18 deletions Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

virtual void PostInitializeComponents() override;

void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

/** Ragdoll System */

Expand Down Expand Up @@ -357,13 +357,13 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

virtual void OnOverlayStateChanged(EALSOverlayState PreviousState);

void OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;
virtual void OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;

void OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;
virtual void OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;

void OnJumped_Implementation() override;
virtual void OnJumped_Implementation() override;

void Landed(const FHitResult& Hit) override;
virtual void Landed(const FHitResult& Hit) override;

void OnLandFrictionReset();

Expand Down Expand Up @@ -455,6 +455,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

protected:
/* Custom movement component*/
UPROPERTY()
UALSCharacterMovementComponent* MyCharacterMovementComponent;

/** Input */
Expand Down Expand Up @@ -535,7 +536,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
/** Essential Information */

UPROPERTY(BlueprintReadOnly, Category = "ALS|Essential Information")
FVector Acceleration;
FVector Acceleration = FVector::ZeroVector;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Essential Information")
bool bIsMoving = false;
Expand All @@ -561,13 +562,13 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
/** Replicated Essential Information*/

UPROPERTY(BlueprintReadOnly, Category = "ALS|Essential Information")
float EasedMaxAcceleration;
float EasedMaxAcceleration = 0.0f;

UPROPERTY(BlueprintReadOnly, Replicated, Category = "ALS|Essential Information")
FVector ReplicatedCurrentAcceleration;
FVector ReplicatedCurrentAcceleration = FVector::ZeroVector;

UPROPERTY(BlueprintReadOnly, Replicated, Category = "ALS|Essential Information")
FRotator ReplicatedControlRotation;
FRotator ReplicatedControlRotation = FRotator::ZeroRotator;

/** State Values */

Expand Down Expand Up @@ -600,10 +601,10 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
/** Rotation System */

UPROPERTY(BlueprintReadOnly, Category = "ALS|Rotation System")
FRotator TargetRotation;
FRotator TargetRotation = FRotator::ZeroRotator;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Rotation System")
FRotator InAirRotation;
FRotator InAirRotation = FRotator::ZeroRotator;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Rotation System")
float YawOffset = 0.0f;
Expand All @@ -617,13 +618,13 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
FALSComponentAndTransform MantleLedgeLS;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Mantle System")
FTransform MantleTarget;
FTransform MantleTarget = FTransform::Identity;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Mantle System")
FTransform MantleActualStartOffset;
FTransform MantleActualStartOffset = FTransform::Identity;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Mantle System")
FTransform MantleAnimatedStartOffset;
FTransform MantleAnimatedStartOffset = FTransform::Identity;

/** Breakfall System */

Expand Down Expand Up @@ -654,10 +655,10 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
bool bRagdollFaceUp = false;

UPROPERTY(BlueprintReadOnly, Category = "ALS|Ragdoll System")
FVector LastRagdollVelocity;
FVector LastRagdollVelocity = FVector::ZeroVector;

UPROPERTY(BlueprintReadOnly, Replicated, Category = "ALS|Ragdoll System")
FVector TargetRagdollLocation;
FVector TargetRagdollLocation = FVector::ZeroVector;

/* Server ragdoll pull force storage*/
float ServerRagdollPull = 0.0f;
Expand All @@ -667,7 +668,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

/** Cached Variables */

FVector PreviousVelocity;
FVector PreviousVelocity = FVector::ZeroVector;

float PreviousAimYaw = 0.0f;

Expand All @@ -687,7 +688,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
FTimerHandle OnLandedFrictionResetTimer;

/* Smooth out aiming by interping control rotation*/
FRotator AimingRotation;
FRotator AimingRotation = FRotator::ZeroRotator;

/** We won't use curve based movement on networked games */
bool bDisableCurvedMovement = false;
Expand Down
1 change: 1 addition & 0 deletions Source/ALSV4_CPP/Public/Character/ALSPlayerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class ALSV4_CPP_API AALSPlayerController : public APlayerController

private:
/** Main character reference */
UPROPERTY()
AALSBaseCharacter* PossessedCharacter = nullptr;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class ALSV4_CPP_API UALSCharacterAnimInstance : public UAnimInstance
GENERATED_BODY()

public:
void NativeInitializeAnimation() override;
virtual void NativeInitializeAnimation() override;

void NativeUpdateAnimation(float DeltaSeconds) override;
virtual void NativeUpdateAnimation(float DeltaSeconds) override;

UFUNCTION(BlueprintCallable)
void PlayTransition(const FALSDynamicMontageParams& Parameters);
Expand Down Expand Up @@ -210,7 +210,7 @@ class ALSV4_CPP_API UALSCharacterAnimInstance : public UAnimInstance
FALSLeanAmount LeanAmount;

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Read Only Data|Anim Graph - Grounded")
FVector RelativeAccelerationAmount;
FVector RelativeAccelerationAmount = FVector::ZeroVector;

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Read Only Data|Anim Graph - Grounded")
FALSGroundedEntryState GroundedEntryState = EALSGroundedEntryState::None;
Expand All @@ -229,7 +229,7 @@ class ALSV4_CPP_API UALSCharacterAnimInstance : public UAnimInstance
FALSAnimGraphAimingValues AimingValues;
public:
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Read Only Data|Anim Graph - Aiming Values")
FVector2D SmoothedAimingAngle;
FVector2D SmoothedAimingAngle = FVector2D::ZeroVector;
protected:
/** Anim Graph - Ragdoll */
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Read Only Data|Anim Graph - Ragdoll")
Expand Down Expand Up @@ -263,34 +263,34 @@ class ALSV4_CPP_API UALSCharacterAnimInstance : public UAnimInstance
/** Blend Curves */

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* DiagonalScaleAmountCurve;
UCurveFloat* DiagonalScaleAmountCurve = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* StrideBlend_N_Walk;
UCurveFloat* StrideBlend_N_Walk = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* StrideBlend_N_Run;
UCurveFloat* StrideBlend_N_Run = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* StrideBlend_C_Walk;
UCurveFloat* StrideBlend_C_Walk = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* LandPredictionCurve;
UCurveFloat* LandPredictionCurve = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveFloat* LeanInAirCurve;
UCurveFloat* LeanInAirCurve = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveVector* YawOffset_FB;
UCurveVector* YawOffset_FB = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Blend Curves")
UCurveVector* YawOffset_LR;
UCurveVector* YawOffset_LR = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Dynamic Transition")
UAnimSequenceBase* TransitionAnim_R;
UAnimSequenceBase* TransitionAnim_R = nullptr;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Configuration|Dynamic Transition")
UAnimSequenceBase* TransitionAnim_L;
UAnimSequenceBase* TransitionAnim_L = nullptr;

private:
FTimerHandle OnPivotTimer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ALSV4_CPP_API UALSPlayerCameraBehavior : public UAnimInstance
APlayerController* PlayerController = nullptr;

protected:
void NativeUpdateAnimation(float DeltaSeconds) override;
virtual void NativeUpdateAnimation(float DeltaSeconds) override;

protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ALSV4_CPP_API UALSAnimNotifyCameraShake : public UAnimNotify
{
GENERATED_BODY()

void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class ALSV4_CPP_API UALSAnimNotifyFootstep : public UAnimNotify
{
GENERATED_BODY()

void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

FString GetNotifyName_Implementation() const override;
virtual FString GetNotifyName_Implementation() const override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ALSV4_CPP_API UALSAnimNotifyGroundedEntryState : public UAnimNotify
{
GENERATED_BODY()

void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

FString GetNotifyName_Implementation() const override;
virtual FString GetNotifyName_Implementation() const override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ALSV4_CPP_API UALSNotifyStateEarlyBlendOut : public UAnimNotifyState
{
GENERATED_BODY()

void NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime) override;
virtual void NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime) override;

FString GetNotifyName_Implementation() const override;
virtual FString GetNotifyName_Implementation() const override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ALSV4_CPP_API UALSNotifyStateMovementAction : public UAnimNotifyState

virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

FString GetNotifyName_Implementation() const override;
virtual FString GetNotifyName_Implementation() const override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ALSV4_CPP_API UALSNotifyStateOverlayOverride : public UAnimNotifyState

virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

FString GetNotifyName_Implementation() const override;
virtual FString GetNotifyName_Implementation() const override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AnimNotify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct FALSMovementSettings
UPROPERTY(EditAnywhere)
UCurveFloat* RotationRateCurve = nullptr;

float GetSpeedForGait(EALSGait Gait)
float GetSpeedForGait(EALSGait Gait) const
{
switch (Gait)
{
Expand Down

0 comments on commit 8263750

Please sign in to comment.