// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "Logging/LogMacros.h" #include "MoveState.h" #include "PilotCamera.h" #include "PilotCameraShake.h" #include "MonolithCharacter.generated.h" class UCharacterMovementComponent; class USkeletalMeshComponent; class UInputAction; class UInputComponent; class UInputMappingContext; struct FInputActionValue; DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All); UCLASS(config=Game) class AMonolithCharacter : public ACharacter { GENERATED_BODY() friend UPilotCamera; friend UPilotCameraShake; /** Jump Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UInputAction* JumpAction; /** Move Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UInputAction* MoveAction; /** Sprint Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UInputAction* SprintAction; /** Horizontal Dash Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UInputAction* HorDashAction; /** Vertical Dash Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UInputAction* VerDashAction; UPROPERTY(EditDefaultsOnly, Category=Input, meta=(AllowPrivateAccess = "true")) float SprintSpeed = 750.f; float WalkSpeed = 600.f; // Velocity Below this Value will be Ignored for Camera Effects UPROPERTY(EditAnywhere, Category = "MoveState", meta=(AllowPrivateAccess = "true")) float VelocityTolerance = 300.f; // Amount of impulse to add when dashing UPROPERTY(EditAnywhere, Category = "MoveState", meta=(AllowPrivateAccess = "true")) float DashImpulse = 600.f; UPROPERTY(EditDefaultsOnly, Category = "Health", meta=(AllowPrivateAccess = "true")) float Health = 100.f; float MaxHealth; USkeletalMeshComponent* Mesh1P; UCharacterMovementComponent* CharMove; FMoveState MoveState; FVector2D MovementVector; protected: void BeginPlay(); void Tick(float DeltaSeconds) override; UFUNCTION(BlueprintCallable) float GetHealth() { return Health; } UFUNCTION(BlueprintCallable) void ResetHealth() { Health = MaxHealth; } // Increase/Decrease health by this amount, will handle death UFUNCTION(BlueprintCallable) void IncrementHealth(float amount); UFUNCTION(BlueprintImplementableEvent) void Died(); /** Called for movement input */ void Move(const FInputActionValue& Value); void StopMove(); /** Called for SPRINT input */ void Sprint(const FInputActionValue& Value); void StopSprint(); /** Called for Dashing inputs */ void HorizontalDash(const FInputActionValue& Value); void VerticalDash(const FInputActionValue& Value); /** Called for looking input */ void Look(const FInputActionValue& Value); // APawn interface virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override; // End of APawn interface // Time to recharge 1 dash UPROPERTY(EditDefaultsOnly, Category = "MoveState", meta = (AllowPrivateAccess = "true")) float DashRechargeTime = 2.5f; FTimerHandle DashRechargeHandle; int DashesRemaining = 4; void StartRechargingDash(); void DashRecharged(); UFUNCTION(BlueprintImplementableEvent) void UpdateDashUI(int dashesRemaining); public: AMonolithCharacter(); /** Look Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) class UInputAction* LookAction; USkeletalMeshComponent* GetMesh1P() { if (Mesh1P) return Mesh1P; Mesh1P = Cast(GetComponentByClass(USkeletalMeshComponent::StaticClass())); return Mesh1P; } };