change pointers to use TObjectPtr

This commit is contained in:
Caleb Buhungiro
2025-06-25 16:06:54 +08:00
parent 8763e041ba
commit 3087d07dfc
10 changed files with 33 additions and 18 deletions

View File

@@ -5,7 +5,7 @@
#include "Net/UnrealNetwork.h"
void UCAttributeSet::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
void UCAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, Health, COND_None, REPNOTIFY_Always);
@@ -18,6 +18,7 @@ void UCAttributeSet::OnRep_Health(const FGameplayAttributeData& OldValue)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, Health, OldValue);
}
void UCAttributeSet::OnRep_MaxHealth(const FGameplayAttributeData& OldValue)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, MaxHealth, OldValue);

View File

@@ -14,7 +14,7 @@ void ACPlayerController::OnPossess(APawn* InPawn)
}
}
void ACPlayerController::AcknowledgePossession(class APawn* P)
void ACPlayerController::AcknowledgePossession(APawn* P)
{
Super::AcknowledgePossession(P);
if (CPlayerCharacter = Cast<ACPlayerCharacter>(P); IsValid(CPlayerCharacter))

View File

@@ -6,6 +6,8 @@
#include "Animation/AnimInstance.h"
#include "CAnimInstance.generated.h"
class UCharacterMovementComponent;
UCLASS()
class CRUNCH_API UCAnimInstance : public UAnimInstance
{
@@ -45,9 +47,9 @@ public:
private:
UPROPERTY()
ACharacter* OwnerCharacter;
TObjectPtr<ACharacter> OwnerCharacter;
UPROPERTY()
class UCharacterMovementComponent* OwnerMovementComp;
TObjectPtr<UCharacterMovementComponent> OwnerMovementComp;
UPROPERTY()
float Speed{0.f};
float YawSpeed{0.f};

View File

@@ -27,7 +27,7 @@ public:
private:
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
UCAbilitySystemComponent* CAbilitySystemComponent;
TObjectPtr<UCAbilitySystemComponent> CAbilitySystemComponent;
UPROPERTY(BlueprintReadOnly, Category="Gameplay Effects", meta=(AllowPrivateAccess=true))
const UCAttributeSet* CAttributeSet;
TObjectPtr<UCAttributeSet> CAttributeSet;
};

View File

@@ -6,6 +6,10 @@
#include "CCharacter.h"
#include "CPlayerCharacter.generated.h"
class UInputAction;
class UInputMappingContext;
class UCameraComponent;
class USpringArmComponent;
struct FInputActionValue;
UCLASS()
@@ -26,21 +30,21 @@ public:
private:
UPROPERTY(VisibleDefaultsOnly, Category= "View")
class USpringArmComponent* CameraBoom;
TObjectPtr<USpringArmComponent> CameraBoom;
UPROPERTY(VisibleDefaultsOnly, Category= "View")
class UCameraComponent* ViewCamera;
TObjectPtr<UCameraComponent> ViewCamera;
UPROPERTY(EditDefaultsOnly, Category= "View")
FRotator RotationRate{FRotator(0.0f, 720.0f, 0.0f)};
UPROPERTY(EditDefaultsOnly, Category= "Input")
class UInputMappingContext* GameplayMappingContext;
TObjectPtr<UInputMappingContext> GameplayMappingContext;
UPROPERTY(EditDefaultsOnly, Category= "Input")
class UInputAction* JumpInputAction;
TObjectPtr<UInputAction> JumpInputAction;
UPROPERTY(EditDefaultsOnly, Category= "Input")
UInputAction* LookInputAction;
TObjectPtr<UInputAction> LookInputAction;
UPROPERTY(EditDefaultsOnly, Category= "Input")
UInputAction* MoveInputAction;
TObjectPtr<UInputAction> MoveInputAction;
void HandleLookInput(const FInputActionValue& InputActionValue);
void HandleMoveInput(const FInputActionValue& InputActionValue);

View File

@@ -1,4 +1,4 @@
// Multipalyer By Caleb
// Multiplayer By Caleb
#pragma once
@@ -6,6 +6,8 @@
#include "GameFramework/PlayerController.h"
#include "CPlayerController.generated.h"
class ACPlayerCharacter;
UCLASS()
class CRUNCH_API ACPlayerController : public APlayerController
{
@@ -17,5 +19,5 @@ public:
private:
UPROPERTY()
class ACPlayerCharacter* CPlayerCharacter;
TObjectPtr<ACPlayerCharacter> CPlayerCharacter;
};

View File

@@ -23,9 +23,9 @@ private:
UPROPERTY(EditAnywhere, Category="Visual")
FLinearColor BarColor;
UPROPERTY(EditAnywhere, meta=(BindWidget))
UProgressBar* ProgressBar;
TObjectPtr<UProgressBar> ProgressBar;
UPROPERTY(EditAnywhere, meta=(BindWidget))
UTextBlock* ValueText;
TObjectPtr<UTextBlock> ValueText;
};