diff --git a/Source/Blaster/Character/BlasterCharacter.cpp b/Source/Blaster/Character/BlasterCharacter.cpp index 27c0249..5887297 100644 --- a/Source/Blaster/Character/BlasterCharacter.cpp +++ b/Source/Blaster/Character/BlasterCharacter.cpp @@ -4,6 +4,7 @@ #include "BlasterCharacter.h" #include "Blaster/Blaster.h" +#include "Blaster/Components/BuffComponent.h" #include "Blaster/Components/CombatComponent.h" #include "Blaster/GameMode/BlasterGameMode.h" #include "Blaster/PlayerController/BlasterPlayerController.h" @@ -43,6 +44,9 @@ ABlasterCharacter::ABlasterCharacter() Combat = CreateDefaultSubobject(TEXT("CombatComponent")); Combat->SetIsReplicated(true); + Buff = CreateDefaultSubobject(TEXT("BuffComponent")); + Buff->SetIsReplicated(true); + GetCharacterMovement()->NavAgentProps.bCanCrouch = true; GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); GetMesh()->SetCollisionObjectType(ECC_SkeletalMesh); @@ -249,6 +253,10 @@ void ABlasterCharacter::PostInitializeComponents() { Combat->Character = this; } + if (Buff) + { + Buff->Character = this; + } } void ABlasterCharacter::PlayFireMontage(bool bAiming) diff --git a/Source/Blaster/Character/BlasterCharacter.h b/Source/Blaster/Character/BlasterCharacter.h index 100220e..be4b787 100644 --- a/Source/Blaster/Character/BlasterCharacter.h +++ b/Source/Blaster/Character/BlasterCharacter.h @@ -91,7 +91,10 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UCombatComponent* Combat; - + + UPROPERTY(VisibleAnywhere) + class UBuffComponent* Buff; + UFUNCTION(Server, Reliable) void ServerEquipButtonPressed(); diff --git a/Source/Blaster/Components/BuffComponent.cpp b/Source/Blaster/Components/BuffComponent.cpp new file mode 100644 index 0000000..861888b --- /dev/null +++ b/Source/Blaster/Components/BuffComponent.cpp @@ -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); + +} + diff --git a/Source/Blaster/Components/BuffComponent.h b/Source/Blaster/Components/BuffComponent.h new file mode 100644 index 0000000..b4ec368 --- /dev/null +++ b/Source/Blaster/Components/BuffComponent.h @@ -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; + + +};