blaster/Source/Blaster/Character/BlasterCharacter.h

197 lines
5.6 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-10 20:34:28 +00:00
#include "Blaster/Interfaces/InteractWithCrosshairsInterface.h"
2022-05-09 21:16:55 +00:00
#include "Blaster/Types/CombatState.h"
2022-05-04 09:28:00 +00:00
#include "Blaster/Types/TurningInPlace.h"
2022-05-08 16:35:37 +00:00
#include "Components/TimelineComponent.h"
2022-04-28 10:18:21 +00:00
#include "GameFramework/Character.h"
2022-05-08 18:59:54 +00:00
#include "Sound/SoundCue.h"
2022-04-28 10:18:21 +00:00
#include "BlasterCharacter.generated.h"
UCLASS()
2022-05-10 20:34:28 +00:00
class BLASTER_API ABlasterCharacter : public ACharacter, public IInteractWithCrosshairsInterface
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-08 18:59:54 +00:00
virtual void Destroyed() override;
2022-05-10 14:03:35 +00:00
void RotateInPlace(float DeltaTime);
2022-05-04 20:13:31 +00:00
void PlayFireMontage(bool bAiming);
2022-05-09 20:19:20 +00:00
void PlayReloadMontage();
2022-05-07 17:10:32 +00:00
void PlayEliminatedMontage();
2022-05-07 15:11:53 +00:00
void Eliminated();
2022-05-07 18:34:40 +00:00
UFUNCTION(NetMulticast, Reliable)
void MulticastEliminated();
2022-05-04 09:28:00 +00:00
2022-05-10 14:03:35 +00:00
UPROPERTY(Replicated)
bool bDisableGameplay = false;
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-05-09 20:19:20 +00:00
void ReloadButtonPressed();
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-05-07 11:03:19 +00:00
UFUNCTION()
void ReceiveDamage(AActor* DamagedActor, float Damage, const UDamageType* DamageType, class AController* InstigatorController, AActor* DamageCauser);
2022-05-10 14:03:35 +00:00
2022-05-07 11:03:19 +00:00
void UpdateHUDHealth();
2022-05-09 14:33:48 +00:00
// Poll for any relevant classes and initialize them
void PollInit();
2022-05-07 11:03:19 +00:00
2022-04-28 10:41:43 +00:00
private:
2022-05-09 15:16:41 +00:00
UPROPERTY()
class ABlasterPlayerState* BlasterPlayerState;
2022-05-09 14:33:48 +00:00
2022-04-28 10:41:43 +00:00
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
2022-05-09 21:16:55 +00:00
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
2022-04-30 11:09:28 +00:00
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
2022-05-09 20:19:20 +00:00
// Animation montages
2022-05-04 20:13:31 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* FireWeaponMontage;
2022-05-09 20:19:20 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* ReloadMontage;
2022-05-05 22:41:35 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* HitReactMontage;
2022-05-07 17:10:32 +00:00
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* EliminatedMontage;
2022-05-05 22:41:35 +00:00
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-07 09:04:11 +00:00
// Health
UPROPERTY(EditAnywhere, Category= "Player Stats")
float MaxHealth = 100.f;
UPROPERTY(ReplicatedUsing = OnRep_Health, VisibleAnywhere, Category= "Player Stats")
float Health = 100.f;
UFUNCTION()
void OnRep_Health();
2022-05-07 10:03:33 +00:00
2022-05-09 15:16:41 +00:00
UPROPERTY()
2022-05-07 10:03:33 +00:00
class ABlasterPlayerController* BlasterPlayerController;
2022-05-07 17:10:32 +00:00
bool bEliminated = false;
2022-05-07 18:34:40 +00:00
UPROPERTY(EditDefaultsOnly)
2022-05-08 18:59:54 +00:00
float EliminationDelay = 2.f;
2022-05-07 18:34:40 +00:00
FTimerHandle EliminationTimer;
void EliminationTimerFinished();
2022-05-08 16:35:37 +00:00
// Dissolve effect
UPROPERTY(VisibleAnywhere)
UTimelineComponent* DissolveTimeline;
FOnTimelineFloat DissolveTrack;
UPROPERTY(EditAnywhere)
UCurveFloat* DissolveCurve;
UFUNCTION()
void UpdateDissolveMaterial(float DissolveValue);
void StartDissolve();
// Dynamic instance that we can change at runtime
UPROPERTY(VisibleAnywhere, Category = Elimination)
UMaterialInstanceDynamic* DynamicDissolveMaterialInstance;
// Material instance set on the Blueprint, used with the dynamic material instance
UPROPERTY(EditAnywhere, Category = Elimination)
UMaterialInstance* DissolveMaterialInstance;
2022-05-08 18:59:54 +00:00
// Elimination bot
UPROPERTY(EditAnywhere)
UParticleSystem* EliminationBotEffect;
UPROPERTY(VisibleAnywhere)
UParticleSystemComponent* EliminationBotComponent;
UPROPERTY(EditAnywhere)
USoundCue* EliminationBotSound;
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-05-07 17:10:32 +00:00
FORCEINLINE bool IsEliminated() const { return bEliminated; }
2022-05-08 19:16:19 +00:00
FORCEINLINE float GetHealth() const { return Health; }
FORCEINLINE float GetMaxHealth() const { return MaxHealth; }
2022-05-09 21:16:55 +00:00
ECombatState GetCombatState() const;
2022-05-10 14:03:35 +00:00
FORCEINLINE UCombatComponent* GetCombat() const { return Combat; }
FORCEINLINE bool GetDisableGameplay() const { return bDisableGameplay; }
2022-04-28 10:18:21 +00:00
};