175 lines
4.7 KiB
C++
175 lines
4.7 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Camera/CameraComponent.h"
|
|
#include "Characters/ExoCharacterBase.h"
|
|
#include "Components/TimelineComponent.h"
|
|
#include "ExoPlayerCharacter.generated.h"
|
|
|
|
class UInteractionComponent;
|
|
class UShootingComponent;
|
|
class UWBP_PlayerUI;
|
|
|
|
UCLASS()
|
|
class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
AExoPlayerCharacter();
|
|
|
|
/// U PROPERTIES ///
|
|
UPROPERTY(EditAnywhere, Category = "Combat")
|
|
TObjectPtr<USkeletalMeshComponent> Weapon;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
|
TObjectPtr<UInteractionComponent> InteractionComponent;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
|
TObjectPtr<UShootingComponent> ShootingComponent;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
|
|
TObjectPtr<UCameraComponent> CameraComponent;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
|
TObjectPtr<USceneComponent> CapsuleBottom;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI")
|
|
TSubclassOf<UUserWidget> PlayerHudClass;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
|
float DodgeForce = 5000.f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
|
float DodgeCooldown = 2.f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Slide Properties")
|
|
float SlideCooldown = 0.35f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
|
float WalkSpeed = 600.0f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
|
float SprintSpeed = 1500.0f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
|
float SlideSpeed = 2500.f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
|
float CrouchSpeed = 300.f;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Aiming")
|
|
float bIsAimingMode = false;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Health")
|
|
float CurrentHealth = 50.0f;
|
|
|
|
/// Połowa wysokości kapsuły gracza podczas stania
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
|
float StandingHalfHeight = 88.f;
|
|
|
|
/** Czy postać gracza jest obecnie schowana za osłoną */
|
|
UPROPERTY(BlueprintReadOnly, Category = "Cover System")
|
|
bool bIsInCover = false;
|
|
|
|
/** Offset kamery podczas leżenia (osłona, ślizg) <br>
|
|
* Bezpiecznie będzie założyć że to najniżej jak kamera
|
|
* może zejść podczas gameplaya
|
|
*/
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
|
|
float LowEyeHeightOffset;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
TObjectPtr<UCurveFloat> CapsuleResizeCurve;
|
|
|
|
|
|
/// U FUNCTIONS ///
|
|
UFUNCTION()
|
|
void OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
|
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult
|
|
);
|
|
|
|
/// Przełącza gracza w tryb kucania
|
|
UFUNCTION(BlueprintCallable, Category = "Movement")
|
|
void CrouchCustom();
|
|
|
|
/// Próbuje wyjść z trybu kucania
|
|
UFUNCTION(BlueprintCallable, Category = "Movement")
|
|
void TryUnCrouchCustom();
|
|
|
|
DECLARE_MULTICAST_DELEGATE(FOnPlayerCrouchEvent);
|
|
FOnPlayerCrouchEvent OnPlayerCrouchStart;
|
|
FOnPlayerCrouchEvent OnPlayerCrouchStop;
|
|
|
|
UFUNCTION()
|
|
void AddHealthPoints(float addValue);
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
|
void SetEyePositionOffsetTarget(FVector LocationOffset);
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
|
void SetEyeRoll(float RollValue);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
FVector GetPlayerLocationAtFeet() const;
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
|
void SetTargetEyeHeight(float NewEyeHeight, const bool bCapsuleRelative = false);
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
|
float GetCurrentEyeHeight(const bool bCapsuleRelative = false) const;
|
|
|
|
UFUNCTION(BlueprintPure, Category="Camera")
|
|
float GetStandingEyeHeight(const bool bCapsuleRelative = false) const;
|
|
|
|
UFUNCTION(BlueprintPure, Category="Camera")
|
|
float GetCrouchingEyeHeight(const bool bCapsuleRelative = false) const;
|
|
|
|
UFUNCTION(BlueprintPure, Category="Movement")
|
|
bool IsCrouching() const;
|
|
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
float MaxHealth = 100.0f;
|
|
|
|
UWBP_PlayerUI* PlayerHud;
|
|
|
|
/** Wysokość kamery podczas kucania jest dostarczana przez Character.h*/
|
|
/** Wysokość kamery podczas stania <br>
|
|
* Też najwyższa wysokość na którą kamera może się wznieść
|
|
* podczas gameplaya
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category="Camera")
|
|
float StandingEyeHeight;
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
float GetFootOffset();
|
|
|
|
|
|
private:
|
|
FVector TargetEyeLocationOffset;
|
|
FVector EyeLocationOffset;
|
|
float TargetEyeRoll;
|
|
float EyeRoll;
|
|
|
|
float TargetEyeHeight;
|
|
float EyeHeight;
|
|
|
|
FTimeline CrouchTimeline;
|
|
|
|
UFUNCTION()
|
|
void CrouchingUpdate(float Alpha);
|
|
|
|
UFUNCTION()
|
|
void CrouchingFinished();
|
|
|
|
void UpdateCameraHeight(float DeltaTime);
|
|
void ApplyCameraOffsets(float DeltaTime);
|
|
};
|