// Copyright Team Lumi. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "LumiStance.h" #include "GameFramework/Character.h" #include "Logging/LogMacros.h" #include "LumiCharacter.generated.h" class USpringArmComponent; class UCameraComponent; class UInputMappingContext; class UInputAction; struct FInputActionValue; DECLARE_LOG_CATEGORY_EXTERN(LogLumiCharacter, Log, All); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FJumpDelegate); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FStanceChangedDelegate, ELumiStance, OldStance, ELumiStance, NewStance); static const FString PlayerStanceEnumPath = TEXT("/Game/Player/E_PlayerStance"); UCLASS() class WIZARDINGCENTRAL_API ALumiCharacter : public ACharacter { GENERATED_BODY() // Private UPROPERTIE'S -------------------------------------------------------------------------------------------- /** Camera boom positioning the camera behind the character */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera, meta = (AllowPrivateAccess = "true")) USpringArmComponent* CameraBoom; /** Follow camera */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera, meta = (AllowPrivateAccess = "true")) UCameraComponent* FollowCamera; /** MappingContext */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) UInputMappingContext* DefaultMappingContext; /** Grab Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) UInputAction* GrabAction; /** 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; /** Look Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) UInputAction* LookAction; /** The default boom offset */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera, meta = (AllowPrivateAccess = "true")) FVector DefaultBoomOffset = FVector(0.0f, 60.0f, 30.0f); /** The boom offset when aiming */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera, meta = (AllowPrivateAccess = "true")) FVector AimBoomOffset = FVector(200.0f, 65.0f, 45.0f); /** The current stance of the character */ UPROPERTY(BlueprintReadWrite, meta = (AllowPrivateAccess = "true")) ELumiStance CurrentStance = ELumiStance::Default; /** The stamina of the character */ UPROPERTY(BlueprintReadWrite, Category = "Stamina", meta = (AllowPrivateAccess = "true")) double Stamina = 10.0; UPROPERTY(BlueprintReadWrite, Category = "Stamina", meta = (AllowPrivateAccess = "true")) double MaxStamina = 10.0; protected: // UFUNCTION's ----------------------------------------------------------------------------------------------------- /** * Set the stance of the character * * @param NewStance The new stance to set * @return The stance before the new stance was set */ UFUNCTION(BlueprintCallable, Category = "Stance") ELumiStance SetCurrentStance(ELumiStance NewStance); /** * Event called when the character switches to the default stance */ UFUNCTION(BlueprintNativeEvent, Category = "Stance") void OnDefaultStance(); /** * Event called when the character switches to the magic stance */ UFUNCTION(BlueprintNativeEvent, Category = "Stance") void OnMagicStance(); /** * Check if the character has jumped the maximum number of times * * @return True if the character cannot jump anymore, false otherwise */ UFUNCTION(BlueprintPure, Category = "LumiCharacter") bool IsLastJump(); public: // Public Virtual Functions ---------------------------------------------------------------------------------------- // Called every frame // virtual void Tick(float DeltaTime) override; /** * Called to bind functionality to input * @param PlayerInputComponent The input component to bind to */ virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; protected: // Protected Virtual Functions ------------------------------------------------------------------------------------- /** * Called when the game starts or when spawned */ virtual void BeginPlay() override; public: // Public Functions ------------------------------------------------------------------------------------------------ /** * Sets default values for this character's properties */ ALumiCharacter(); /** * Getter for @property CurrentStance * * @return The current stance of the character */ ELumiStance GetCurrentStance() const; private: // Private Functions ----------------------------------------------------------------------------------------------- // Grab /** * Callback for when the grab action is triggered * @param Value The value of the input action */ void OnGrabActionTriggered(const FInputActionValue& Value); // Jump /** * Callback for when the jump action is started * @param Value The value of the input action */ void OnJumpActionStarted(const FInputActionValue& Value); /** * Callback for when the jump action is ongoing * @param Value The value of the input action */ void OnJumpActionOngoing(const FInputActionValue& Value); /** * Callback for when the jump action is completed * @param Value The value of the input action */ void OnJumpActionCompleted(const FInputActionValue& Value); // Move /** * Callback for when the move action is triggered * @param Value The value of the input action */ void OnMoveActionTriggered(const FInputActionValue& Value); // Look /** * Callback for when the look action is triggered * @param Value The value of the input action */ void OnLookActionTriggered(const FInputActionValue& Value); public: // Delegates ------------------------------------------------------------------------------------------------------- UPROPERTY(BlueprintAssignable, Category = "Input") FJumpDelegate OnJumpStarted; UPROPERTY(BlueprintAssignable, Category = "Stance") FStanceChangedDelegate OnStanceChanged; };