Replace raw pointers with TObjectPtr<>
This commit is contained in:
parent
0a486535f1
commit
f72780bb00
@ -35,13 +35,15 @@ public:
|
||||
|
||||
private:
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UBehaviorTree* BehaviorTree = nullptr;
|
||||
TObjectPtr<UBehaviorTree> BehaviorTree = nullptr;
|
||||
|
||||
UObjectPoolComponent* ObjectPoolComponent = nullptr;
|
||||
UPROPERTY()
|
||||
TObjectPtr<UObjectPoolComponent> ObjectPoolComponent = nullptr;
|
||||
|
||||
UPickupDataAsset* PickupTemplate = nullptr;
|
||||
UPROPERTY()
|
||||
TObjectPtr<UPickupDataAsset> PickupTemplate = nullptr;
|
||||
|
||||
TArray<AActor*> Player;
|
||||
TArray<TObjectPtr<AActor>> Player;
|
||||
|
||||
FTimerHandle DamageTimerHandle;
|
||||
|
||||
|
@ -20,13 +20,13 @@ class VAMPIRES_API UEnemyDataAsset : public UDataAsset
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
UStaticMesh* StaticMesh;
|
||||
TObjectPtr<UStaticMesh> StaticMesh;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UBehaviorTree* BehaviorTree = nullptr;
|
||||
TObjectPtr<UBehaviorTree> BehaviorTree = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UPickupDataAsset* PickupDataAsset = nullptr;
|
||||
TObjectPtr<UPickupDataAsset> PickupDataAsset = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
TObjectPtr<USoundBase> OnDamagedSoundBase = nullptr;
|
||||
@ -35,8 +35,8 @@ public:
|
||||
TObjectPtr<USoundBase> OnDeathSoundBase = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UNiagaraSystem* OnDamagedNiagaraSystem;
|
||||
TObjectPtr<UNiagaraSystem> OnDamagedNiagaraSystem;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UNiagaraSystem* OnDeathNiagaraSystem;
|
||||
TObjectPtr<UNiagaraSystem> OnDeathNiagaraSystem;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ class VAMPIRES_API AObjectPoolManager : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
TArray<AActor*> ObjectPool = TArray<AActor*>();
|
||||
TArray<TObjectPtr<AActor>> ObjectPool = TArray<TObjectPtr<AActor>>();
|
||||
|
||||
public:
|
||||
void InitializeObjectPool(TSubclassOf<AActor> Object, int InitialObjectPoolSize = 400);
|
||||
|
@ -22,22 +22,22 @@ public:
|
||||
int PickupValue = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USphereComponent* InnerSphereComponent = nullptr;
|
||||
TObjectPtr<USphereComponent> InnerSphereComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USphereComponent* OuterSphereComponent = nullptr;
|
||||
TObjectPtr<USphereComponent> OuterSphereComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||
TObjectPtr<UStaticMeshComponent> StaticMeshComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USoundBase* PickupSoundBase = nullptr;
|
||||
TObjectPtr<USoundBase> PickupSoundBase = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Timeline")
|
||||
TObjectPtr<UTimelineComponent> TimelineComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Timeline")
|
||||
UCurveFloat* CurveFloat;
|
||||
TObjectPtr<UCurveFloat> CurveFloat;
|
||||
|
||||
private:
|
||||
FOnTimelineFloat onTimelineCallback;
|
||||
|
@ -26,13 +26,13 @@ class VAMPIRES_API APlayerCharacter : public AVampireCharacter
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UEXPComponent* EXPComponent;
|
||||
TObjectPtr<UEXPComponent> EXPComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UGoldComponent* GoldComponent;
|
||||
TObjectPtr<UGoldComponent> GoldComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UWidgetComponent* HealthBarWidgetComponent;
|
||||
TObjectPtr<UWidgetComponent> HealthBarWidgetComponent;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TObjectPtr<UTimelineComponent> CameraShakeTimelineComponent = nullptr;
|
||||
|
@ -18,10 +18,10 @@ class VAMPIRES_API AProjectile : public AActor, public IProjectilable
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USphereComponent* SphereComponent = nullptr;
|
||||
TObjectPtr<USphereComponent> SphereComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UProjectileMovementComponent* ProjectileMovement = nullptr;
|
||||
TObjectPtr<UProjectileMovementComponent> ProjectileMovement = nullptr;
|
||||
|
||||
FVector TargetDirection = FVector::ZeroVector;
|
||||
|
||||
@ -29,7 +29,7 @@ public:
|
||||
float ProjectileSpeed = 500.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||
TObjectPtr<UStaticMeshComponent> StaticMeshComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int RemainingDamagableEnemies = 1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
AVampireAIController::AVampireAIController(const FObjectInitializer& object_initializer) : Super(
|
||||
object_initializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT("Path Following Component")))
|
||||
{
|
||||
Blackboard = CreateDefaultSubobject<UBlackboardComponent>(TEXT("Blackboard"));
|
||||
DefaultBlackboard = CreateDefaultSubobject<UBlackboardComponent>(TEXT("Blackboard"));
|
||||
BehaviorTree = CreateDefaultSubobject<UBehaviorTreeComponent>(TEXT("Behavior Tree"));
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ void AVampireAIController::Tick(float DeltaTime)
|
||||
|
||||
if (PlayerCharacter)
|
||||
{
|
||||
Blackboard->SetValueAsVector("PlayerLocation", PlayerCharacter->GetActorLocation());
|
||||
DefaultBlackboard->SetValueAsVector("PlayerLocation", PlayerCharacter->GetActorLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,13 +56,13 @@ void AVampireAIController::OnPossess(APawn* InPawn)
|
||||
|
||||
if (UBehaviorTree* bt = EnemyCharacter->GetBehaviorTree())
|
||||
{
|
||||
Blackboard->InitializeBlackboard(*bt->BlackboardAsset);
|
||||
DefaultBlackboard->InitializeBlackboard(*bt->BlackboardAsset);
|
||||
BehaviorTree->StartTree(*bt);
|
||||
Blackboard->SetValueAsObject("SelfActor", EnemyCharacter);
|
||||
DefaultBlackboard->SetValueAsObject("SelfActor", EnemyCharacter);
|
||||
|
||||
if (PlayerCharacter)
|
||||
{
|
||||
Blackboard->SetValueAsObject("Player", PlayerCharacter);
|
||||
DefaultBlackboard->SetValueAsObject("Player", PlayerCharacter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,17 @@ class VAMPIRES_API AVampireAIController : public AAIController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UBlackboardComponent* Blackboard;
|
||||
UPROPERTY()
|
||||
TObjectPtr<UBlackboardComponent> DefaultBlackboard;
|
||||
|
||||
UBehaviorTreeComponent* BehaviorTree;
|
||||
UPROPERTY()
|
||||
TObjectPtr<UBehaviorTreeComponent> BehaviorTree;
|
||||
|
||||
ACharacter* PlayerCharacter;
|
||||
UPROPERTY()
|
||||
TObjectPtr<ACharacter> PlayerCharacter;
|
||||
|
||||
AEnemyCharacter* EnemyCharacter;
|
||||
UPROPERTY()
|
||||
TObjectPtr<AEnemyCharacter> EnemyCharacter;
|
||||
|
||||
FTimerHandle PawnMoveToTimerHandle;
|
||||
|
||||
|
@ -21,7 +21,7 @@ class VAMPIRES_API AVampireCharacter : public ACharacter, public IInputable
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
UStaticMeshComponent* StaticMeshComponent;
|
||||
TObjectPtr<UStaticMeshComponent> StaticMeshComponent;
|
||||
|
||||
FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f);
|
||||
|
||||
@ -30,25 +30,25 @@ public:
|
||||
|
||||
protected:
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UHealthComponent* HealthComponent;
|
||||
TObjectPtr<UHealthComponent> HealthComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UInputMappingContext> InputMappingContext;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UWeaponInventoryComponent* WeaponInventoryComponent;
|
||||
TObjectPtr<UWeaponInventoryComponent> WeaponInventoryComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
USoundBase* OnDamagedSound;
|
||||
TObjectPtr<USoundBase> OnDamagedSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
USoundBase* OnDeathSound;
|
||||
TObjectPtr<USoundBase> OnDeathSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UNiagaraSystem* OnDamagedNiagaraSystem;
|
||||
TObjectPtr<UNiagaraSystem> OnDamagedNiagaraSystem;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UNiagaraSystem* OnDeathNiagaraSystem;
|
||||
TObjectPtr<UNiagaraSystem> OnDeathNiagaraSystem;
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
|
@ -39,20 +39,26 @@ public:
|
||||
TArray<TObjectPtr<UEnemyDataAsset>> EnemyDataAssets;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<APlayerCharacter> PlayerCharacter;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<AVampirePlayerController> PlayerController;
|
||||
|
||||
FTimerHandle SpawnEnemyTimerDelegate;
|
||||
|
||||
int EnemyDeathCount = 0;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<AObjectPoolManager> EnemyObjectPoolManager = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<AObjectPoolManager> ProjectileObjectPoolManager = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<AObjectPoolManager> PickupObjectPoolManager = nullptr;
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<UEnemyDataAsset>> SpawnableEnemyDataAssets;
|
||||
|
||||
protected:
|
||||
|
@ -33,17 +33,20 @@ public:
|
||||
|
||||
// Inputs
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* MovementAction;
|
||||
TObjectPtr<UInputAction> MovementAction;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* PauseAction;
|
||||
TObjectPtr<UInputAction> PauseAction;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UHUDWidget> currentPlayerHUD = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UPauseWidget> currentPauseUI = nullptr;
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<ULevelUpWidget> currentLevelUpUI = nullptr;
|
||||
|
||||
FTimerHandle pawnLifeTimeHandle;
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
TObjectPtr<UTexture2D> Icon;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties")
|
||||
USoundBase* WeaponActivatedSoundBase = nullptr;
|
||||
TObjectPtr<USoundBase> WeaponActivatedSoundBase = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties")
|
||||
TObjectPtr<UPaperSprite> WeaponSprite = nullptr;
|
||||
@ -51,9 +51,9 @@ public:
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UBoxComponent* BoxComponent = nullptr;
|
||||
TObjectPtr<UBoxComponent> BoxComponent = nullptr;
|
||||
|
||||
TArray<AActor*> OverlappedEnemies = TArray<AActor*>();
|
||||
TArray<TObjectPtr<AActor>> OverlappedEnemies = TArray<TObjectPtr<AActor>>();
|
||||
|
||||
private:
|
||||
FTimerHandle WeaponTimerHandle;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TArray<AWeapon*> inventory;
|
||||
TArray<TObjectPtr<AWeapon>> inventory;
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
|
@ -14,7 +14,8 @@ struct FOverlappedEnemy
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
AEnemyCharacter* OverlappedEnemyCharacter;
|
||||
UPROPERTY()
|
||||
TObjectPtr<AEnemyCharacter> OverlappedEnemyCharacter;
|
||||
|
||||
FTimerHandle OverlappedTimerHandle;
|
||||
};
|
||||
@ -28,7 +29,7 @@ class VAMPIRES_API AGarlicWeapon : public AWeapon
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
|
||||
USphereComponent* SphereComponent;
|
||||
TObjectPtr<USphereComponent> SphereComponent;
|
||||
|
||||
TArray<FOverlappedEnemy> GarlicOverlappedEnemies;
|
||||
|
||||
|
@ -18,7 +18,7 @@ class VAMPIRES_API APentagramWeapon : public AWeapon
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
TArray<APickup*> OverlappedPickups = TArray<APickup*>();
|
||||
TArray<TObjectPtr<APickup>> OverlappedPickups = TArray<TObjectPtr<APickup>>();
|
||||
|
||||
public:
|
||||
APentagramWeapon();
|
||||
|
@ -15,10 +15,10 @@ class VAMPIRES_API ASwarmAgent : public AActor
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USphereComponent* SphereComponent = nullptr;
|
||||
TObjectPtr<USphereComponent> SphereComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||
TObjectPtr<UStaticMeshComponent> StaticMeshComponent = nullptr;
|
||||
|
||||
// Sets default values for this actor's properties
|
||||
ASwarmAgent();
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
private:
|
||||
FOnTimelineFloat onTimelineCallback;
|
||||
|
||||
TArray<ASwarmAgent*> SwarmActors;
|
||||
TArray<TObjectPtr<ASwarmAgent>> SwarmActors;
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
|
Loading…
x
Reference in New Issue
Block a user