Init Commit

This commit is contained in:
2024-10-22 18:22:34 -05:00
parent d0bb3a3b13
commit cd51f057b7
529 changed files with 397763 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class epic_inventoryTarget : TargetRules
{
public epic_inventoryTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.Add("epic_inventory");
}
}

View File

@@ -0,0 +1,36 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AC_InventoryItem.h"
#include "Engine/DataTable.h"
#include "EpicEnumsAndStructs.h"
// Sets default values for this component's properties
UAC_InventoryItem::UAC_InventoryItem()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UAC_InventoryItem::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UAC_InventoryItem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}

View File

@@ -0,0 +1,86 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AC_PlayerInventory.h"
#include "Engine/DataTable.h"
// Sets default values for this component's properties
UAC_PlayerInventory::UAC_PlayerInventory()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UAC_PlayerInventory::BeginPlay()
{
Super::BeginPlay();
InitializePlayerInventory();
// ...
}
// Called every frame
void UAC_PlayerInventory::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UAC_PlayerInventory::InitializePlayerInventory()
{
for (const FStartingItems& Item : StartingItems)
{
FString ContextString = TEXT("Initialize Player Inventory");
// For each of the quantities defined
for (int32 i = 0; i < Item.QuantityOfItem; i++)
{
// Is the data table valid?
if (Item.ItemDataTableAndRow.DataTable)
{
FBaseItemInfo* LocItemInfo = Item.ItemDataTableAndRow.DataTable->FindRow<FBaseItemInfo>(Item.ItemDataTableAndRow.RowName, ContextString);
//If the rows struct is valid
if (LocItemInfo)
{
// Add item to player inventory array
PlayerInventory.Add(*LocItemInfo);
}
}
}
}
}
TArray<FBaseItemInfo> UAC_PlayerInventory::GetPlayerInventory()
{
if (!PlayerInventory.IsEmpty())
{
return PlayerInventory;
}
else {
UE_LOG(LogTemp, Warning, TEXT("Player Inventory is empty!"));
return PlayerInventory;
}
}
void UAC_PlayerInventory::RequestAddItem(FBaseItemInfo InItemInfo, int32 InItemQuantity)
{
for (int32 i = 0; i < InItemQuantity; i++)
{
PlayerInventory.Add(InItemInfo);
}
}

View File

@@ -0,0 +1,66 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AC_PlayerStats.h"
#include "AC_PlayerInventory.h"
#include "EpicEnumsAndStructs.h"
// Sets default values for this component's properties
UAC_PlayerStats::UAC_PlayerStats()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
void UAC_PlayerStats::InitializePlayerStats()
{
CurrentHealth = MaxHealth;
CurrentStamina = MaxStamina;
CurrentMana = MaxMana;
UpdateCurrentCarryWeight(CurrentCarryWeight);
}
float UAC_PlayerStats::UpdateCurrentCarryWeight(float& InCurrentCarryWeight)
{
APawn* PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
float LocCarryWeight = 0.f;
if (PlayerPawn)
{
TArray<FBaseItemInfo> PlayerInventory = PlayerPawn->FindComponentByClass<UAC_PlayerInventory>()->GetPlayerInventory();
for (const FBaseItemInfo& InventoryItem : PlayerInventory)
{
LocCarryWeight += InventoryItem.ItemWeight;
}
InCurrentCarryWeight = LocCarryWeight;
}
return InCurrentCarryWeight;
}
// Called when the game starts
void UAC_PlayerStats::BeginPlay()
{
Super::BeginPlay();
InitializePlayerStats();
// ...
}
// Called every frame
void UAC_PlayerStats::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}

View File

@@ -0,0 +1,61 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BPFL_EpicInventory.h"
#include "AC_PlayerInventory.h"
#include "AC_InventoryItem.h"
//Returns the player's Inventory Component
UAC_PlayerInventory* UBPFL_EpicInventory::GetPlayerInventoryComponent(UObject* WorldContextObject)
{
UAC_PlayerInventory* PlayerInventoryComponent(nullptr);
APlayerController* PlayerController = WorldContextObject->GetWorld()->GetFirstPlayerController();
if (PlayerController)
{
APawn* PlayerPawn = PlayerController->GetPawn();
if (PlayerPawn)
{
PlayerInventoryComponent = PlayerPawn->FindComponentByClass<UAC_PlayerInventory>();
}
}
return PlayerInventoryComponent;
}
void UBPFL_EpicInventory::RequestInteraction(AActor* InteractingActor)
{
UAC_PlayerInventory* PlayerInventoryComponent = GetPlayerInventoryComponent(InteractingActor);
UAC_InventoryItem* ObjectInventoryItem = InteractingActor->FindComponentByClass<UAC_InventoryItem>();
TArray<FStartingItems> ObjectItemInfoArray = ObjectInventoryItem->ItemInformation;
if (PlayerInventoryComponent)
{
if (PlayerInventoryComponent->bUseInventoryCap)
{
//Check type of cap and if there is room then add item
UE_LOG(LogTemp, Warning, TEXT("Implement cap check"))
}
else {
UE_LOG(LogTemp, Warning, TEXT("Implement AddItem"));
// Add item for each item defined in the item array on the component
for (const FStartingItems& DTRow : ObjectItemInfoArray)
{
FBaseItemInfo* LocItemInfo = DTRow.ItemDataTableAndRow.DataTable->FindRow<FBaseItemInfo>(DTRow.ItemDataTableAndRow.RowName, FString("Interaction Request"));
int32 LocItemQuantity = DTRow.QuantityOfItem;
PlayerInventoryComponent->RequestAddItem(*LocItemInfo, LocItemQuantity);
}
}
InteractingActor->Destroy();
}
}

View File

@@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "EpicEnumsAndStructs.h"
EpicEnumsAndStructs::EpicEnumsAndStructs()
{
}
EpicEnumsAndStructs::~EpicEnumsAndStructs()
{
}

View File

@@ -0,0 +1,41 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "EpicEnumsAndStructs.h"
#include "AC_InventoryItem.generated.h"
// Forward Declarations
struct FDataTabelRowHandle;
enum class EItemType : uint8;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class EPIC_INVENTORY_API UAC_InventoryItem : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UAC_InventoryItem();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
TArray<FStartingItems> ItemInformation;
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

View File

@@ -0,0 +1,66 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "EpicEnumsAndStructs.h"
#include "AC_PlayerInventory.generated.h"
//Forward Declarations
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class EPIC_INVENTORY_API UAC_PlayerInventory : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UAC_PlayerInventory();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory Configuration")
bool bUseInventoryCap;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory Configuration", meta = (EditCondition = "bUseInventoryCap", EditConditionHides, Tooltip = "Select the type of inventory cap. WEIGHT uses item weight, TOTAL uses total number of items, TOTAL PER CATEGORY uses a cap per category of inventory item"))
EInventoryCapType InventoryCapType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory Configuration", meta = (EditCondition = "InventoryCapType == EInventoryCapType::TotalItems", EditConditionHides))
int32 InventoryMaxCapacity = 100;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory Configuration", meta = (EditCondition = "InventoryCapType == EInventoryCapType::PerCat", EditConditionHides))
TMap<EItemType, int32> InventoryCapacityPerCategory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory Starting Items")
TArray<FStartingItems> StartingItems;
// Initialize the inventory component with default inventory, if any.
UFUNCTION(BlueprintCallable)
void InitializePlayerInventory();
UFUNCTION(BlueprintCallable)
TArray<FBaseItemInfo> GetPlayerInventory();
UFUNCTION(BlueprintCallable)
void RequestAddItem(FBaseItemInfo InItemInfo, int32 InItemQuantity);
protected:
// Called when the game starts
virtual void BeginPlay() override;
private:
//Master player inventory variable
TArray<FBaseItemInfo> PlayerInventory;
};

View File

@@ -0,0 +1,58 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "AC_PlayerStats.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class EPIC_INVENTORY_API UAC_PlayerStats : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UAC_PlayerStats();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Stat Defaults")
float MaxHealth = 100;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Stat Defaults")
float MaxStamina = 100;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Stat Defaults")
float MaxMana = 100;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Stat Defaults")
float MaxCarryWeight = 200;
UPROPERTY(BlueprintReadWrite, Category = "Current Player Stats")
float CurrentHealth;
UPROPERTY(BlueprintReadWrite, Category = "Current Player Stats")
float CurrentStamina;
UPROPERTY(BlueprintReadWrite, Category = "Current Player Stats")
float CurrentMana;
UPROPERTY(BlueprintReadWrite, Category = "Current Player Stats")
float CurrentCarryWeight;
UFUNCTION(BlueprintCallable)
void InitializePlayerStats();
UFUNCTION(BlueprintCallable)
float UpdateCurrentCarryWeight(float& InCurrentCarryWeight);
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

View File

@@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "BPFL_EpicInventory.generated.h"
//Forward Declarations
class UAC_PlayerInventory;
class UAC_InventoryItem;
/**
*
*/
UCLASS()
class EPIC_INVENTORY_API UBPFL_EpicInventory : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
// Get the players inventory actor component
UFUNCTION(BlueprintCallable, Category = "Player Inventory Getters")
static UAC_PlayerInventory* GetPlayerInventoryComponent(UObject* WorldContextObject);
//Request interaction with the player quest component
UFUNCTION(BlueprintCallable, Category = "Inventory Interaction")
static void RequestInteraction(AActor* InteractingActor);
};

View File

@@ -0,0 +1,401 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Texture2D.h"
#include "Engine/StaticMesh.h"
#include "Engine/SkeletalMesh.h"
#include "Engine/DataTable.h"
#include "EpicEnumsAndStructs.generated.h"
/**
*
*/
class EPIC_INVENTORY_API EpicEnumsAndStructs
{
public:
EpicEnumsAndStructs();
~EpicEnumsAndStructs();
};
// SYSTEM WIDE ENUMS
// ITEM TYPE ENUM
UENUM(BlueprintType)
enum class EItemType : uint8
{
None UMETA(DisplayName = "None"),
Armor UMETA(DisplayName = "Armor"),
Weapon UMETA(DisplayeName = "Weapon"),
Goods UMETA(DisplayeName = "Goods")
};
// WEAPON CATEGORY ENUM
UENUM(BlueprintType)
enum class EWeaponCategory : uint8
{
None UMETA(DisplayName = "None"),
OneHSword UMETA(DisplayName = "1H Sword"),
TwoHSword UMETA(DisplayeName = "2H Sword"),
Dagger UMETA(DisplayeName = "Dagger"),
Bow UMETA(DisplayeName = "Bow"),
OneHAxe UMETA(DisplayeName = "1H Axe"),
TwoHAxe UMETA(DisplayeName = "2H Axe")
};
// ARMOR CATEGORY ENUM
UENUM(BlueprintType)
enum class EArmorCategory : uint8
{
None UMETA(DisplayName = "None"),
Shield UMETA(DisplayName = "Shield"),
Boots UMETA(DisplayeName = "Boots"),
Legs UMETA(DisplayeName = "Legs"),
Chest UMETA(DisplayeName = "Chest"),
Arms UMETA(DisplayeName = "Arms"),
Helmet UMETA(DisplayeName = "Helmet"),
Jewelry UMETA(DisplayeName = "Jewelry")
};
// GOODS CATEGORY ENUM
UENUM(BlueprintType)
enum class EGoodsCategory : uint8
{
None UMETA(DisplayName = "None"),
Consumable UMETA(DisplayName = "Consumable"),
QuestItem UMETA(DisplayeName = "Quest Item"),
Book UMETA(DisplayeName = "Book"),
Junk UMETA(DisplayeName = "Junk")
};
// ITEM RARITY ENUM
UENUM(BlueprintType)
enum class EItemRarity : uint8
{
None UMETA(DisplayName = "None"),
Common UMETA(DisplayName = "Common"),
Uncommon UMETA(DisplayeName = "Uncommon"),
Rare UMETA(DisplayeName = "Rare"),
Epic UMETA(DisplayeName = "Epic"),
Legendary UMETA(DisplayeName = "Legendary"),
Mythic UMETA(DisplayeName = "Mythic")
};
//Inventory Cap Types
UENUM(BlueprintType)
enum class EInventoryCapType : uint8
{
None UMETA(DisplayName = "None"),
Weight UMETA(DisplayName = "Weight"),
TotalItems UMETA(DisplayName = "Total Items"),
PerCat UMETA(DisplayName = "Total Items per Category")
};
// SYSTEM WIDE STRUCTS
//Player starting items struct
USTRUCT(BlueprintType)
struct FStartingItems
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FDataTableRowHandle ItemDataTableAndRow;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 QuantityOfItem;
};
//Base Stat definitions
USTRUCT(BlueprintType)
struct FBaseStats
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxHealth;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxStamina;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxMana;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Level;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float CurrentHealth;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float CurrentStamina;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float CurrentMana;
};
// Base Item Struct that defines basic details
USTRUCT(BlueprintType)
struct FBaseItemInfo : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
FText Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
FText Description;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
int32 RequiredLevel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
UTexture2D* Icon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
bool bUseSkeletalMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info", meta = (EditCondition="bUseSkeletalMesh == false", EditConditionHides))
UStaticMesh* StaticMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info", meta = (EditCondition="bUseSkeletalMesh == true", EditConditionHides))
USkeletalMesh* SkeletalMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
FName EquipSocket;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
float Price;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
EItemRarity Rarity;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
float ItemWeight;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info")
EItemType ItemType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Goods", EditConditionHides))
EGoodsCategory GoodsCategory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Armor", EditConditionHides))
EArmorCategory ArmorCategory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Weapon", EditConditionHides))
EWeaponCategory WeaponCategory;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Armor", EditConditionHides))
FDataTableRowHandle ArmorDataTableRow;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Weapon", EditConditionHides))
FDataTableRowHandle WeaponDataTableRow;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Specific Item Info", meta = (EditCondition = "ItemType == EItemType::Goods && GoodsCategory != EGoodsCategory::Junk", EditConditionHides))
FDataTableRowHandle GoodsDataTableRow;
};
// Struct to define armor stats
USTRUCT(BlueprintType)
struct FArmorStats
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stats")
float ArmorAmount;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stats")
float HealthAmount;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stats")
float StaminaAmount;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stats")
float ManaAmount;
};
//Struct to define weapon stats
USTRUCT(BlueprintType)
struct FWeaponStats
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stats")
float HackDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stats")
float StabDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stats")
float SlashDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stats")
float MagicDamage;
};
//Struct for Armor Data Table
USTRUCT(BlueprintType)
struct FArmorDataTable : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stats")
FArmorStats ArmorStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stat Modifiers")
bool bModifyWeaponStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stat Modifiers", meta = (EditCondition="bModifyWeaponStats == true", EditConditionHides))
FWeaponStats WeaponStatModifiers;
};
//Struct for Weapon Data Table
USTRUCT(BlueprintType)
struct FWeaponDataTable : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stats")
FWeaponStats WeaponStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stat Modifiers")
bool bModifyArmorStats;
UPROPERTY(EditAnywhere, blueprintReadWrite, Category = "Armor Stat Modifiers", meta = (EditCondition="bModifyArmorStats == true", EditConditionHides))
FArmorStats ArmorStatModifiers;
};
//Struct for Goods Data Table
//USTRUCT(BlueprintType)
//struct FGoodsDataTable : public FTableRowBase
//{
// GENERATED_BODY()
//
//public:
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Goods Base Info")
// EGoodsCategory GoodsCategory;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Info")
// FDataTableRowHandle ConsumableDataTable;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest Info")
// FDataTableRowHandle QuestItemDataTableAndRow;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest Info")
// FName ObjectiveName;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Book Info")
// FDataTableRowHandle BookDataTable;
//
//};
//Struct for Consumable Information and Data Tables
USTRUCT(BlueprintType)
struct FConsumableInfo : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Info")
float Duration;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Info")
bool bModifyBaseStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Info")
bool bModifyArmorStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Info")
bool bModifyWeaponStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Stat Modifications", meta = (EditCondition = "bModifyBaseStats == true", EditConditionHides))
FBaseStats StatModification;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Armor Stat Modifications", meta = (EditCondition = "bModifyArmorStats == true", EditConditionHides))
FArmorStats ArmorModifications;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Stat Modifications", meta=(EditCondition="bModifyWeaponStats", EditConditionHides))
FWeaponStats WeaponModifications;
};
//Struct for Quest Item information and Data Tables
USTRUCT(BlueprintType)
struct FQuestItemInfo : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest Info")
FName QuestName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest Info")
FName ObjectiveName;
};
//Struct for Book information and Data Tables
USTRUCT(BlueprintType)
struct FBookInfo : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Book Info")
FText BookText;
};
//USTRUCT(BlueprintType)
//struct FItemMasterInfo : public FTableRowBase
//{
// GENERATED_BODY()
//
//public:
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
// FDataTableRowHandle BaseItemDataTableRow;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
// EItemType ItemType;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info")
// int32 ItemQuantity = 1;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info", meta = (EditCondition = "ItemType == EItemType::Armor", EditConditionHides))
// FDataTableRowHandle ArmorDataTableRow;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info", meta = (EditCondition = "ItemType == EItemType::Weapon", EditConditionHides))
// FDataTableRowHandle WeaponDataTableRow;
//
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Base Item Info", meta = (EditCondition = "ItemType == EItemType::Goods", EditConditionHides))
// FDataTableRowHandle GoodsDataTableRow;
//};

View File

@@ -0,0 +1,13 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class epic_inventory : ModuleRules
{
public epic_inventory(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
}
}

View File

@@ -0,0 +1,7 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "epic_inventory.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, epic_inventory, "epic_inventory" );

View File

@@ -0,0 +1,5 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"

View File

@@ -0,0 +1,130 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "epic_inventoryCharacter.h"
#include "Engine/LocalPlayer.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/Controller.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputActionValue.h"
DEFINE_LOG_CATEGORY(LogTemplateCharacter);
//////////////////////////////////////////////////////////////////////////
// Aepic_inventoryCharacter
Aepic_inventoryCharacter::Aepic_inventoryCharacter()
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
// Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
// instead of recompiling to adjust them
GetCharacterMovement()->JumpZVelocity = 700.f;
GetCharacterMovement()->AirControl = 0.35f;
GetCharacterMovement()->MaxWalkSpeed = 500.f;
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
GetCharacterMovement()->BrakingDecelerationFalling = 1500.0f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
}
void Aepic_inventoryCharacter::BeginPlay()
{
// Call the base class
Super::BeginPlay();
}
//////////////////////////////////////////////////////////////////////////
// Input
void Aepic_inventoryCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
// Add Input Mapping Context
if (APlayerController* PlayerController = Cast<APlayerController>(GetController()))
{
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
{
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
}
// Set up action bindings
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent)) {
// Jumping
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
// Moving
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &Aepic_inventoryCharacter::Move);
// Looking
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &Aepic_inventoryCharacter::Look);
}
else
{
UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this));
}
}
void Aepic_inventoryCharacter::Move(const FInputActionValue& Value)
{
// input is a Vector2D
FVector2D MovementVector = Value.Get<FVector2D>();
if (Controller != nullptr)
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
// get right vector
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement
AddMovementInput(ForwardDirection, MovementVector.Y);
AddMovementInput(RightDirection, MovementVector.X);
}
}
void Aepic_inventoryCharacter::Look(const FInputActionValue& Value)
{
// input is a Vector2D
FVector2D LookAxisVector = Value.Get<FVector2D>();
if (Controller != nullptr)
{
// add yaw and pitch input to controller
AddControllerYawInput(LookAxisVector.X);
AddControllerPitchInput(LookAxisVector.Y);
}
}

View File

@@ -0,0 +1,73 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Logging/LogMacros.h"
#include "epic_inventoryCharacter.generated.h"
class USpringArmComponent;
class UCameraComponent;
class UInputMappingContext;
class UInputAction;
struct FInputActionValue;
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
UCLASS(config=Game)
class Aepic_inventoryCharacter : public ACharacter
{
GENERATED_BODY()
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* CameraBoom;
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
UCameraComponent* FollowCamera;
/** MappingContext */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputMappingContext* DefaultMappingContext;
/** 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;
public:
Aepic_inventoryCharacter();
protected:
/** Called for movement input */
void Move(const FInputActionValue& Value);
/** Called for looking input */
void Look(const FInputActionValue& Value);
protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// To add mapping context
virtual void BeginPlay();
public:
/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};

View File

@@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "epic_inventoryGameMode.h"
#include "epic_inventoryCharacter.h"
#include "UObject/ConstructorHelpers.h"
Aepic_inventoryGameMode::Aepic_inventoryGameMode()
{
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter"));
if (PlayerPawnBPClass.Class != NULL)
{
DefaultPawnClass = PlayerPawnBPClass.Class;
}
}

View File

@@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "epic_inventoryGameMode.generated.h"
UCLASS(minimalapi)
class Aepic_inventoryGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
Aepic_inventoryGameMode();
};

View File

@@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class epic_inventoryEditorTarget : TargetRules
{
public epic_inventoryEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.Add("epic_inventory");
}
}