Space Plunder
Loading...
Searching...
No Matches
UALSDebugComponent Class Reference

#include <ALSDebugComponent.h>

Inheritance diagram for UALSDebugComponent:
UCustomDebugComponent

Public Member Functions

 UALSDebugComponent ()
 
virtual void BeginPlay () override
 
void OnPlayerControllerInitialized (APlayerController *Controller)
 
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
 
virtual void OnComponentDestroyed (bool bDestroyingHierarchy) override
 
void UpdateColoringSystem ()
 
void DrawDebugSpheres ()
 
void SetResetColors ()
 
void SetDynamicMaterials ()
 
void ToggleGlobalTimeDilationLocal (float TimeDilation)
 
void ToggleSlomo ()
 
void ToggleHud ()
 
void ToggleDebugView ()
 
void OpenOverlayMenu (bool bValue)
 
void OverlayMenuCycle (bool bValue)
 
void ToggleDebugMesh ()
 
void ToggleTraces ()
 
void ToggleDebugShapes ()
 
void ToggleLayerColors ()
 
void ToggleCharacterInfo ()
 
bool GetDebugView ()
 
bool GetShowTraces ()
 
bool GetShowDebugShapes ()
 
bool GetShowLayerColors ()
 
void FocusedDebugCharacterCycle (bool bValue)
 

Static Public Member Functions

static void DrawDebugLineTraceSingle (const UWorld *World, const FVector &Start, const FVector &End, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
 
static void DrawDebugCapsuleTraceSingle (const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
 
static void DrawDebugSphereTraceSingle (const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
 

Public Attributes

TObjectPtr< AALSBaseCharacterOwnerCharacter
 
bool bSlomo = false
 
bool bShowHud = false
 
bool bShowCharacterInfo = false
 
TObjectPtr< USkeletalMesh > DebugSkeletalMesh = nullptr
 
TArray< TObjectPtr< AALSBaseCharacter > > AvailableDebugCharacters
 
TObjectPtr< AALSBaseCharacterDebugFocusCharacter = nullptr
 

Protected Member Functions

void DetectDebuggableCharactersInWorld ()
 

Private Attributes

bool bNeedsColorReset = false
 
bool bDebugMeshVisible = false
 
TObjectPtr< USkeletalMesh > DefaultSkeletalMesh = nullptr
 
int32 FocusedDebugCharacterIndex = INDEX_NONE
 

Static Private Attributes

static bool bDebugView = false
 
static bool bShowTraces = false
 
static bool bShowDebugShapes = false
 
static bool bShowLayerColors = false
 

Constructor & Destructor Documentation

◆ UALSDebugComponent()

UALSDebugComponent::UALSDebugComponent ( )
23{
24#if UE_BUILD_SHIPPING
25 PrimaryComponentTick.bCanEverTick = false;
26#else
27 PrimaryComponentTick.bCanEverTick = true;
28#endif
29}

Member Function Documentation

◆ BeginPlay()

void UALSDebugComponent::BeginPlay ( )
overridevirtual
129{
130 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::BeginPlay);
131 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
132
133 Super::BeginPlay();
134
135 OwnerCharacter = Cast<AALSBaseCharacter>(GetOwner());
137 if (OwnerCharacter)
138 {
141 }
142}
virtual void BeginPlay() override
Definition ALSDebugComponent.cpp:128
void SetDynamicMaterials()
TObjectPtr< AALSBaseCharacter > DebugFocusCharacter
Definition ALSDebugComponent.h:156
TObjectPtr< AALSBaseCharacter > OwnerCharacter
Definition ALSDebugComponent.h:138

◆ DetectDebuggableCharactersInWorld()

void UALSDebugComponent::DetectDebuggableCharactersInWorld ( )
protected
145{
146 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::DetectDebuggableCharactersInWorld);
147 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
148
149 // Get all ALSBaseCharacter's, which are currently present to show them later in the ALS HUD for debugging purposes.
150 TArray<AActor*> AlsBaseCharacters;
151 UGameplayStatics::GetAllActorsOfClass(GetWorld(), AALSBaseCharacter::StaticClass(), AlsBaseCharacters);
152
154 if (AlsBaseCharacters.Num() > 0)
155 {
156 AvailableDebugCharacters.Reserve(AlsBaseCharacters.Num());
157 for (AActor* Character : AlsBaseCharacters)
158 {
159 if (AALSBaseCharacter* AlsBaseCharacter = Cast<AALSBaseCharacter>(Character))
160 {
161 AvailableDebugCharacters.Add(AlsBaseCharacter);
162 }
163 }
164
166 if (FocusedDebugCharacterIndex == INDEX_NONE && AvailableDebugCharacters.Num() > 0)
167 { // seems to be that this component was not attached to and AALSBaseCharacter,
168 // therefore the index will be set to the first element in the array.
170 }
171 }
172}
Definition ALSBaseCharacter.h:38
int32 FocusedDebugCharacterIndex
Definition ALSDebugComponent.h:175
void DetectDebuggableCharactersInWorld()
Definition ALSDebugComponent.cpp:144
TArray< TObjectPtr< AALSBaseCharacter > > AvailableDebugCharacters
Definition ALSDebugComponent.h:153

◆ DrawDebugCapsuleTraceSingle()

void UALSDebugComponent::DrawDebugCapsuleTraceSingle ( const UWorld * World,
const FVector & Start,
const FVector & End,
const FCollisionShape & CollisionShape,
EDrawDebugTrace::Type DrawDebugType,
bool bHit,
const FHitResult & OutHit,
FLinearColor TraceColor,
FLinearColor TraceHitColor,
float DrawTime )
static
285{
286 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::DrawDebugCapsuleTraceSingle);
287 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
288
289 if (DrawDebugType != EDrawDebugTrace::None)
290 {
291 bool bPersistent = DrawDebugType == EDrawDebugTrace::Persistent;
292 float LifeTime = (DrawDebugType == EDrawDebugTrace::ForDuration) ? DrawTime : 0.f;
293
294 if (bHit && OutHit.bBlockingHit)
295 {
296 // Red up to the blocking hit, green thereafter
297 DrawDebugCapsule(World, Start, CollisionShape.GetCapsuleHalfHeight(), CollisionShape.GetCapsuleRadius(), FQuat::Identity, TraceColor.ToFColor(true), bPersistent, LifeTime);
298 DrawDebugCapsule(World, OutHit.Location, CollisionShape.GetCapsuleHalfHeight(), CollisionShape.GetCapsuleRadius(), FQuat::Identity, TraceColor.ToFColor(true), bPersistent, LifeTime);
299 DrawDebugLine(World, Start, OutHit.Location, TraceColor.ToFColor(true), bPersistent, LifeTime);
300 DrawDebugPoint(World, OutHit.ImpactPoint, 16.0f, TraceColor.ToFColor(true), bPersistent, LifeTime);
301
302 DrawDebugCapsule(World, End, CollisionShape.GetCapsuleHalfHeight(), CollisionShape.GetCapsuleRadius(), FQuat::Identity, TraceHitColor.ToFColor(true), bPersistent, LifeTime);
303 DrawDebugLine(World, OutHit.Location, End, TraceHitColor.ToFColor(true), bPersistent, LifeTime);
304 }
305 else
306 {
307 // no hit means all red
308 DrawDebugCapsule(World, Start, CollisionShape.GetCapsuleHalfHeight(), CollisionShape.GetCapsuleRadius(), FQuat::Identity, TraceColor.ToFColor(true), bPersistent, LifeTime);
309 DrawDebugCapsule(World, End, CollisionShape.GetCapsuleHalfHeight(), CollisionShape.GetCapsuleRadius(), FQuat::Identity, TraceColor.ToFColor(true), bPersistent, LifeTime);
310 DrawDebugLine(World, Start, End, TraceColor.ToFColor(true), bPersistent, LifeTime);
311 }
312 }
313}
static void DrawDebugCapsuleTraceSingle(const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
Definition ALSDebugComponent.cpp:275

◆ DrawDebugLineTraceSingle()

void UALSDebugComponent::DrawDebugLineTraceSingle ( const UWorld * World,
const FVector & Start,
const FVector & End,
EDrawDebugTrace::Type DrawDebugType,
bool bHit,
const FHitResult & OutHit,
FLinearColor TraceColor,
FLinearColor TraceHitColor,
float DrawTime )
static

Util for drawing result of single line trace

251{
252 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::DrawDebugLineTraceSingle);
253 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
254
255 if (DrawDebugType != EDrawDebugTrace::None)
256 {
257 bool bPersistent = DrawDebugType == EDrawDebugTrace::Persistent;
258 float LifeTime = (DrawDebugType == EDrawDebugTrace::ForDuration) ? DrawTime : 0.f;
259
260 if (bHit && OutHit.bBlockingHit)
261 {
262 // Red up to the blocking hit, green thereafter
263 DrawDebugLine(World, Start, OutHit.ImpactPoint, TraceColor.ToFColor(true), bPersistent, LifeTime);
264 DrawDebugLine(World, OutHit.ImpactPoint, End, TraceHitColor.ToFColor(true), bPersistent, LifeTime);
265 DrawDebugPoint(World, OutHit.ImpactPoint, 16.0f, TraceColor.ToFColor(true), bPersistent, LifeTime);
266 }
267 else
268 {
269 // no hit means all red
270 DrawDebugLine(World, Start, End, TraceColor.ToFColor(true), bPersistent, LifeTime);
271 }
272 }
273}
static void DrawDebugLineTraceSingle(const UWorld *World, const FVector &Start, const FVector &End, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
Definition ALSDebugComponent.cpp:241

◆ DrawDebugSpheres()

void UALSDebugComponent::DrawDebugSpheres ( )

Implement on BP to draw debug spheres

◆ DrawDebugSphereTraceSingle()

void UALSDebugComponent::DrawDebugSphereTraceSingle ( const UWorld * World,
const FVector & Start,
const FVector & End,
const FCollisionShape & CollisionShape,
EDrawDebugTrace::Type DrawDebugType,
bool bHit,
const FHitResult & OutHit,
FLinearColor TraceColor,
FLinearColor TraceHitColor,
float DrawTime )
static
347{
348 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::DrawDebugSphereTraceSingle);
349 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
350
351 if (DrawDebugType != EDrawDebugTrace::None)
352 {
353 bool bPersistent = DrawDebugType == EDrawDebugTrace::Persistent;
354 float LifeTime = (DrawDebugType == EDrawDebugTrace::ForDuration) ? DrawTime : 0.f;
355
356 if (bHit && OutHit.bBlockingHit)
357 {
358 // Red up to the blocking hit, green thereafter
359 DrawDebugSweptSphere(World, Start, OutHit.Location, CollisionShape.GetSphereRadius(), TraceColor.ToFColor(true), bPersistent, LifeTime);
360 DrawDebugSweptSphere(World, OutHit.Location, End, CollisionShape.GetSphereRadius(), TraceHitColor.ToFColor(true), bPersistent, LifeTime);
361 DrawDebugPoint(World, OutHit.ImpactPoint, 16.0f, TraceColor.ToFColor(true), bPersistent, LifeTime);
362 }
363 else
364 {
365 // no hit means all red
366 DrawDebugSweptSphere(World, Start, End, CollisionShape.GetSphereRadius(), TraceColor.ToFColor(true), bPersistent, LifeTime);
367 }
368 }
369}
static void DrawDebugSweptSphere(const UWorld *InWorld, FVector const &Start, FVector const &End, float Radius, FColor const &Color, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority=0)
Definition ALSDebugComponent.cpp:315
static void DrawDebugSphereTraceSingle(const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
Definition ALSDebugComponent.cpp:337

◆ FocusedDebugCharacterCycle()

void UALSDebugComponent::FocusedDebugCharacterCycle ( bool bValue)
93{
94 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::FocusedDebugCharacterCycle);
95 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
96
97 // Refresh list, so we can also debug runtime spawned characters & remove despawned characters back
99
100 if (FocusedDebugCharacterIndex == INDEX_NONE)
101 {
102 // Return here as no AALSBaseCharacter where found during call of BeginPlay.
103 // Moreover, for safety set also no focused debug character.
104 DebugFocusCharacter = nullptr;
105 return;
106 }
107
108 if (bValue)
109 {
112 {
114 }
115 }
116 else
117 {
120 {
122 }
123 }
124
126}
void FocusedDebugCharacterCycle(bool bValue)
Definition ALSDebugComponent.cpp:92

◆ GetDebugView()

bool UALSDebugComponent::GetDebugView ( )
inline
83{ return bDebugView; }
static bool bDebugView
Definition ALSDebugComponent.h:158

◆ GetShowDebugShapes()

bool UALSDebugComponent::GetShowDebugShapes ( )
inline
89{ return bShowDebugShapes; }
static bool bShowDebugShapes
Definition ALSDebugComponent.h:162

◆ GetShowLayerColors()

bool UALSDebugComponent::GetShowLayerColors ( )
inline
92{ return bShowLayerColors; }
static bool bShowLayerColors
Definition ALSDebugComponent.h:164

◆ GetShowTraces()

bool UALSDebugComponent::GetShowTraces ( )
inline
86{ return bShowTraces; }
static bool bShowTraces
Definition ALSDebugComponent.h:160

◆ OnComponentDestroyed()

void UALSDebugComponent::OnComponentDestroyed ( bool bDestroyingHierarchy)
overridevirtual
79{
80 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::OnComponentDestroyed);
81 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
82
83 Super::OnComponentDestroyed(bDestroyingHierarchy);
84
85 // Keep static values false on destroy
86 bDebugView = false;
87 bShowTraces = false;
88 bShowDebugShapes = false;
89 bShowLayerColors = false;
90}
virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override
Definition ALSDebugComponent.cpp:78

◆ OnPlayerControllerInitialized()

void UALSDebugComponent::OnPlayerControllerInitialized ( APlayerController * Controller)

◆ OpenOverlayMenu()

void UALSDebugComponent::OpenOverlayMenu ( bool bValue)

◆ OverlayMenuCycle()

void UALSDebugComponent::OverlayMenuCycle ( bool bValue)

◆ SetDynamicMaterials()

void UALSDebugComponent::SetDynamicMaterials ( )

Implemented on BP to set dynamic color materials for debugging

◆ SetResetColors()

void UALSDebugComponent::SetResetColors ( )

Implemented on BP to set/reset layering colors

◆ TickComponent()

void UALSDebugComponent::TickComponent ( float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction * ThisTickFunction )
overridevirtual
33{
34 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::TickComponent);
35 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
36 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component_Tick);
37
38 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
39
40#if !UE_BUILD_SHIPPING
41 if (!OwnerCharacter)
42 {
43 return;
44 }
45
47 {
48 bNeedsColorReset = false;
50 }
51
53 {
55 }
56 else
57 {
58 bNeedsColorReset = true;
59 }
60
62 {
64
65 APlayerController* Controller = Cast<APlayerController>(OwnerCharacter->GetController());
66 if (Controller)
67 {
68 AALSPlayerCameraManager* CamManager = Cast<AALSPlayerCameraManager>(Controller->PlayerCameraManager);
69 if (CamManager)
70 {
71 CamManager->DrawDebugTargets(OwnerCharacter->GetThirdPersonPivotTarget().GetLocation());
72 }
73 }
74 }
75#endif
76}
Definition ALSPlayerCameraManager.h:19
void DrawDebugTargets(FVector PivotTargetLocation)
bool bNeedsColorReset
Definition ALSDebugComponent.h:166
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
Definition ALSDebugComponent.cpp:31
void UpdateColoringSystem()

◆ ToggleCharacterInfo()

void UALSDebugComponent::ToggleCharacterInfo ( )
inline
bool bShowCharacterInfo
Definition ALSDebugComponent.h:147

◆ ToggleDebugMesh()

void UALSDebugComponent::ToggleDebugMesh ( )
223{
224 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::ToggleDebugMesh);
225 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
226
228 {
229 OwnerCharacter->SetVisibleMesh(DefaultSkeletalMesh);
230 }
231 else
232 {
233 DefaultSkeletalMesh = OwnerCharacter->GetMesh()->GetSkeletalMeshAsset();
234 OwnerCharacter->SetVisibleMesh(DebugSkeletalMesh);
235 }
237}
TObjectPtr< USkeletalMesh > DebugSkeletalMesh
Definition ALSDebugComponent.h:150
TObjectPtr< USkeletalMesh > DefaultSkeletalMesh
Definition ALSDebugComponent.h:171
bool bDebugMeshVisible
Definition ALSDebugComponent.h:168
void ToggleDebugMesh()
Definition ALSDebugComponent.cpp:222

◆ ToggleDebugShapes()

void UALSDebugComponent::ToggleDebugShapes ( )
inline

◆ ToggleDebugView()

void UALSDebugComponent::ToggleDebugView ( )
195{
196 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::ToggleDebugView);
197 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
198
200
201 AALSPlayerCameraManager* CamManager = Cast<AALSPlayerCameraManager>(
202 UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0));
203 if (CamManager)
204 {
205 UALSPlayerCameraBehavior* CameraBehavior = Cast<UALSPlayerCameraBehavior>(
206 CamManager->CameraBehavior->GetAnimInstance());
207 if (CameraBehavior)
208 {
209 CameraBehavior->bDebugView = bDebugView;
210 }
211 }
212}
TObjectPtr< USkeletalMeshComponent > CameraBehavior
Definition ALSPlayerCameraManager.h:50
void ToggleDebugView()
Definition ALSDebugComponent.cpp:194
Definition ALSPlayerCameraBehavior.h:21
bool bDebugView
Definition ALSPlayerCameraBehavior.h:58

◆ ToggleGlobalTimeDilationLocal()

void UALSDebugComponent::ToggleGlobalTimeDilationLocal ( float TimeDilation)
175{
176 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::ToggleGlobalTimeDilationLocal);
177 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
178
179 if (UKismetSystemLibrary::IsStandalone(this))
180 {
181 UGameplayStatics::SetGlobalTimeDilation(this, TimeDilation);
182 }
183}
void ToggleGlobalTimeDilationLocal(float TimeDilation)
Definition ALSDebugComponent.cpp:174

◆ ToggleHud()

void UALSDebugComponent::ToggleHud ( )
inline
56{ bShowHud = !bShowHud; }
bool bShowHud
Definition ALSDebugComponent.h:144

◆ ToggleLayerColors()

void UALSDebugComponent::ToggleLayerColors ( )
inline

◆ ToggleSlomo()

void UALSDebugComponent::ToggleSlomo ( )
186{
187 TRACE_CPUPROFILER_EVENT_SCOPE(UALSDebugComponent::ToggleSlomo);
188 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Debug_Component);
189
190 bSlomo = !bSlomo;
192}
bool bSlomo
Definition ALSDebugComponent.h:141
void ToggleSlomo()
Definition ALSDebugComponent.cpp:185

◆ ToggleTraces()

void UALSDebugComponent::ToggleTraces ( )
inline

◆ UpdateColoringSystem()

void UALSDebugComponent::UpdateColoringSystem ( )

Implemented on BP to update layering colors

Member Data Documentation

◆ AvailableDebugCharacters

TArray<TObjectPtr<AALSBaseCharacter> > UALSDebugComponent::AvailableDebugCharacters

◆ bDebugMeshVisible

bool UALSDebugComponent::bDebugMeshVisible = false
private

◆ bDebugView

bool UALSDebugComponent::bDebugView = false
staticprivate

◆ bNeedsColorReset

bool UALSDebugComponent::bNeedsColorReset = false
private

◆ bShowCharacterInfo

bool UALSDebugComponent::bShowCharacterInfo = false

◆ bShowDebugShapes

bool UALSDebugComponent::bShowDebugShapes = false
staticprivate

◆ bShowHud

bool UALSDebugComponent::bShowHud = false

◆ bShowLayerColors

bool UALSDebugComponent::bShowLayerColors = false
staticprivate

◆ bShowTraces

bool UALSDebugComponent::bShowTraces = false
staticprivate

◆ bSlomo

bool UALSDebugComponent::bSlomo = false

◆ DebugFocusCharacter

TObjectPtr<AALSBaseCharacter> UALSDebugComponent::DebugFocusCharacter = nullptr

◆ DebugSkeletalMesh

TObjectPtr<USkeletalMesh> UALSDebugComponent::DebugSkeletalMesh = nullptr

◆ DefaultSkeletalMesh

TObjectPtr<USkeletalMesh> UALSDebugComponent::DefaultSkeletalMesh = nullptr
private

◆ FocusedDebugCharacterIndex

int32 UALSDebugComponent::FocusedDebugCharacterIndex = INDEX_NONE
private

Stores the index, which is used to select the next focused debug ALSBaseCharacter. If no characters where found during BeginPlay the value should be set to INDEX_NONE.

◆ OwnerCharacter

TObjectPtr<AALSBaseCharacter> UALSDebugComponent::OwnerCharacter

The documentation for this class was generated from the following files: