blaster/Source/Blaster/Components/CombatComponent.h

49 lines
1.1 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "CombatComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BLASTER_API UCombatComponent : public UActorComponent
{
GENERATED_BODY()
public:
UCombatComponent();
friend class ABlasterCharacter;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void EquipWeapon(class AWeapon* WeaponToEquip);
protected:
virtual void BeginPlay() override;
void SetAiming(bool bIsAiming);
UFUNCTION(Server, Reliable)
void ServerSetAiming(bool bIsAiming);
UFUNCTION()
void OnRep_EquippedWeapon();
private:
class ABlasterCharacter* Character;
UPROPERTY(ReplicatedUsing=OnRep_EquippedWeapon)
class AWeapon* EquippedWeapon;
UPROPERTY(Replicated)
bool bAiming;
UPROPERTY(EditAnywhere)
float BaseWalkSpeed;
UPROPERTY(EditAnywhere)
float AimWalkSpeed;
};