style: fix include sequence

This commit is contained in:
2026-01-17 01:56:46 +08:00
parent 280ee428b7
commit 02ab1b45ba
3 changed files with 53 additions and 35 deletions

View File

@@ -101,6 +101,16 @@ ColumnLimit: 110
# 排序include
SortIncludes: true
IncludeCategories:
# 1. 匹配所有 .generated.h 文件,给它一个极大的优先级数字(比如 99)
# 数字越大,排序越靠后
- Regex: '.*\.generated\.h'
Priority: 99
# 2. 匹配其他所有文件,优先级设为 1
- Regex: '.*'
Priority: 1
# 注释前面需要有1个空格
SpacesBeforeTrailingComments: 1

View File

@@ -12,8 +12,13 @@ class UInputAction;
class UInputComponent;
class UPawnNoiseEmitterComponent;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBulletCountUpdatedDelegate, int32, MagazineSize, int32, Bullets)
;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(
FBulletCountUpdatedDelegate,
int32,
MagazineSize,
int32,
Bullets
);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDamagedDelegate, float, LifePercent);
@@ -27,43 +32,48 @@ class FIRSTPERSONDEMO_API AShooterCharacter : public AFirstPersonDemoCharacter,
GENERATED_BODY()
/** AI Noise emitter component */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
UPROPERTY(
VisibleAnywhere,
BlueprintReadOnly,
Category = "Components",
meta = (AllowPrivateAccess = "true")
)
UPawnNoiseEmitterComponent* PawnNoiseEmitter;
protected:
/** Fire weapon input action */
UPROPERTY(EditAnywhere, Category ="Input")
UPROPERTY(EditAnywhere, Category = "Input")
UInputAction* FireAction;
/** Switch weapon input action */
UPROPERTY(EditAnywhere, Category ="Input")
UPROPERTY(EditAnywhere, Category = "Input")
UInputAction* SwitchWeaponAction;
/** Name of the first person mesh weapon socket */
UPROPERTY(EditAnywhere, Category ="Weapons")
UPROPERTY(EditAnywhere, Category = "Weapons")
FName FirstPersonWeaponSocket = FName("HandGrip_R");
/** Name of the third person mesh weapon socket */
UPROPERTY(EditAnywhere, Category ="Weapons")
UPROPERTY(EditAnywhere, Category = "Weapons")
FName ThirdPersonWeaponSocket = FName("HandGrip_R");
/** Max distance to use for aim traces */
UPROPERTY(EditAnywhere, Category ="Aim", meta = (ClampMin = 0, ClampMax = 100000, Units = "cm"))
UPROPERTY(EditAnywhere, Category = "Aim", meta = (ClampMin = 0, ClampMax = 100000, Units = "cm"))
float MaxAimDistance = 10000.0f;
/** Max HP this character can have */
UPROPERTY(EditAnywhere, Category="Health")
UPROPERTY(EditAnywhere, Category = "Health")
float MaxHP = 500.0f;
/** Current HP remaining to this character */
float CurrentHP = 0.0f;
/** Team ID for this character*/
UPROPERTY(EditAnywhere, Category="Team")
UPROPERTY(EditAnywhere, Category = "Team")
uint8 TeamByte = 0;
/** Actor tag to grant this character when it dies */
UPROPERTY(EditAnywhere, Category="Team")
UPROPERTY(EditAnywhere, Category = "Team")
FName DeathTag = FName("Dead");
/** List of weapons picked up by the character */
@@ -72,7 +82,7 @@ protected:
/** Weapon currently equipped and ready to shoot with */
TObjectPtr<AShooterWeapon> CurrentWeapon;
UPROPERTY(EditAnywhere, Category ="Destruction", meta = (ClampMin = 0, ClampMax = 10, Units = "s"))
UPROPERTY(EditAnywhere, Category = "Destruction", meta = (ClampMin = 0, ClampMax = 10, Units = "s"))
float RespawnTime = 5.0f;
FTimerHandle RespawnTimer;
@@ -100,10 +110,12 @@ protected:
public:
/** Handle incoming damage */
virtual float TakeDamage(float Damage,
const struct FDamageEvent& DamageEvent,
AController* EventInstigator,
AActor* DamageCauser) override;
virtual float TakeDamage(
float Damage,
const struct FDamageEvent& DamageEvent,
AController* EventInstigator,
AActor* DamageCauser
) override;
public:
/** Handles aim inputs from either controls or UI interfaces */
@@ -119,15 +131,15 @@ public:
virtual void DoJumpEnd() override;
/** Handles start firing input */
UFUNCTION(BlueprintCallable, Category="Input")
UFUNCTION(BlueprintCallable, Category = "Input")
void DoStartFiring();
/** Handles stop firing input */
UFUNCTION(BlueprintCallable, Category="Input")
UFUNCTION(BlueprintCallable, Category = "Input")
void DoStopFiring();
/** Handles switch weapon input */
UFUNCTION(BlueprintCallable, Category="Input")
UFUNCTION(BlueprintCallable, Category = "Input")
void DoSwitchWeapon();
public:
@@ -170,7 +182,7 @@ protected:
void Die();
/** Called to allow Blueprint code to react to this character's death */
UFUNCTION(BlueprintImplementableEvent, Category="Shooter", meta = (DisplayName = "On Death"))
UFUNCTION(BlueprintImplementableEvent, Category = "Shooter", meta = (DisplayName = "On Death"))
void BP_OnDeath();
/** Called from the respawn timer to destroy this character and force the PC to respawn */

View File

@@ -1,15 +1,14 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Variant_Shooter/ShooterPlayerController.h"
#include "EnhancedInputSubsystems.h"
#include "Engine/LocalPlayer.h"
#include "EnhancedInputSubsystems.h"
#include "FirstPersonDemo.h"
#include "GameFramework/PlayerStart.h"
#include "InputMappingContext.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerStart.h"
#include "ShooterCharacter.h"
#include "ShooterBulletCounterUI.h"
#include "FirstPersonDemo.h"
#include "ShooterCharacter.h"
#include "Widgets/Input/SVirtualJoystick.h"
void AShooterPlayerController::BeginPlay() {
@@ -28,7 +27,6 @@ void AShooterPlayerController::BeginPlay() {
} else {
UE_LOG(LogFirstPersonDemo, Error, TEXT("Could not spawn mobile controls widget."));
}
}
@@ -41,9 +39,7 @@ void AShooterPlayerController::BeginPlay() {
} else {
UE_LOG(LogFirstPersonDemo, Error, TEXT("Could not spawn bullet counter widget."));
}
}
}
@@ -53,8 +49,8 @@ void AShooterPlayerController::SetupInputComponent() {
// only add IMCs for local player controllers
if (IsLocalPlayerController()) {
// add the input mapping contexts
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<
UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer())) {
if (UEnhancedInputLocalPlayerSubsystem* Subsystem =
ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer())) {
for (UInputMappingContext* CurrentContext : DefaultMappingContexts) {
Subsystem->AddMappingContext(CurrentContext, 0);
}
@@ -81,8 +77,9 @@ void AShooterPlayerController::OnPossess(APawn* InPawn) {
ShooterCharacter->Tags.Add(PlayerPawnTag);
// subscribe to the pawn's delegates
ShooterCharacter->OnBulletCountUpdated.AddDynamic(this,
&AShooterPlayerController::OnBulletCountUpdated);
ShooterCharacter->OnBulletCountUpdated.AddDynamic(
this, &AShooterPlayerController::OnBulletCountUpdated
);
ShooterCharacter->OnDamaged.AddDynamic(this, &AShooterPlayerController::OnPawnDamaged);
// force update the life bar
@@ -107,9 +104,8 @@ void AShooterPlayerController::OnPawnDestroyed(AActor* DestroyedActor) {
// spawn a character at the player start
const FTransform SpawnTransform = RandomPlayerStart->GetActorTransform();
if (AShooterCharacter* RespawnedCharacter = GetWorld()->SpawnActor<AShooterCharacter>(
CharacterClass,
SpawnTransform)) {
if (AShooterCharacter* RespawnedCharacter =
GetWorld()->SpawnActor<AShooterCharacter>(CharacterClass, SpawnTransform)) {
// possess the character
Possess(RespawnedCharacter);
}