blaster/Source/Blaster/Components/CombatComponent.h

66 lines
1.6 KiB
C
Raw Normal View History

2022-04-30 11:09:28 +00:00
// 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"
2022-05-04 22:39:17 +00:00
#define TRACE_LENGTH 80000
2022-04-30 11:09:28 +00:00
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BLASTER_API UCombatComponent : public UActorComponent
{
GENERATED_BODY()
public:
UCombatComponent();
friend class ABlasterCharacter;
2022-04-30 14:48:34 +00:00
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
2022-04-30 11:09:28 +00:00
void EquipWeapon(class AWeapon* WeaponToEquip);
protected:
virtual void BeginPlay() override;
2022-04-30 15:38:03 +00:00
void SetAiming(bool bIsAiming);
UFUNCTION(Server, Reliable)
void ServerSetAiming(bool bIsAiming);
2022-04-30 11:09:28 +00:00
2022-05-02 13:40:33 +00:00
UFUNCTION()
void OnRep_EquippedWeapon();
2022-05-04 20:13:31 +00:00
void FireButtonPressed(bool bPressed);
2022-05-04 20:57:45 +00:00
UFUNCTION(Server, Reliable)
2022-05-05 12:29:21 +00:00
void ServerFire(const FVector_NetQuantize& TraceHitTarget);
2022-05-04 20:57:45 +00:00
UFUNCTION(NetMulticast, Reliable)
2022-05-05 12:29:21 +00:00
void MulticastFire(const FVector_NetQuantize& TraceHitTarget);
2022-05-04 22:39:17 +00:00
void TraceUnderCrosshairs(FHitResult& TraceHitResult);
2022-05-05 15:57:57 +00:00
void SetHUDCrosshairs(float DeltaTime);
2022-05-04 20:57:45 +00:00
2022-04-30 11:09:28 +00:00
private:
class ABlasterCharacter* Character;
2022-05-05 15:57:57 +00:00
class ABlasterPlayerController* Controller;
class ABlasterHUD* HUD;
2022-04-30 14:48:34 +00:00
2022-05-02 13:40:33 +00:00
UPROPERTY(ReplicatedUsing=OnRep_EquippedWeapon)
2022-04-30 11:09:28 +00:00
class AWeapon* EquippedWeapon;
2022-04-30 15:38:03 +00:00
UPROPERTY(Replicated)
bool bAiming;
2022-05-03 17:50:47 +00:00
UPROPERTY(EditAnywhere)
float BaseWalkSpeed;
UPROPERTY(EditAnywhere)
float AimWalkSpeed;
2022-05-04 20:13:31 +00:00
bool bFireButtonPressed;
2022-04-30 11:09:28 +00:00
};