Files
ProjectEleri/Source/ProjectEleri/Items/DataAssets/ItemDataAsset.h

229 lines
9.4 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "../ItemContainer.h"
#include "Engine/DataTable.h"
#include "GameplayTagContainer.h"
#include "ItemDataAsset.generated.h"
USTRUCT(BlueprintType)
struct FPropertyStrength {
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
ItemProperty Property;
/** Effectivness of the potion or ingredient that determines how strong the crafted potion is */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
int32 Strength;
bool operator== (const ItemProperty &IP) {
return IP == Property;
}
bool operator== (const FPropertyStrength& PS) {
return PS.Property == Property;
}
FPropertyStrength()
{
Property = ItemProperty::Heal;
Strength = 0;
}
FPropertyStrength(ItemProperty InProperty, int32 InStrength)
{
Property = InProperty;
Strength = InStrength;
}
};
USTRUCT(BlueprintType)
struct FPropertyMapInfo {
GENERATED_BODY()
FPropertyMapInfo() {};
FPropertyMapInfo(ItemProperty InProp, FVector2D InCoord) {
Property = InProp;
Coordinates = InCoord;
}
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ItemProperty Property;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FVector2D Coordinates;
};
class ARemovableStaticMeshActor;
/**
*
*/
UCLASS(BlueprintType, PrioritizeCategories = ("Default", "Info", "Placeable", "Craftable", "Property Map", "Seed"))
class PROJECTELERI_API UItemDataAsset : public UPrimaryDataAsset
{
GENERATED_BODY()
Element StringToElement(FString ElemName);
public:
UItemDataAsset();
virtual void PostLoad() override;
FORCEINLINE friend bool operator <(const UItemDataAsset& FirstDataAsset, const UItemDataAsset& OtherDataAsset)
{
return FirstDataAsset.ItemName.ToString() < OtherDataAsset.ItemName.ToString();
}
/** ID of the item, generated by hand, usually Name + number */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info")
FName ItemID = "";
/** Default name of the item */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
FText ItemName;
/** Description of the item that's in the inventory view nad quick overview */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (MultiLine = true, AssetBundles = "Inventory, Book"))
FText ItemDescription;
/** Category the item belongs to */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
Category ItemCategory;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
FGameplayTagContainer ItemTags;
/** Description levels unlocked by leveling the ingredient or potion level,
since all of them have 2-3 levels there should only ever be that amount
of items in the array*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Info", AssetRegistrySearchable, meta = (MultiLine = true, AssetBundles = "Book"))
TArray<FText> ItemDescriptionLevels;
/** Icon of the item */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
TSoftObjectPtr<UTexture2D> ItemImage;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
TSoftObjectPtr<UPaperSprite> ItemSprite;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
float IconRotaiton;
/** Does the item stack or only one can be present at a time (all seeds should stack) */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable)
bool Stackable = true;
/** Mesh that the item / potion have, ignored for seeds */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
TSoftObjectPtr<UStaticMesh> ItemMesh;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
int32 GridScale = 1;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
FVector BoxExtentOverride;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides, MetaClass="/Script/ProjectEleri.RemovableStaticMeshActor"))
FSoftClassPath DecorationActorClassPath;
// Base cost of the item that's used to form buying and selling prices
// EDIT IT THE CSV
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
int32 BaseCost;
/*--------------------------------------------------------------------------------------------------------------------------*/
/** What base will the seed spawn when planting initiates */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
BaseType TypeOfBase;
/** Does this ingredient have a seed? Ignored in potions */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
bool IsSeed = true;
/** What is the base cost of the seed for this ingredient, ignored in potions */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
int32 SeedCost;
/** Grow time for a seed in game days, if the seed is a tree or wine this is the growth for them */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, DisplayName = "Grow Time", Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
int32 GrowTimeSelf;
/** Stages of a plant, set a mesh for certain days */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
TArray<FSeedStage> SeedStages;
/** What is the preferred temperature in alchemy that the ingredient releases it's
properties in the most effective way*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Seed", AssetRegistrySearchable, meta = (AssetBundles = "Book", EditCondition="ItemCategory==Category::Seed", EditConditionHides))
int32 PreferredTemperature;
/*-------------------------------------------------------------------------------------------------------------------------*/
/** Profession level needed to harvest the plant in case of an ingredient
and profession level needed to have a chance of HQ potion in the case of potions*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
int32 ProfessionLevelNeeded;
/** The item element describes what type of crystal goes into creating
a potion of the same element type
EDIT IN CSV*/
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
Element ItemElement;
/** The chemical alignment of item, coresponds to a clock */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Craftable")
TArray<int32> ChemicalAlignments;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Craftable")
EChemicalAlignment ChemicalAlignment;
/** What are the main properties of the ingredient/potion
* EDIT IN CSV
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
TArray<FPropertyStrength> Properties;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
TArray<FPropertyMapInfo> PropertyMap;
/** What defects does a certain ingredient have */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
TArray<FPropertyStrength> Defects;
/*Item effectiveness is it's ability to effect the body in various ways, 1 being least effective and 4 most effective
* EDIT IN CSV
*/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Craftable", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
int32 Effectiveness;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Craftable", meta = (ClampMin = 1.f, ClampMax = 2.f, UIMin = 1.f, UIMax = 2.f, Delta = 0.01f))
float CraftableDifficulty = 1.f;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Book"))
FDataTableRowHandle DataTableRowHandleRef;
/** Does a potion have a fixed recipe? */
UPROPERTY()
bool HasRecipe;
/** Array of item ids that are required to craft the potion if it has a fixed recipe */
UPROPERTY()
TArray<FPrimaryAssetId> RecipeItemsID;
virtual Category GetCategory();
int32 GetPropertyStrength(ItemProperty EProperty);
UFUNCTION(CallInEditor)
void BuildPropertyMap();
};