// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "Items/Item.h" #include "Items/Inventory.h" #include "AstralQuestCharacter.generated.h" USTRUCT() struct FInteractionData { GENERATED_BODY() FInteractionData() { ViewedInteractionComponent = nullptr; LastInteractionCheckTime = 0.f; bInteractHeld = false; } //The current interactable component we're viewing, if there is one UPROPERTY() class UInteractionComponent* ViewedInteractionComponent; //The time when we last checked for an interactable UPROPERTY() float LastInteractionCheckTime; //Whether the local player is holding the interact key UPROPERTY() bool bInteractHeld; }; UCLASS(config=Game) class AAstralQuestCharacter : public ACharacter { GENERATED_BODY() /** Camera boom positioning the camera behind the character */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) class USpringArmComponent* CameraBoom; /** Follow camera */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) class UCameraComponent* FollowCamera; public: AAstralQuestCharacter(); /** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera) float BaseTurnRate; /** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera) float BaseLookUpRate; void Attack(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") int32 Level; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") int32 Health; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") int32 Damage; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") AItem* EquippedWeapon; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") float Energy; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") FText CurrentTask; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") int32 Defense; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Clothing") class ABaseshirt* Shirt; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Clothing") class ABasePants* Pants; UFUNCTION(BlueprintCallable) void ChangeMesh(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory") UInventory* Inventory; protected: /** Resets HMD orientation in VR. */ void OnResetVR(); virtual void BeginPlay() override; virtual void Tick(float DeltaTime) override; UPROPERTY(EditDefaultsOnly, Category = "Interaction") float InteractionCheckFrequency; UPROPERTY(EditDefaultsOnly, Category = "Interaction") float InteractionCheckDistance; void PerformInteractionCheck(); void CouldntFindInteractable(); void FoundNewInteractable(UInteractionComponent* Interactable); void BeginInteract(); void EndInteract(); void Interact(); void Hotbar1(); void Hotbar2(); void Hotbar3(); void Hotbar4(); void Hotbar5(); void Hotbar6(); void Hotbar7(); class AAstralQuestPlayerController* Controller; UFUNCTION(BlueprintCallable) void DeathAnimation(); UPROPERTY() FInteractionData interactionData; FORCEINLINE class UInteractionComponent* GetInteractable() const { return interactionData.ViewedInteractionComponent; } FORCEINLINE class UInventory* GetInventory() const { return Inventory; } FTimerHandle TimerHandle_Interact; public: bool IsInteracting() const; UPROPERTY(BlueprintReadOnly, VisibleAnywhere) int32 ItemEquipped; float GetRemaingInteractTime() const; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player info") bool CanPlaceBlocks; protected: /** Called for forwards/backward input */ void MoveForward(float Value); /** Called for side to side input */ void MoveRight(float Value); /** * Called via input to turn at a given rate. * @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate */ void TurnAtRate(float Rate); void PlaceBlock(); /** * Called via input to turn look up/down at a given rate. * @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate */ void LookUpAtRate(float Rate); /** Handler for when a touch input begins. */ void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location); /** Handler for when a touch input stops. */ void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location); // APawn interface virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; // End of APawn interface public: /** Returns CameraBoom subobject **/ FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } /** Returns FollowCamera subobject **/ FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } };