(Feat) Add Cooking and Workbench
This commit is contained in:
@@ -57,6 +57,7 @@ void UInteractionComponent::UpdateFocus()
|
||||
if (!GetViewPoint(ViewLocation, ViewRotation))
|
||||
{
|
||||
SetFocusedActor(nullptr);
|
||||
RefreshPrompt();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,6 +85,10 @@ void UInteractionComponent::UpdateFocus()
|
||||
|
||||
SetFocusedActor(Candidate);
|
||||
|
||||
// Apres SetFocusedActor, jamais avant : l'ordre garantit que l'UI recoit
|
||||
// d'abord "la cible a change", puis le texte correspondant.
|
||||
RefreshPrompt();
|
||||
|
||||
#if ENABLE_DRAW_DEBUG
|
||||
if (bDrawDebug)
|
||||
{
|
||||
@@ -161,13 +166,26 @@ void UInteractionComponent::TryInteract()
|
||||
UpdateFocus();
|
||||
}
|
||||
|
||||
FText UInteractionComponent::GetFocusedPrompt() const
|
||||
void UInteractionComponent::RefreshPrompt()
|
||||
{
|
||||
AActor* Target = FocusedActor.Get();
|
||||
if (!IsValid(Target))
|
||||
|
||||
// Un seul FText::Format par trace, soit 20 fois par seconde et seulement
|
||||
// quand on vise quelque chose. Recalculer ici plutot que dans le getter
|
||||
// evite qu'un widget qui interroge le prompt plusieurs fois par frame
|
||||
// paie le format autant de fois.
|
||||
const FText NewPrompt = IsValid(Target)
|
||||
? IInteractable::Execute_GetInteractionPrompt(Target, GetOwner())
|
||||
: FText::GetEmpty();
|
||||
|
||||
// EqualTo et non IdenticalTo : on compare ce qui s'affiche, pas l'instance.
|
||||
// Deux FText::Format successifs produisent toujours deux instances
|
||||
// differentes, IdenticalTo redeclencherait donc l'UI a chaque trace.
|
||||
if (CachedPrompt.EqualTo(NewPrompt))
|
||||
{
|
||||
return FText::GetEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
return IInteractable::Execute_GetInteractionPrompt(Target);
|
||||
CachedPrompt = NewPrompt;
|
||||
OnPromptChanged.Broadcast(CachedPrompt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user