155 - Buff Component

This commit is contained in:
Kingsmedia 2022-05-22 23:17:42 +02:00
parent 9e357cb57b
commit bc681ab8a6
4 changed files with 67 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include "BlasterCharacter.h" #include "BlasterCharacter.h"
#include "Blaster/Blaster.h" #include "Blaster/Blaster.h"
#include "Blaster/Components/BuffComponent.h"
#include "Blaster/Components/CombatComponent.h" #include "Blaster/Components/CombatComponent.h"
#include "Blaster/GameMode/BlasterGameMode.h" #include "Blaster/GameMode/BlasterGameMode.h"
#include "Blaster/PlayerController/BlasterPlayerController.h" #include "Blaster/PlayerController/BlasterPlayerController.h"
@ -43,6 +44,9 @@ ABlasterCharacter::ABlasterCharacter()
Combat = CreateDefaultSubobject<UCombatComponent>(TEXT("CombatComponent")); Combat = CreateDefaultSubobject<UCombatComponent>(TEXT("CombatComponent"));
Combat->SetIsReplicated(true); Combat->SetIsReplicated(true);
Buff = CreateDefaultSubobject<UBuffComponent>(TEXT("BuffComponent"));
Buff->SetIsReplicated(true);
GetCharacterMovement()->NavAgentProps.bCanCrouch = true; GetCharacterMovement()->NavAgentProps.bCanCrouch = true;
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
GetMesh()->SetCollisionObjectType(ECC_SkeletalMesh); GetMesh()->SetCollisionObjectType(ECC_SkeletalMesh);
@ -249,6 +253,10 @@ void ABlasterCharacter::PostInitializeComponents()
{ {
Combat->Character = this; Combat->Character = this;
} }
if (Buff)
{
Buff->Character = this;
}
} }
void ABlasterCharacter::PlayFireMontage(bool bAiming) void ABlasterCharacter::PlayFireMontage(bool bAiming)

View File

@ -91,7 +91,10 @@ private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UCombatComponent* Combat; class UCombatComponent* Combat;
UPROPERTY(VisibleAnywhere)
class UBuffComponent* Buff;
UFUNCTION(Server, Reliable) UFUNCTION(Server, Reliable)
void ServerEquipButtonPressed(); void ServerEquipButtonPressed();

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BuffComponent.h"
UBuffComponent::UBuffComponent()
{
PrimaryComponentTick.bCanEverTick = true;
}
void UBuffComponent::BeginPlay()
{
Super::BeginPlay();
}
void UBuffComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}

View File

@ -0,0 +1,30 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "BuffComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BLASTER_API UBuffComponent : public UActorComponent
{
GENERATED_BODY()
public:
UBuffComponent();
friend class ABlasterCharacter;
protected:
virtual void BeginPlay() override;
private:
UPROPERTY()
class ABlasterCharacter* Character;
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};