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>
45 lines
1.9 KiB
C++
45 lines
1.9 KiB
C++
// Copyright ExByte Studios. Item Interaction Ecosystem.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/Object.h"
|
|
#include "InteractionTypes.h"
|
|
#include "InteractionResolver.generated.h"
|
|
|
|
class APawn;
|
|
|
|
/**
|
|
* Central, stateless resolver (section 8.3). Given who is interacting and what
|
|
* they look at, it produces the ordered list of available options. Run on the
|
|
* client for predictive UI AND re-run on the server to authorize a request, so
|
|
* it must be deterministic and side-effect free.
|
|
*/
|
|
UCLASS()
|
|
class ITEMINTERACTION_API UInteractionResolver : public UObject
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** Assembles the interaction context for an instigator/target pair. */
|
|
UFUNCTION(BlueprintCallable, Category = "Interaction", meta = (WorldContext = "Instigator"))
|
|
static FInteractionContext BuildContext(APawn* Instigator, AActor* TargetActor);
|
|
|
|
/** All options available, highest priority first (section 8.6). */
|
|
UFUNCTION(BlueprintCallable, Category = "Interaction")
|
|
static void GetAvailableInteractions(APawn* Instigator, AActor* TargetActor, TArray<FInteractionOption>& OutOptions);
|
|
|
|
/** Convenience: the single best (highest priority, enabled) option. */
|
|
UFUNCTION(BlueprintCallable, Category = "Interaction")
|
|
static bool GetPrimaryInteraction(APawn* Instigator, AActor* TargetActor, FInteractionOption& OutOption);
|
|
|
|
/** Finds the held item on an instigator via IHeldItemInterface (actor or component). */
|
|
static bool ResolveHeldItem(APawn* Instigator, FItemInstanceData& OutItem);
|
|
|
|
private:
|
|
static void GatherCapabilityOptions(const FInteractionContext& Ctx, TArray<FInteractionOption>& Out);
|
|
static void GatherContainerOptions(const FInteractionContext& Ctx, TArray<FInteractionOption>& Out);
|
|
static void GatherDataDrivenOptions(const FInteractionContext& Ctx, TArray<FInteractionOption>& Out);
|
|
static void GatherActionClassOptions(const FInteractionContext& Ctx, TArray<FInteractionOption>& Out);
|
|
};
|