64 lines
1.4 KiB
C++
64 lines
1.4 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"
|
|
|
|
#define TRACE_LENGTH 80000
|
|
|
|
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();
|
|
|
|
void FireButtonPressed(bool bPressed);
|
|
|
|
UFUNCTION(Server, Reliable)
|
|
void ServerFire();
|
|
|
|
UFUNCTION(NetMulticast, Reliable)
|
|
void MulticastFire();
|
|
|
|
void TraceUnderCrosshairs(FHitResult& TraceHitResult);
|
|
|
|
private:
|
|
class ABlasterCharacter* Character;
|
|
|
|
UPROPERTY(ReplicatedUsing=OnRep_EquippedWeapon)
|
|
class AWeapon* EquippedWeapon;
|
|
|
|
UPROPERTY(Replicated)
|
|
bool bAiming;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
float BaseWalkSpeed;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
float AimWalkSpeed;
|
|
|
|
bool bFireButtonPressed;
|
|
|
|
FVector HitTarget;
|
|
};
|