some small changes

This commit is contained in:
Caleb Buhungiro
2025-06-19 10:19:34 +08:00
parent accf4cce15
commit b8475c7ba1
12 changed files with 24 additions and 24 deletions

Binary file not shown.

View File

@@ -14,6 +14,10 @@ ACCharacter::ACCharacter()
CAbilitySystemComponent = CreateDefaultSubobject<UCAbilitySystemComponent>(TEXT("Ability System Component")); CAbilitySystemComponent = CreateDefaultSubobject<UCAbilitySystemComponent>(TEXT("Ability System Component"));
CAttributeSet = CreateDefaultSubobject<UCAttributeSet>(TEXT("CAttribute Set")); CAttributeSet = CreateDefaultSubobject<UCAttributeSet>(TEXT("CAttribute Set"));
/**
* This is also valid
* CAttributeSet = CAbilitySystemComponent->GetSet<UCAttributeSet>();
**/
} }
void ACCharacter::ServerSideInit() void ACCharacter::ServerSideInit()

View File

@@ -1,4 +1,4 @@
// Multipalyer By Caleb // Multiplayer By Caleb
#include "Crunch/Public/Player/CPlayerController.h" #include "Crunch/Public/Player/CPlayerController.h"
@@ -8,8 +8,7 @@
void ACPlayerController::OnPossess(APawn* InPawn) void ACPlayerController::OnPossess(APawn* InPawn)
{ {
Super::OnPossess(InPawn); Super::OnPossess(InPawn);
CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn); if (CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn); IsValid(CPlayerCharacter))
if (CPlayerCharacter)
{ {
CPlayerCharacter->ServerSideInit(); CPlayerCharacter->ServerSideInit();
} }
@@ -18,8 +17,7 @@ void ACPlayerController::OnPossess(APawn* InPawn)
void ACPlayerController::AcknowledgePossession(class APawn* P) void ACPlayerController::AcknowledgePossession(class APawn* P)
{ {
Super::AcknowledgePossession(P); Super::AcknowledgePossession(P);
CPlayerCharacter = Cast<ACPlayerCharacter>(P); if (CPlayerCharacter = Cast<ACPlayerCharacter>(P); IsValid(CPlayerCharacter))
if (CPlayerCharacter)
{ {
CPlayerCharacter->ClientSideInit(); CPlayerCharacter->ClientSideInit();
} }

View File

@@ -7,6 +7,9 @@
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "CCharacter.generated.h" #include "CCharacter.generated.h"
class UCAbilitySystemComponent;
class UCAttributeSet;
UCLASS() UCLASS()
class CRUNCH_API ACCharacter : public ACharacter, public IAbilitySystemInterface class CRUNCH_API ACCharacter : public ACharacter, public IAbilitySystemInterface
{ {
@@ -24,7 +27,7 @@ public:
private: private:
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects") UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
class UCAbilitySystemComponent* CAbilitySystemComponent; UCAbilitySystemComponent* CAbilitySystemComponent;
UPROPERTY() UPROPERTY(BlueprintReadOnly, Category="Gameplay Effects", meta=(AllowPrivateAccess=true))
class UCAttributeSet* CAttributeSet; const UCAttributeSet* CAttributeSet;
}; };

View File

@@ -7,7 +7,6 @@
#include "CAbilitySystemComponent.generated.h" #include "CAbilitySystemComponent.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent
{ {

View File

@@ -7,7 +7,6 @@
#include "AttributeSet.h" #include "AttributeSet.h"
#include "CAttributeSet.generated.h" #include "CAttributeSet.generated.h"
/** /**
* This defines a set of helper functions for accessing and initializing attributes, to avoid having to manually write these functions. * This defines a set of helper functions for accessing and initializing attributes, to avoid having to manually write these functions.
* It would creates the following functions, for attribute Health * It would creates the following functions, for attribute Health

View File

@@ -6,9 +6,6 @@
#include "GameFramework/GameModeBase.h" #include "GameFramework/GameModeBase.h"
#include "CGameMode.generated.h" #include "CGameMode.generated.h"
/**
*
*/
UCLASS() UCLASS()
class CRUNCH_API ACGameMode : public AGameModeBase class CRUNCH_API ACGameMode : public AGameModeBase
{ {

View File

@@ -13,7 +13,7 @@ class CRUNCH_API ACPlayerController : public APlayerController
public: public:
virtual void OnPossess(APawn* InPawn) override; virtual void OnPossess(APawn* InPawn) override;
virtual void AcknowledgePossession(class APawn* P) override; virtual void AcknowledgePossession(APawn* P) override;
private: private:
UPROPERTY() UPROPERTY()