// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Blaster/Interfaces/InteractWithCrosshairInterface.h" #include "Blaster/Types/TurningInPlace.h" #include "GameFramework/Character.h" #include "BlasterCharacter.generated.h" UCLASS() class BLASTER_API ABlasterCharacter : public ACharacter, public IInteractWithCrosshairInterface { GENERATED_BODY() public: ABlasterCharacter(); virtual void Tick(float DeltaTime) override; virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; virtual void GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const override; virtual void PostInitializeComponents() override; virtual void OnRep_ReplicatedMovement() override; void PlayFireMontage(bool bAiming); UFUNCTION(NetMulticast, Unreliable) void MulticastHit(); protected: virtual void BeginPlay() override; void MoveForward(float Value); void MoveRight(float Value); void Turn(float Value); void LookUp(float Value); void EquipButtonPressed(); void CrouchButtonPressed(); void AimButtonPressed(); void AimButtonReleased(); void CalculateAO_Pitch(); void AimOffset(float DeltaTime); void SimProxiesTurn(); virtual void Jump() override; void FireButtonPressed(); void FireButtonReleased(); void PlayHitReactMontage(); private: UPROPERTY(VisibleAnywhere, Category="Camera") class USpringArmComponent* CameraBoom; UPROPERTY(VisibleAnywhere, Category="Camera") class UCameraComponent* FollowCamera; UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UWidgetComponent* OverheadWidget; UPROPERTY(ReplicatedUsing = OnRep_OverlappingWeapon) class AWeapon* OverlappingWeapon; UFUNCTION() void OnRep_OverlappingWeapon(AWeapon* LastWeapon); UPROPERTY(VisibleAnywhere) class UCombatComponent* Combat; UFUNCTION(Server, Reliable) void ServerEquipButtonPressed(); float AO_Yaw; float InterpAO_Yaw; float AO_Pitch; FRotator StartingAimRotation; ETurningInPlace TurningInPlace; void TurnInPlace(float DeltaTime); UPROPERTY(EditAnywhere, Category = Combat) class UAnimMontage* FireWeaponMontage; UPROPERTY(EditAnywhere, Category = Combat) class UAnimMontage* HitReactMontage; void HideCameraIfCharacterClose(); UPROPERTY(EditAnywhere) float CameraThreshold = 200.f; bool bRotateRootBone; float TurnThreshold = 0.8f; FRotator ProxyRotationLastFrame; FRotator ProxyRotation; float ProxyYaw; float TimeSinceLastMovementReplication; float CalculateSpeed(); // 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(); class ABlasterPlayerController* BlasterPlayerController; public: void SetOverlappingWeapon(AWeapon* Weapon); bool IsWeaponEquipped(); bool IsAiming(); FORCEINLINE float GetAO_Yaw() const { return AO_Yaw; } FORCEINLINE float GetAO_Pitch() const { return AO_Pitch; } AWeapon* GetEquippedWeapon(); FORCEINLINE ETurningInPlace GetTurningInPlace() const { return TurningInPlace; } FVector GetHitTarget() const; FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; } FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; } };