// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "Logging/LogMacros.h" #include "AgrarianGameCharacter.generated.h" class USpringArmComponent; class UCameraComponent; class UInputAction; class UAgrarianBuildingPlacementComponent; class UAgrarianCraftingComponent; class UAgrarianInventoryComponent; class UAgrarianSurvivalComponent; struct FInputActionValue; DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All); /** * A simple player-controllable third person character * Implements a controllable orbiting camera */ UCLASS(abstract) class AAgrarianGameCharacter : public ACharacter { GENERATED_BODY() /** Camera boom positioning the camera behind the character */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) USpringArmComponent* CameraBoom; /** Follow camera */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UCameraComponent* FollowCamera; /** Replicated survival state for hunger, thirst, stamina, health, temperature, and injury. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UAgrarianSurvivalComponent* SurvivalComponent; /** Replicated inventory used by gathering, primitive crafting, and early economy prototypes. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UAgrarianInventoryComponent* InventoryComponent; /** Primitive crafting component for MVP recipes and future knowledge progression. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UAgrarianCraftingComponent* CraftingComponent; /** Server-authoritative primitive building placement component. */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UAgrarianBuildingPlacementComponent* BuildingPlacementComponent; protected: /** Jump Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* JumpAction; /** Move Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* MoveAction; /** Look Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* LookAction; /** Mouse Look Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* MouseLookAction; /** Interact Input Action */ UPROPERTY(EditAnywhere, Category="Input") UInputAction* InteractAction; /** How far the player can interact with MVP objects. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Agrarian|Interaction", meta = (ClampMin = "100")) float InteractionDistance = 450.0f; public: /** Constructor */ AAgrarianGameCharacter(); protected: /** Initialize input action bindings */ virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; protected: /** Called for movement input */ void Move(const FInputActionValue& Value); /** Called for looking input */ void Look(const FInputActionValue& Value); /** Called for interaction input */ void Interact(); public: /** Handles move inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoMove(float Right, float Forward); /** Handles look inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoLook(float Yaw, float Pitch); /** Handles jump pressed inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoJumpStart(); /** Handles jump pressed inputs from either controls or UI interfaces */ UFUNCTION(BlueprintCallable, Category="Input") virtual void DoJumpEnd(); /** Attempts to interact with the object in front of the player. */ UFUNCTION(BlueprintCallable, Category="Agrarian|Interaction") virtual void TryInteract(); /** Server-authoritative interaction entry point. */ UFUNCTION(Server, Reliable) void ServerInteract(AActor* TargetActor); public: /** Returns CameraBoom subobject **/ FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } /** Returns FollowCamera subobject **/ FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } /** Returns SurvivalComponent subobject **/ FORCEINLINE UAgrarianSurvivalComponent* GetSurvivalComponent() const { return SurvivalComponent; } /** Returns InventoryComponent subobject **/ FORCEINLINE UAgrarianInventoryComponent* GetInventoryComponent() const { return InventoryComponent; } /** Returns CraftingComponent subobject **/ FORCEINLINE UAgrarianCraftingComponent* GetCraftingComponent() const { return CraftingComponent; } /** Returns BuildingPlacementComponent subobject **/ FORCEINLINE UAgrarianBuildingPlacementComponent* GetBuildingPlacementComponent() const { return BuildingPlacementComponent; } };