Neue Funktion `GetInteractableDisplayName` in `Interactable.h` hinzugefügt, um benutzerfreundliche Objektnamen für Interaktionsaufforderungen bereitzustellen. Die Logik in `InteractionContextMenuWidget.cpp` wurde überarbeitet: - Aufforderungen werden ausgeblendet, wenn keine Optionen verfügbar sind. - Objektnamen werden in die Aufforderungen integriert. - Zusätzliche Hinweise für sekundäre Interaktionen und Kontextmenüs hinzugefügt. Binärdateien (`BP_BerryBush.uasset`, `BP_Campfire.uasset`, `BP_ThirdPersonCharacter.uasset`, `WBP_InteractionContextMenu.uasset`) aktualisiert.
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/Interface.h"
|
|
#include "InteractionTypes.h"
|
|
#include "Interactable.generated.h"
|
|
|
|
/**
|
|
* Generic interaction interface. Blueprintable so pure-Blueprint actors
|
|
* (BP_DoorFrame, BP_JumpPad, ...) can implement it without any C++.
|
|
*/
|
|
UINTERFACE(MinimalAPI, Blueprintable)
|
|
class UInteractable : public UInterface
|
|
{
|
|
GENERATED_BODY()
|
|
};
|
|
|
|
/**
|
|
* Implement this and return interaction data - the InteractionComponent decides
|
|
* on its own whether that means a direct tap, a hold, or a Context Menu.
|
|
*/
|
|
class IInteractable
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
/** Returns the interactions currently available to Interactor, in priority order (index 0 = primary/tap). */
|
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
|
TArray<FInteractionOption> GetInteractionOptions(AActor* Interactor);
|
|
|
|
/** Friendly object name for prompts, e.g. "Berry Bush", "Wooden Chest", "Workbench". Optional - an empty default just drops the "with X" part of the prompt. */
|
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
|
FText GetInteractableDisplayName();
|
|
|
|
/** Runs the interaction identified by ActionID (one of the ActionIDs previously returned by GetInteractionOptions). */
|
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
|
void ExecuteInteraction(AActor* Interactor, FName ActionID);
|
|
};
|