Server-authoritative, data-driven item/inventory/interaction/carry/equipment/ world-slot/placement/crafting framework. 8 modules, compiles against UE 5.7. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
130 lines
3.9 KiB
C
130 lines
3.9 KiB
C
// Copyright ExByte Studios. Item Interaction Ecosystem.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/DataTable.h"
|
|
#include "GameplayTagContainer.h"
|
|
#include "ItemEnums.h"
|
|
#include "ItemAuxiliaryRows.generated.h"
|
|
|
|
/**
|
|
* DT_ItemProperties row (section 6.2): default runtime property for an item.
|
|
* Multiple rows share one ItemId, so the row name is arbitrary - the database
|
|
* indexes these by ItemId.
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct ITEMDATABASE_API FItemPropertyRow : public FTableRowBase
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
FName ItemId;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
FGameplayTag PropertyTag;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
float DefaultValue = 0.f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
float Min = 0.f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
float Max = 1.f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
EItemPropertyReplicationPolicy ReplicationPolicy = EItemPropertyReplicationPolicy::OwnerOnly;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Property")
|
|
bool bSave = true;
|
|
};
|
|
|
|
/**
|
|
* DT_ItemFeatures row (section 6.3): one tunable parameter of a feature.
|
|
* e.g. raw_meat | Rotting | DecayRatePerHour | 0.08
|
|
* Value is stored as text so it can carry floats, ints or item ids uniformly.
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct ITEMDATABASE_API FItemFeatureRow : public FTableRowBase
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feature")
|
|
FName ItemId;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feature")
|
|
FGameplayTag Feature;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feature")
|
|
FName Param;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feature")
|
|
FString Value;
|
|
|
|
float GetFloat(float Fallback = 0.f) const
|
|
{
|
|
return Value.IsNumeric() ? FCString::Atof(*Value) : Fallback;
|
|
}
|
|
int32 GetInt(int32 Fallback = 0) const
|
|
{
|
|
return Value.IsNumeric() ? FCString::Atoi(*Value) : Fallback;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* DT_ItemInteractions row (section 6.4): a data-driven interaction option.
|
|
* The interaction resolver turns matching rows into FInteractionOptions.
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct ITEMDATABASE_API FItemInteractionRow : public FTableRowBase
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
FName ItemId;
|
|
|
|
/** Context filter, e.g. "World", "Inventory", "Held+Vehicle", "Held+Generator". */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
FName Context;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
FGameplayTag ActionTag;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
EItemInteractionMode InteractionMode = EItemInteractionMode::None;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
int32 Priority = 0;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
bool bRequiresHold = false;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
float HoldDuration = 0.f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
float ActionDuration = 0.f;
|
|
|
|
/** Free-form requirement expression resolved by the requirement system (section 18). */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
FString Requirement;
|
|
|
|
/** Result verb, e.g. AddToInventory / HoldWorldItem / InstallIntoSlot / TransferFuel. */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
|
|
FName Result;
|
|
};
|
|
|
|
/** DT_ItemRedirects row (section 26.1): maps a retired ItemId to its replacement. */
|
|
USTRUCT(BlueprintType)
|
|
struct ITEMDATABASE_API FItemRedirectRow : public FTableRowBase
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redirect")
|
|
FName OldItemId;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redirect")
|
|
FName NewItemId;
|
|
};
|