75 lines
1.7 KiB
C++
75 lines
1.7 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(const FVector_NetQuantize& TraceHitTarget);
|
|
|
|
UFUNCTION(NetMulticast, Reliable)
|
|
void MulticastFire(const FVector_NetQuantize& TraceHitTarget);
|
|
|
|
void TraceUnderCrosshairs(FHitResult& TraceHitResult);
|
|
|
|
void SetHUDCrosshairs(float DeltaTime);
|
|
|
|
private:
|
|
class ABlasterCharacter* Character;
|
|
class ABlasterPlayerController* Controller;
|
|
class ABlasterHUD* HUD;
|
|
|
|
UPROPERTY(ReplicatedUsing=OnRep_EquippedWeapon)
|
|
class AWeapon* EquippedWeapon;
|
|
|
|
UPROPERTY(Replicated)
|
|
bool bAiming;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
float BaseWalkSpeed;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
float AimWalkSpeed;
|
|
|
|
bool bFireButtonPressed;
|
|
|
|
/*
|
|
* HUD and Crosshairs
|
|
*/
|
|
|
|
float CrosshairVelocityFactor;
|
|
float CrosshairInAirFactor;
|
|
|
|
FVector HitTarget;
|
|
};
|