100 lines
3.0 KiB
C++
100 lines
3.0 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#include "EBMagazineComponentFactory.h"
|
|
#include "EBMagazine.h"
|
|
#include "Engine/Selection.h"
|
|
#include "Components/SceneComponent.h"
|
|
#include "DrawDebugHelpers.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "EBMagazineComponentFactory"
|
|
|
|
void FEBMagazineComponentVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI)
|
|
{
|
|
const UEBMagazine* MagazineComponent = Cast<const UEBMagazine>(Component);
|
|
if (!MagazineComponent)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Get the component's owner actor
|
|
const AActor* Owner = MagazineComponent->GetOwner();
|
|
if (!Owner)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Draw a simple visualization for the magazine
|
|
FVector Location = Owner->GetActorLocation();
|
|
FVector Offset = FVector(0, 0, -20); // Offset below the actor
|
|
FVector MagazineLocation = Location + Offset;
|
|
|
|
// Draw magazine representation
|
|
FColor MagazineColor = FColor::Yellow;
|
|
if (MagazineComponent->bIsEmpty)
|
|
{
|
|
MagazineColor = FColor::Red;
|
|
}
|
|
else if (MagazineComponent->bIsFull)
|
|
{
|
|
MagazineColor = FColor::Green;
|
|
}
|
|
|
|
// Draw a box to represent the magazine
|
|
FVector BoxExtent = FVector(2, 8, 15);
|
|
DrawWireBox(PDI, FBox(MagazineLocation - BoxExtent, MagazineLocation + BoxExtent), MagazineColor, SDPG_Foreground);
|
|
|
|
// Draw capacity indicator
|
|
float FillRatio = MagazineComponent->GetFillPercentage();
|
|
FVector FillLocation = MagazineLocation + FVector(0, 0, -BoxExtent.Z + (BoxExtent.Z * 2 * FillRatio));
|
|
FVector FillExtent = FVector(1, 6, BoxExtent.Z * FillRatio);
|
|
DrawWireBox(PDI, FBox(FillLocation - FillExtent, FillLocation + FillExtent), FColor::Orange, SDPG_Foreground);
|
|
|
|
// Draw text showing round count
|
|
FString RoundCountText = FString::Printf(TEXT("%d/%d"),
|
|
MagazineComponent->GetCurrentRoundCount(),
|
|
MagazineComponent->GetMaxCapacity());
|
|
|
|
// Note: Text drawing in visualizers requires more complex setup
|
|
// For now, we'll just draw the geometric representation
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::GetCustomInputCoordinateSystem(const FEditorViewportClient* ViewportClient, FMatrix& OutMatrix) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::HandleInputKey(FEditorViewportClient* ViewportClient, FViewport* Viewport, FKey Key, EInputEvent Event)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
TSharedPtr<SWidget> FEBMagazineComponentVisualizer::GenerateContextMenu() const
|
|
{
|
|
return TSharedPtr<SWidget>();
|
|
}
|
|
|
|
bool FEBMagazineComponentVisualizer::IsVisualizationShown(const UActorComponent* Component) const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void FEBMagazineComponentVisualizer::EndEditing()
|
|
{
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |