This commit is contained in:
benroshio 2024-06-23 11:43:16 -04:00
commit 9aa9d15e13
44 changed files with 157 additions and 89 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "CraftingInfo.h"

View File

@ -0,0 +1,40 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataTable.h"
#include "CraftingInfo.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FCraftingInfo : public FTableRowBase
{
GENERATED_BODY();
public:
//unique ID of item that is being used to create the item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ComponentID;
//unique ID of the item that gets created
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ProductID;
//do we want to destroy the component?
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemA;
//
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemB;
bool operator==(const FCraftingInfo& OtherItem) const {
return ComponentID == OtherItem.ComponentID;
}
};

View File

@ -18,7 +18,7 @@ void AHYInteractableActor::Interact_Implementation(APlayerController* Controller
FString AHYInteractableActor::GetInteractText() const
{
return FString::Printf(TEXT("s%: Press F to %s"), *Name, *Action);
return FString::Printf(TEXT("%s: Press F to %s"), *Name, *Action);
}
// Called when the game starts or when spawned

View File

@ -30,7 +30,7 @@ public:
UPROPERTY(EditDefaultsOnly)
FString Action;
UFUNCTION(Blueprintcallable, Category = "Pickup")
UFUNCTION(BlueprintCallable, Category = "Pickup")
FString GetInteractText() const;
protected:

View File

@ -12,7 +12,7 @@ AHYManualPickUp::AHYManualPickUp()
ItemID = FName("No ID");
Super::Name = "Item";
Super::Action = "pickup";
Super::Action = "Pick up";
}
void AHYManualPickUp::Interact_Implementation(APlayerController* Controller)

View File

@ -31,7 +31,7 @@ public:
UFUNCTION(BlueprintCallable, Category = "Utils")
bool AddItemToInventoryByID(FName ID);
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
class AHYInteractableActor* CurrentInteractable;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
@ -43,14 +43,15 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 InventoryWeightLimit;
//interacts with the Interactable objects
UFUNCTION(BlueprintCallable, Category = "Utils")
void Interact();
#pragma endregion
protected:
//interacts with the Interactable objects
void Interact();
//abstract function to override in order to
//bind actions or axis to different input components
virtual void SetupInputComponent() override;

View File

@ -5,10 +5,12 @@
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Engine/DataTable.h"
#include "HYManualPickUp.h"
#include "CraftingInfo.h"
#include "InventoryItem.generated.h"
/**
*
* Represents an item that can be added to player's inventory
*/
USTRUCT(BlueprintType)
struct FInventoryItem : public FTableRowBase
@ -22,6 +24,10 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ItemID;
//queue of items that are dropped and spawned back into the world
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<class AHYManualPickUp> ItemPickup;
//name of the item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText ItemName;
@ -35,12 +41,20 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool OnlyDropped;
//can this item be consumed/used?
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool CanBeUsed;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* ItemIcon;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText ItemDescription;
////all the possible crafting combinations for this particular item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FCraftingInfo> CraftCombinations;
bool operator==(const FInventoryItem& OtherItem) const {
return ItemID == OtherItem.ItemID;
}

View File

@ -2,19 +2,10 @@
#pragma once
#ifndef _HWANYOUNG2_H__
#define _HWANYOUNG2_H__
#include "CoreMinimal.h"
UENUM(BlueprintType)
enum class EAbilityInputID : uint8
{
None UMETA(DisplayName = "None"), //no input given
Confirm UMETA(DisplayName = "Confirm"),
Cancel UMETA(DisplayName = "Cancel"),
UseWeapon UMETA(DisplayName = "Use Weapon"), //using melee weapon to attack
SwitchWeapon UMETA(DisplayName = "Switch Weapons"), //switching weapons
UseActive1 UMETA(DisplayName = "Use Active Skill 1"), //active 1
UseActive2 UMETA(DisplayName = "Use Active Skill 2"), //active 2
UseActive3 UMETA(DisplayName = "Use Active Skill 3"), //active 3
UseUlt UMETA(DisplayName = "Use Ultimate Skill"), //ult
PassiveDash UMETA(DisplayName = "Dash") //dash (passive)
};
#define COLLISION_INTERACTABLE ECC_GameTraceChannel1;
#endif

View File

@ -63,7 +63,7 @@ void Ahwanyoung2Character::CheckForInteractables()
FHitResult HitResult;
// The range of area the system should check for interactables
int32 Range = 500; //this can be changed
int32 Range = 800; //this can be changed
//The start of the trace is the transform of the follow camera
FVector StartTrace = FollowCamera->GetComponentLocation();
@ -80,22 +80,21 @@ void Ahwanyoung2Character::CheckForInteractables()
//object attached to the character and cast it as player character controller class
AHYPlayerCharacController* IController = Cast<AHYPlayerCharacController>(GetController());
if (IController) {
//Checking if something is hit by the line cast within the range
if (GetWorld()->LineTraceSingleByChannel(HitResult, StartTrace, EndTrace,
ECC_Visibility, QueryParams)) {
//Cast the actor to AInteractable
AHYInteractableActor* Interactable = Cast<AHYInteractableActor>(HitResult.GetActor());
if (Interactable) {
if (AHYInteractableActor* Interactable = Cast<AHYInteractableActor>(HitResult.GetActor())) {
IController->CurrentInteractable = Interactable;
return;
}
}
} else {
IController->CurrentInteractable = nullptr;
}
}