Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/Annotations/SmartObjectSlotLinkAnnotation.cpp
mikko mononen a24c665ba3 SmartObjects: Added entry annotation selection and validation.
- Added USmartObjectSubsystem::FindEntryLocationForSlot() which allows to query entry points which are on navigable surface
- Improved debug visualizations
- Added visualization shape and size for slots
- Added gameplay interaction state tree task to query entry location

#jira UE-174418
#preflight 63ff4702437ce3e7f3f60cf4

[CL 24462168 by mikko mononen in ue5-main branch]
2023-03-01 10:06:12 -05:00

54 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Annotations/SmartObjectSlotLinkAnnotation.h"
#include "SmartObjectDefinition.h"
#include "SmartObjectVisualizationContext.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectSlotLinkAnnotation)
#if WITH_EDITOR
void FSmartObjectSlotLinkAnnotation::DrawVisualization(FSmartObjectVisualizationContext& VisContext) const
{
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
{
return;
}
const FSmartObjectSlotIndex SlotIndex(VisContext.SlotIndex);
const FSmartObjectSlotIndex LinkedSlotIndex(LinkedSlot.GetIndex());
const TOptional<FTransform> Transform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, SlotIndex);
const TOptional<FTransform> TargetTransform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, LinkedSlotIndex);
if (Transform.IsSet() && TargetTransform.IsSet())
{
FLinearColor Color = FLinearColor::White;
if (VisContext.bIsSlotSelected)
{
Color = VisContext.SelectedColor;
}
VisContext.DrawArrow(Transform.GetValue().GetLocation(), TargetTransform.GetValue().GetLocation(), Color, 15.0f, 15.0f, /*DepthPrioGroup*/0, /*Thickness*/1.0f, /*DepthBias*/2.0);
}
}
void FSmartObjectSlotLinkAnnotation::DrawVisualizationHUD(FSmartObjectVisualizationContext& VisContext) const
{
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
{
return;
}
const FSmartObjectSlotIndex SlotIndex(VisContext.SlotIndex);
const FSmartObjectSlotIndex LinkedSlotIndex(LinkedSlot.GetIndex());
const TOptional<FTransform> Transform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, SlotIndex);
const TOptional<FTransform> TargetTransform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, LinkedSlotIndex);
if (VisContext.bIsSlotSelected
&& Transform.IsSet() && TargetTransform.IsSet())
{
const FVector LabelPos = FMath::Lerp(Transform.GetValue().GetLocation(), TargetTransform.GetValue().GetLocation(), 0.3f);
VisContext.DrawString(LabelPos, *Tag.ToString(), FLinearColor::White);
}
}
#endif // WITH_EDITOR