blaster/Source/Blaster/Character/BlasterCharacter.h

108 lines
3.0 KiB
C
Raw Normal View History

2022-04-28 10:18:21 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
2022-05-05 20:46:35 +00:00
#include "Blaster/Interfaces/InteractWithCrosshairInterface.h"
2022-05-04 09:28:00 +00:00
#include "Blaster/Types/TurningInPlace.h"
2022-04-28 10:18:21 +00:00
#include "GameFramework/Character.h"
#include "BlasterCharacter.generated.h"
UCLASS()
2022-05-05 20:46:35 +00:00
class BLASTER_API ABlasterCharacter : public ACharacter, public IInteractWithCrosshairInterface
2022-04-28 10:18:21 +00:00
{
GENERATED_BODY()
public:
ABlasterCharacter();
2022-04-28 10:41:43 +00:00
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
2022-04-30 10:26:25 +00:00
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
2022-04-30 11:09:28 +00:00
virtual void PostInitializeComponents() override;
2022-05-06 10:43:18 +00:00
virtual void OnRep_ReplicatedMovement() override;
2022-05-04 20:13:31 +00:00
void PlayFireMontage(bool bAiming);
2022-05-05 22:41:35 +00:00
UFUNCTION(NetMulticast, Unreliable)
void MulticastHit();
2022-05-04 09:28:00 +00:00
2022-04-28 10:18:21 +00:00
protected:
virtual void BeginPlay() override;
2022-04-28 12:39:36 +00:00
void MoveForward(float Value);
void MoveRight(float Value);
void Turn(float Value);
void LookUp(float Value);
2022-04-30 11:09:28 +00:00
void EquipButtonPressed();
2022-04-30 15:10:07 +00:00
void CrouchButtonPressed();
2022-04-30 15:38:03 +00:00
void AimButtonPressed();
void AimButtonReleased();
2022-05-06 10:43:18 +00:00
void CalculateAO_Pitch();
2022-05-03 21:14:04 +00:00
void AimOffset(float DeltaTime);
2022-05-06 10:43:18 +00:00
void SimProxiesTurn();
2022-05-04 12:57:48 +00:00
virtual void Jump() override;
2022-05-04 20:13:31 +00:00
void FireButtonPressed();
void FireButtonReleased();
2022-05-05 22:41:35 +00:00
void PlayHitReactMontage();
2022-04-30 11:09:28 +00:00
2022-04-28 10:41:43 +00:00
private:
UPROPERTY(VisibleAnywhere, Category="Camera")
class USpringArmComponent* CameraBoom;
2022-04-28 10:18:21 +00:00
2022-04-28 10:41:43 +00:00
UPROPERTY(VisibleAnywhere, Category="Camera")
class UCameraComponent* FollowCamera;
2022-04-29 21:38:34 +00:00
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UWidgetComponent* OverheadWidget;
2022-04-30 10:26:25 +00:00
UPROPERTY(ReplicatedUsing = OnRep_OverlappingWeapon)
class AWeapon* OverlappingWeapon;
UFUNCTION()
void OnRep_OverlappingWeapon(AWeapon* LastWeapon);
2022-04-30 11:09:28 +00:00
UPROPERTY(VisibleAnywhere)
class UCombatComponent* Combat;
2022-04-30 14:08:00 +00:00
UFUNCTION(Server, Reliable)
void ServerEquipButtonPressed();
2022-05-03 21:14:04 +00:00
float AO_Yaw;
2022-05-04 12:09:01 +00:00
float InterpAO_Yaw;
2022-05-03 21:14:04 +00:00
float AO_Pitch;
FRotator StartingAimRotation;
2022-05-04 09:28:00 +00:00
ETurningInPlace TurningInPlace;
void TurnInPlace(float DeltaTime);
2022-05-04 20:13:31 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* FireWeaponMontage;
2022-05-05 22:41:35 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* HitReactMontage;
2022-05-05 21:03:09 +00:00
void HideCameraIfCharacterClose();
UPROPERTY(EditAnywhere)
float CameraThreshold = 200.f;
2022-05-06 10:43:18 +00:00
bool bRotateRootBone;
float TurnThreshold = 0.8f;
FRotator ProxyRotationLastFrame;
FRotator ProxyRotation;
float ProxyYaw;
float TimeSinceLastMovementReplication;
float CalculateSpeed();
2022-05-05 21:03:09 +00:00
2022-04-30 10:26:25 +00:00
public:
void SetOverlappingWeapon(AWeapon* Weapon);
2022-04-30 14:48:34 +00:00
bool IsWeaponEquipped();
2022-04-30 15:38:03 +00:00
bool IsAiming();
2022-05-05 19:56:31 +00:00
FORCEINLINE float GetAO_Yaw() const { return AO_Yaw; }
FORCEINLINE float GetAO_Pitch() const { return AO_Pitch; }
2022-05-03 22:43:10 +00:00
AWeapon* GetEquippedWeapon();
2022-05-05 19:56:31 +00:00
FORCEINLINE ETurningInPlace GetTurningInPlace() const { return TurningInPlace; }
2022-05-05 18:14:17 +00:00
FVector GetHitTarget() const;
2022-05-05 19:56:31 +00:00
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
2022-05-06 10:43:18 +00:00
FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; }
2022-04-28 10:18:21 +00:00
};