[code] refactor Debug module

main
Nikolay Petrov 2025-10-03 02:09:44 +05:00
parent df3deef577
commit 11596690cd
48 changed files with 1372 additions and 1437 deletions

View File

@ -151,21 +151,23 @@ export class BP_MainCharacter extends Pawn {
}
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
if (this.ShowDebugInfo) {
this.DebugHUDComponent.InitializeDebugHUD(
this.MovementComponent,
this.ToastSystemComponent,
this.InputDeviceComponent,
this.CameraComponent
this.InputDeviceComponent
);
}
this.MovementComponent.InitializeMovementSystem();
this.MovementComponent.InitializeMovementSystem(this.DebugHUDComponent);
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
}
/**
@ -176,10 +178,7 @@ export class BP_MainCharacter extends Pawn {
this.DeltaTime = DeltaTime;
if (this.ShowDebugInfo) {
this.DebugHUDComponent.UpdateHUD(
SystemLibrary.GetGameTimeInSeconds(),
DeltaTime
);
this.DebugHUDComponent.UpdateHUD(SystemLibrary.GetGameTimeInSeconds());
this.ToastSystemComponent.UpdateToastSystem();
}
@ -197,7 +196,14 @@ export class BP_MainCharacter extends Pawn {
this.CurrentMovementInput,
DeltaTime
);
this.ApplyMovementAndRotation();
if (this.ShowDebugInfo) {
this.MovementComponent.UpdateDebugPage();
this.InputDeviceComponent.UpdateDebugPage();
this.CameraComponent.UpdateDebugPage();
}
}
// ════════════════════════════════════════════════════════════════════════════════════════

BIN
Content/Blueprints/BP_MainCharacter.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -2,6 +2,7 @@
import type { S_CameraSettings } from '#root/Camera/Structs/S_CameraSettings.ts';
import type { S_CameraState } from '#root/Camera/Structs/S_CameraState.ts';
import type { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import type { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { ActorComponent } from '#root/UE/ActorComponent.ts';
import type { Float } from '#root/UE/Float.ts';
@ -131,20 +132,48 @@ export class AC_Camera extends ActorComponent {
* Initialize camera system with default settings
* @category System Setup
*/
public InitializeCameraSystem(InputDeviceRef: AC_InputDevice): void {
public InitializeCameraSystem(
InputDeviceRef: AC_InputDevice,
DebugComponentRef: AC_DebugHUD
): void {
this.InputDeviceComponent = InputDeviceRef;
this.DebugHUDComponent = DebugComponentRef;
this.IsInitialized = true;
// Reset camera state
this.CameraState = {
CurrentPitch: 0.0,
CurrentYaw: 0.0,
TargetPitch: 0.0,
TargetYaw: 0.0,
LastInputDelta: new Vector(0, 0, 0),
InputMagnitude: 0.0,
};
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
this.DebugHUDComponent.AddDebugPage(
this.DebugPageID,
'Camera System',
60
);
}
}
/**
* Update debug HUD with current camera info
* @category Debug
*/
public UpdateDebugPage(): void {
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
if (
this.DebugHUDComponent.ShouldUpdatePage(
this.DebugPageID,
SystemLibrary.GetGameTimeInSeconds()
)
) {
this.DebugHUDComponent.UpdatePageContent(
this.DebugPageID,
`Current Device: ${SystemLibrary.IsValid(this.InputDeviceComponent) ? this.InputDeviceComponent.GetCurrentInputDevice() : 'Input Device Component Not Found'}\n` +
`Sensitivity: ${SystemLibrary.IsValid(this.InputDeviceComponent) && this.InputDeviceComponent.IsGamepad() ? this.CameraSettings.GamepadSensitivity : this.CameraSettings.MouseSensitivity}\n` +
`Pitch: ${this.GetCameraRotation().Pitch}°\n` +
`Yaw: ${this.GetCameraRotation().Yaw}°\n` +
`Is Rotating: ${this.IsCameraRotating() ? 'Yes' : 'No'}\n` +
`Smoothing: ${this.CameraSettings.SmoothingSpeed}\n` +
`Invert Y: ${this.CameraSettings.InvertYAxis ? 'Yes' : 'No'}`
);
}
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
@ -192,4 +221,18 @@ export class AC_Camera extends ActorComponent {
* @category Components
*/
public InputDeviceComponent: AC_InputDevice | null = null;
/**
* Reference to debug HUD component for displaying camera info
* Optional, used for debugging purposes
* @category Components
*/
public DebugHUDComponent: AC_DebugHUD | null = null;
/**
* Debug page identifier for organizing debug output
* Used by debug HUD to categorize information
* @category Debug
*/
public readonly DebugPageID: string = 'CameraInfo';
}

BIN
Content/Camera/Components/AC_Camera.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,6 +1,7 @@
// Camera/Tests/FT_CameraInitialization.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -28,11 +29,15 @@ export class FT_CameraInitialization extends FunctionalTest {
// Initialize dependencies
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
// Initialize camera system
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
// Validate initialization
if (
@ -87,4 +92,10 @@ export class FT_CameraInitialization extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,6 +1,7 @@
// Camera/Tests/FT_CameraLimits.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -30,9 +31,13 @@ export class FT_CameraLimits extends FunctionalTest {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
// Test 1: Test upper pitch limit clamping
const { PitchMin: pitchMin, PitchMax: pitchMax } =
@ -126,4 +131,10 @@ export class FT_CameraLimits extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,6 +1,7 @@
// Camera/Tests/FT_CameraRotation.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -30,9 +31,13 @@ export class FT_CameraRotation extends FunctionalTest {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
// Test positive X input (should increase Yaw)
this.CameraComponent.ProcessLookInput(new Vector(1.0, 0.0, 0.0), 0.016);
@ -120,4 +125,10 @@ export class FT_CameraRotation extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,6 +1,7 @@
// Camera/Tests/FT_CameraSensitivity.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -29,9 +30,13 @@ export class FT_CameraSensitivity extends FunctionalTest {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
// Test 1: Verify sensitivity settings are loaded correctly
const { MouseSensitivity: mouseSens, GamepadSensitivity: gamepadSens } =
@ -100,4 +105,10 @@ export class FT_CameraSensitivity extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,6 +1,7 @@
// Camera/Tests/FT_CameraSmoothing.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -29,9 +30,13 @@ export class FT_CameraSmoothing extends FunctionalTest {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(this.InputDeviceComponent);
// Test 1: Test smooth rotation behavior
this.CameraComponent.ProcessLookInput(new Vector(5.0, 0.0, 0.0), 0.016);
@ -108,4 +113,10 @@ export class FT_CameraSmoothing extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,22 +1,14 @@
// Debug/Components/AC_DebugHUD.ts
import type { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { E_DebugUpdateFunction } from '#root/Debug/Enums/E_DebugUpdateFunction.ts';
import type { S_DebugPage } from '#root/Debug/Structs/S_DebugPage.ts';
import type { S_DebugSettings } from '#root/Debug/Structs/S_DebugSettings.ts';
import { DT_DebugPages } from '#root/Debug/Tables/DT_DebugPages.ts';
import { WBP_DebugHUD } from '#root/Debug/UI/WBP_DebugHUD.ts';
import type { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import type { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import type { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { ActorComponent } from '#root/UE/ActorComponent.ts';
import { CreateWidget } from '#root/UE/CteateWidget.ts';
import type { DataTable } from '#root/UE/DataTable.ts';
import { DataTableFunctionLibrary } from '#root/UE/DataTableFunctionLibrary.ts';
import { ESlateVisibility } from '#root/UE/ESlateVisibility.ts';
import type { Float } from '#root/UE/Float.ts';
import type { Integer } from '#root/UE/Integer.ts';
import { StringLibrary } from '#root/UE/StringLibrary.ts';
import { SystemLibrary } from '#root/UE/SystemLibrary.ts';
import type { Text } from '#root/UE/Text.ts';
import { UEArray } from '#root/UE/UEArray.ts';
@ -33,81 +25,143 @@ export class AC_DebugHUD extends ActorComponent {
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Check if debug HUD should be visible
* @returns True if system is initialized and mode is visible
* @category HUD Control
* @pure true
*/
private ShouldShowDebugHUD(): boolean {
const IsSystemReadyAndVisible = (modeIsVisible: boolean): boolean =>
this.IsInitialized && modeIsVisible;
return IsSystemReadyAndVisible(
this.DebugSettings.CurrentMode === ESlateVisibility.Visible
);
}
/**
* Check if debug HUD should update this frame
* Add or register a debug page in the system
* @param PageID - Unique identifier for the page
* @param Title - Display title for the page
* @param RefreshRate - How often this page should be updated (Hz), default 30
* @param IsVisible - Whether the page is visible by default, default true
* @example
* // Update every frame (UpdateFrequency = 0)
* ShouldUpdateDebugHUD(gameTime) // returns true
* // Update at 30Hz (UpdateFrequency = 30)
* ShouldUpdateDebugHUD(gameTime) // returns true every 1/30 seconds
* @param CurrentTime - Current game time in seconds
* @returns True if enough time has passed since last update
* @pure true
* @category HUD Control
* // In your component's BeginPlay:
* this.DebugHUDRef.AddDebugPage('MovementInfo', 'Movement Data', 30);
* @category Page Management
*/
private ShouldUpdateDebugHUD(CurrentTime: Float = 0): boolean {
const IsFrequencyLimited = (updateFrequency: Float): boolean =>
updateFrequency > 0;
public AddDebugPage(
PageID: string,
Title: Text,
RefreshRate: number = 30,
IsVisible: boolean = true
): void {
const existingPageIndex = this.FindPageIndex(PageID);
const IsUpdateIntervalReached = (
currentTime: Float,
updateFrequency: Float
): boolean => currentTime - this.LastUpdateTime >= 1 / updateFrequency;
const pageData: S_DebugPage = {
PageID,
Title,
Content: '',
RefreshRate,
IsVisible,
LastUpdateTime: 0,
};
if (IsFrequencyLimited(this.DebugSettings.UpdateFrequency)) {
return IsUpdateIntervalReached(
CurrentTime,
this.DebugSettings.UpdateFrequency
);
if (existingPageIndex >= 0) {
this.DebugPages.SetArrayElem(existingPageIndex, {
...pageData,
Content: this.DebugPages.Get(existingPageIndex).Content,
});
} else {
return true; // Update every frame
this.DebugPages.Add(pageData);
}
}
/**
* Register or update a debug page in the system
* Update content of a specific debug page
* Call this from your component's Tick or custom update function
* @param PageId - Unique identifier of the page to update
* @param Content - New content text for the page
* @example
* // Register movement constants page
* RegisterDebugPage({
* PageID: E_DebugPageID.MovementInfo,
* Title: "Movement Constants",
* Content: "",
* IsVisible: true,
* UpdateFunction: E_DebugUpdateFunction.UpdateMovementPage
* })
* @param PageData - Page configuration and content data
* // In your component's Tick:
* this.DebugHUDRef.UpdatePageContent(
* 'MovementInfo',
* `Speed: ${this.Speed}\nAcceleration: ${this.Acceleration}`
* );
* @category Page Management
*/
private RegisterDebugPage(PageData: S_DebugPage): void {
let existingIndex: Integer = -1;
public UpdatePageContent(PageId: string, Content: Text): void {
const pageIndex = this.FindPageIndex(PageId);
this.DebugPages.forEach((page, index) => {
if (page.PageID === PageData.PageID) {
existingIndex = index;
return;
if (pageIndex >= 0) {
this.DebugPages.SetArrayElem(pageIndex, {
...this.DebugPages.Get(pageIndex),
Content,
});
}
}
/**
* Check if page needs update based on its refresh rate
* Use this to control update frequency in your component
* @param PageID - Page identifier to check
* @param CurrentTime - Current game time
* @returns True if page should be updated
* @example
* // In your component's Tick:
* if (this.DebugHUDRef.ShouldUpdatePage('MovementInfo', currentTime)) {
* this.DebugHUDRef.UpdatePageContent('MovementInfo', this.GetDebugContent());
* }
* @category Page Management
* @pure true
*/
public ShouldUpdatePage(PageID: string, CurrentTime: Float): boolean {
const pageIndex = this.FindPageIndex(PageID);
if (pageIndex >= 0) {
let page = this.DebugPages.Get(pageIndex);
const IsTimeToUpdate = (
currentTime: Float,
refreshRate: Float,
updateTime: Float
): boolean => currentTime - updateTime >= 1 / refreshRate;
const { RefreshRate: refreshRate, LastUpdateTime: updateTime } = page;
if (IsTimeToUpdate(CurrentTime, refreshRate, updateTime)) {
page = {
...page,
LastUpdateTime: CurrentTime,
};
this.DebugPages.SetArrayElem(pageIndex, page);
return true;
} else {
return false;
}
});
const IsPageExists = (): boolean => existingIndex >= 0;
if (IsPageExists()) {
this.DebugPages.SetArrayElem(existingIndex, PageData);
} else {
this.DebugPages.Add(PageData);
return false;
}
}
/**
* Remove a debug page from the system
* @param pageId - Unique identifier of the page to remove
* @category Page Management
*/
public RemoveDebugPage(pageId: string): void {
const pageIndex = this.FindPageIndex(pageId);
if (pageIndex >= 0) {
this.DebugPages.RemoveIndex(pageIndex);
// Adjust current page index if needed
if (this.CurrentPageIndex >= this.GetVisiblePages().length) {
this.CurrentPageIndex = Math.max(0, this.GetVisiblePages().length - 1);
}
}
}
/**
* Set visibility of a specific debug page
* @param pageId - Page identifier
* @param isVisible - Visibility state
* @category Page Management
*/
public SetPageVisibility(pageId: string, isVisible: boolean): void {
const pageIndex = this.FindPageIndex(pageId);
if (pageIndex >= 0) {
this.DebugPages.SetArrayElem(pageIndex, {
...this.DebugPages.Get(pageIndex),
IsVisible: isVisible,
});
}
}
@ -117,41 +171,36 @@ export class AC_DebugHUD extends ActorComponent {
* @category Page Management
* @pure true
*/
public GetVisiblePages(): UEArray<S_DebugPage> {
const filteredPages: UEArray<S_DebugPage> = new UEArray([]);
private GetVisiblePages(): UEArray<S_DebugPage> {
const filteredArray: UEArray<S_DebugPage> = new UEArray([]);
this.DebugPages.forEach(page => {
if (page.IsVisible) {
filteredPages.Add(page);
filteredArray.Add(page);
}
});
return filteredPages;
return filteredArray;
}
/**
* Get currently selected debug page
* @returns Object with page data and validity flag
* @returns Current page data or null if invalid
* @category Page Management
* @pure true
*/
private GetCurrentPage():
| { Page: S_DebugPage | null; IsFound: true }
| { Page: null; IsFound: false } {
const IsPageIndexInvalid = (
length: Integer,
currentPageIndex: Integer
): boolean => length === 0 || currentPageIndex >= length;
private GetCurrentPage(): { Page: S_DebugPage | null; IsFound: boolean } {
const IsCurrentPageValid = (length: Integer): boolean =>
length === 0 || this.CurrentPageIndex >= length;
return IsPageIndexInvalid(
this.GetVisiblePages().length,
this.DebugSettings.CurrentPageIndex
)
? { Page: null, IsFound: false }
: {
Page: this.GetVisiblePages().Get(this.DebugSettings.CurrentPageIndex),
IsFound: true,
};
if (!IsCurrentPageValid(this.GetVisiblePages().length)) {
return {
Page: this.GetVisiblePages().Get(this.CurrentPageIndex),
IsFound: true,
};
}
return { Page: null, IsFound: false };
}
/**
@ -159,11 +208,14 @@ export class AC_DebugHUD extends ActorComponent {
* @category Navigation
*/
public ToggleDebugHUD(): void {
this.DebugSettings.CurrentMode =
this.DebugSettings.CurrentMode === ESlateVisibility.Visible
? ESlateVisibility.Hidden
: ESlateVisibility.Visible;
this.UpdateWidgetVisibility();
if (SystemLibrary.IsValid(this.DebugWidget)) {
this.CurrentMode =
this.CurrentMode === ESlateVisibility.Visible
? ESlateVisibility.Hidden
: ESlateVisibility.Visible;
this.DebugWidget.SetVisibility(this.CurrentMode);
}
}
/**
@ -175,17 +227,13 @@ export class AC_DebugHUD extends ActorComponent {
const length = this.GetVisiblePages().length;
if (length > 1) {
const currentPage = this.DebugSettings.CurrentPageIndex;
const isAtFirstPage = (): boolean => currentPage - 1 < 0;
const isAtFirstPage = (): boolean => this.CurrentPageIndex - 1 < 0;
const getLastPageIndex = (): Integer => length - 1;
const getPreviousPageIndex = (): Integer => currentPage - 1;
const getPreviousPageIndex = (): Integer => this.CurrentPageIndex - 1;
this.DebugSettings.CurrentPageIndex = isAtFirstPage()
this.CurrentPageIndex = isAtFirstPage()
? getLastPageIndex()
: getPreviousPageIndex();
this.UpdateCurrentPage();
}
}
@ -197,16 +245,11 @@ export class AC_DebugHUD extends ActorComponent {
public NextPage(): void {
const length = this.GetVisiblePages().length;
const HasMultiplePages = (): boolean => length > 1;
const GetNextPageIndex = (currentPageIndex: Integer): Integer =>
(currentPageIndex + 1) % length;
const GetNextPageIndex = (): Integer =>
(this.CurrentPageIndex + 1) % length;
if (HasMultiplePages()) {
this.DebugSettings.CurrentPageIndex = GetNextPageIndex(
this.DebugSettings.CurrentPageIndex
);
this.UpdateCurrentPage();
if (length > 1) {
this.CurrentPageIndex = GetNextPageIndex();
}
}
@ -215,218 +258,145 @@ export class AC_DebugHUD extends ActorComponent {
* @category Visual Debug
*/
public ToggleVisualDebug(): void {
this.DebugSettings.ShowVisualDebug = !this.DebugSettings.ShowVisualDebug;
this.ShowVisualDebug = !this.ShowVisualDebug;
if (SystemLibrary.IsValid(this.ToastComponent)) {
this.ToastComponent.ShowToast(
`Visual Debug ${this.DebugSettings.ShowVisualDebug ? 'Enabled' : 'Disabled'}`
`Visual Debug ${this.ShowVisualDebug ? 'Enabled' : 'Disabled'}`
);
}
}
/**
* Update content of currently selected page
* Calls appropriate update function based on page type
* @category Page Updates
* Get comprehensive test data for debug system validation
* @returns Object containing initialization status, DataTable reference, and pages array
* @category Testing
*/
private UpdateCurrentPage(): void {
let CurrentPage = this.GetCurrentPage().Page;
public GetTestData(): {
IsInitialized: boolean;
DebugPages: UEArray<S_DebugPage>;
VisiblePagesLength: Integer;
CurrentPageIndex: Integer;
} {
return {
IsInitialized: this.IsInitialized,
DebugPages: this.DebugPages,
VisiblePagesLength: this.GetVisiblePages().length,
CurrentPageIndex: this.CurrentPageIndex,
};
}
if (this.GetCurrentPage().IsFound && CurrentPage !== null) {
switch (CurrentPage.UpdateFunction) {
case E_DebugUpdateFunction.UpdateMovementPage: {
CurrentPage = this.UpdateMovementPage(CurrentPage);
break;
}
case E_DebugUpdateFunction.UpdateSurfacePage: {
CurrentPage = this.UpdateSurfacePage(CurrentPage);
break;
}
case E_DebugUpdateFunction.UpdatePerformancePage: {
CurrentPage = this.UpdatePerformancePage(CurrentPage);
break;
}
case E_DebugUpdateFunction.UpdateInputDevicePage: {
CurrentPage = this.UpdateInputDevicePage(CurrentPage);
break;
}
case E_DebugUpdateFunction.UpdateCameraPage: {
CurrentPage = this.UpdateCameraPage(CurrentPage);
break;
/**
* Initialize debug HUD system with movement component reference
* Sets up pages, creates widget, runs tests, and starts display
* @param ToastComponentRef - Reference to toast system for notifications
* @param InputDeviceComponentRef - Reference to input device component for device info
* @example
* // Initialize debug HUD in main character
* this.DebugHUDComponent.InitializeDebugHUD(this.MovementComponent);
* @category System Setup
*/
public InitializeDebugHUD(
ToastComponentRef: AC_ToastSystem | null,
InputDeviceComponentRef: AC_InputDevice | null
): void {
this.ToastComponent = ToastComponentRef;
this.InputDeviceComponent = InputDeviceComponentRef;
if (!this.IsInitialized) {
this.IsInitialized = true;
this.CreateDebugWidget();
if (SystemLibrary.IsValid(this.ToastComponent)) {
this.ToastComponent.ShowToast(
'Debug HUD Initialized',
E_MessageType.Success
);
}
}
}
/**
* Find index of page by ID
* @param PageId - Page identifier to search for
* @returns Index of the page or -1 if not found
* @category Utility
*/
private FindPageIndex(PageId: string): Integer {
for (let i = 0; i < this.DebugPages.length; i++) {
if (this.DebugPages.Get(i).PageID === PageId) {
return i;
}
}
return -1;
}
/**
* Main update loop for debug HUD system
* @param CurrentTime - Current game time in seconds
* @category HUD Rendering
*/
public UpdateHUD(CurrentTime: Float): void {
if (this.IsInitialized && SystemLibrary.IsValid(this.DebugWidget)) {
this.FrameCounter++;
const ShouldUpdateFPS = (currentTime: Float): boolean =>
currentTime - this.LastUpdateTime >= 1;
const UpdateFPSCounter = (currentTime: Float): Float =>
this.FrameCounter / (currentTime - this.LastUpdateTime);
if (ShouldUpdateFPS(CurrentTime)) {
this.FPS = UpdateFPSCounter(CurrentTime);
this.FrameCounter = 0;
this.LastUpdateTime = CurrentTime;
if (this.ShouldShowDebugHUD()) {
this.UpdateWidgetDisplay();
}
}
this.DebugPages.SetArrayElem(
this.DebugSettings.CurrentPageIndex,
CurrentPage
);
this.UpdateWidgetPage();
}
}
/**
* Update movement constants page content
* @param Page - Page structure to update
* @returns Updated page with current movement data
* @category Page Updates
* Get navigation instructions based on input device
* @return Control hints text
* @category Widget Management
* @pure true
*/
public UpdateMovementPage(Page: S_DebugPage): S_DebugPage {
if (SystemLibrary.IsValid(this.MovementComponent)) {
return {
PageID: Page.PageID,
Title: Page.Title,
Content:
// Constants
`Max Speed: ${this.MovementComponent.MovementConstants.MaxSpeed}\n` +
`Acceleration: ${this.MovementComponent.MovementConstants.Acceleration}\n` +
`Friction: ${this.MovementComponent.MovementConstants.Friction}\n` +
`Gravity: ${this.MovementComponent.MovementConstants.Gravity}\n` +
`\n` + // Разделитель
// Current State
`Current Velocity: ${StringLibrary.ConvVectorToString(this.MovementComponent.CurrentVelocity)}\n` +
`Speed: ${this.MovementComponent.CurrentSpeed}\n` +
`Is Grounded: ${this.MovementComponent.IsGrounded}\n` +
`Surface Type: ${this.MovementComponent.CurrentSurface}\n` +
`Movement State: ${this.MovementComponent.MovementState}\n` +
`Input Magnitude: ${this.MovementComponent.InputMagnitude}`,
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
} else {
return {
PageID: Page.PageID,
Title: Page.Title,
Content: 'Movement Component Not Found',
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
}
}
/**
* Update surface classification page content
* @param Page - Page structure to update
* @returns Updated page with current surface angle thresholds
* @category Page Updates
*/
public UpdateSurfacePage(Page: S_DebugPage): S_DebugPage {
if (SystemLibrary.IsValid(this.MovementComponent)) {
return {
PageID: Page.PageID,
Title: Page.Title,
Content:
`Walkable: ≤${this.MovementComponent.AngleThresholdsDegrees.Walkable}°\n` +
`Steep Slope: ${this.MovementComponent.AngleThresholdsDegrees.Walkable}°-${this.MovementComponent.AngleThresholdsDegrees.SteepSlope}°\n` +
`Wall: ${this.MovementComponent.AngleThresholdsDegrees.SteepSlope}°-${this.MovementComponent.AngleThresholdsDegrees.Wall}°\n` +
`Ceiling: >${this.MovementComponent.AngleThresholdsDegrees.Wall}°`,
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
} else {
return {
PageID: Page.PageID,
Title: Page.Title,
Content: 'Movement Component Not Found',
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
}
}
/**
* Update performance metrics page content
* @param Page - Page structure to update
* @returns Updated page with current performance data
* @category Page Updates
*/
public UpdatePerformancePage(Page: S_DebugPage): S_DebugPage {
if (SystemLibrary.IsValid(this.MovementComponent)) {
const IsUpdatingEveryFrame = (updateFrequency: Float): boolean =>
updateFrequency <= 0;
return {
PageID: Page.PageID,
Title: Page.Title,
Content:
`Frame: ${this.FrameCounter}\n` +
`FPS: ${this.FPS}\n` +
`Update Rate: ${IsUpdatingEveryFrame(this.DebugSettings.UpdateFrequency) ? 'Every Frame' : `${this.DebugSettings.UpdateFrequency} Hz`}\n` +
`ActivePages: ${this.GetVisiblePages().length}`,
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
} else {
return {
PageID: Page.PageID,
Title: Page.Title,
Content: 'Movement Component Not Found',
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
}
}
/**
* Update input device information page content
* @param Page - Page structure to update
* @returns Updated page with current input device data
* @category Page Updates
*/
public UpdateInputDevicePage(Page: S_DebugPage): S_DebugPage {
private GetControlHints(): Text {
if (SystemLibrary.IsValid(this.InputDeviceComponent)) {
return {
PageID: Page.PageID,
Title: Page.Title,
Content:
`Hardware Device Identifier: ${this.InputDeviceComponent.GetCurrentInputDevice()}` +
`Initialized: ${this.InputDeviceComponent.IsInitialized}` +
`Last Change: ${this.InputDeviceComponent.LastDeviceChangeTime}`,
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
} else {
return {
PageID: Page.PageID,
Title: Page.Title,
Content: 'Input Device Component Not Found',
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
if (this.InputDeviceComponent.IsGamepad()) {
return 'LT+RT+Right/LT+RT+Left';
}
}
return 'PageUp/PageDown';
}
/**
* Update widget display with current page content
* @category Widget Management
*/
private UpdateWidgetDisplay(): void {
const { Page: currentPage, IsFound } = this.GetCurrentPage();
if (IsFound && SystemLibrary.IsValid(this.DebugWidget)) {
this.DebugWidget.SetHeaderText(currentPage!.Title);
this.DebugWidget.SetContentText(currentPage!.Content);
this.DebugWidget.SetNavigationText(this.GetNavigationText());
}
}
/**
* Update camera system information page content
* @param Page - Page structure to update
* @returns Updated page with current camera data
* @category Page Updates
* Generate navigation text showing current page position
* @returns Formatted navigation string
* @category Widget Control
* @pure true
*/
public UpdateCameraPage(Page: S_DebugPage): S_DebugPage {
if (SystemLibrary.IsValid(this.CameraComponent)) {
return {
PageID: Page.PageID,
Title: Page.Title,
Content:
`Current Device: ${SystemLibrary.IsValid(this.InputDeviceComponent) ? this.InputDeviceComponent.GetCurrentInputDevice() : 'Input Device Component Not Found'}\n` +
`Sensitivity: ${SystemLibrary.IsValid(this.InputDeviceComponent) && this.InputDeviceComponent.IsGamepad() ? this.CameraComponent.CameraSettings.GamepadSensitivity : this.CameraComponent.CameraSettings.MouseSensitivity}\n` +
`Pitch: ${this.CameraComponent.GetCameraRotation().Pitch}°\n` +
`Yaw: ${this.CameraComponent.GetCameraRotation().Yaw}°\n` +
`Is Rotating: ${this.CameraComponent.IsCameraRotating() ? 'Yes' : 'No'}\n` +
`Smoothing: ${this.CameraComponent.CameraSettings.SmoothingSpeed}\n` +
`Invert Y: ${this.CameraComponent.CameraSettings.InvertYAxis ? 'Yes' : 'No'}`,
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
} else {
return {
PageID: Page.PageID,
Title: Page.Title,
Content: 'Camera Component Not Found',
IsVisible: Page.IsVisible,
UpdateFunction: Page.UpdateFunction,
};
}
private GetNavigationText(): string {
return `Page ${this.CurrentPageIndex + 1}/${this.GetVisiblePages().length} | FPS: ${this.FPS} | ${this.GetControlHints()}`;
}
/**
@ -435,13 +405,16 @@ export class AC_DebugHUD extends ActorComponent {
*/
private CreateDebugWidget(): void {
this.DebugWidget = CreateWidget(WBP_DebugHUD);
this.DebugWidget.MovementComponent = this.MovementComponent;
if (SystemLibrary.IsValid(this.DebugWidget)) {
this.DebugWidget.AddToViewport();
this.UpdateWidgetVisibility();
} else {
if (SystemLibrary.IsValid(this.ToastComponent)) {
this.ToastComponent.ShowToast('Failed to create debug widget');
this.ToastComponent.ShowToast(
'Failed to create debug widget',
E_MessageType.Error
);
}
}
}
@ -461,139 +434,22 @@ export class AC_DebugHUD extends ActorComponent {
}
/**
* Send current page data to debug widget for display
* @category Widget Communication
* Check if debug HUD should be visible
* @returns True if system is initialized and mode is visible
* @category HUD Control
* @pure true
*/
private UpdateWidgetPage(): void {
if (
this.GetCurrentPage().IsFound &&
SystemLibrary.IsValid(this.DebugWidget)
) {
const currentPage = this.GetCurrentPage().Page;
const visiblePages = this.GetVisiblePages();
this.DebugWidget.SetHeaderText(currentPage!.Title);
this.DebugWidget.SetContentText(currentPage!.Content);
this.DebugWidget.SetNavigationText(
`Page ${this.DebugSettings.CurrentPageIndex + 1}/${visiblePages.length} | ${this.GetControlHints()} - Navigate`
);
}
}
private GetControlHints(): Text {
if (SystemLibrary.IsValid(this.InputDeviceComponent)) {
if (this.InputDeviceComponent.IsGamepad()) {
return 'D-Pad Up/Down';
}
}
return 'PageUp/PageDown';
}
/**
* Main update loop for debug HUD system
* Called every frame from game loop
* @param CurrentTime - Current game time in seconds
* @param DeltaTime - Time since last frame in seconds
* @category HUD Rendering
*/
public UpdateHUD(CurrentTime: Float, DeltaTime: Float): void {
const IsReadyForUpdate = (shouldUpdateHUD: boolean): boolean =>
this.IsInitialized && shouldUpdateHUD;
const IsValidDeltaTime = (deltaTime: Float): boolean => deltaTime > 0;
const CalculateFPS = (deltaTime: Float): Float => 1 / deltaTime;
if (IsReadyForUpdate(this.ShouldUpdateDebugHUD(CurrentTime))) {
this.FrameCounter++;
this.FPS = IsValidDeltaTime(DeltaTime) ? CalculateFPS(DeltaTime) : 0;
this.LastUpdateTime = CurrentTime;
if (this.ShouldShowDebugHUD()) {
this.UpdateCurrentPage();
this.UpdateWidgetPage();
}
}
}
/**
* Register default debug pages (Movement, Surface, Performance)
* @category System Setup
*/
private RegisterDefaultPages(): void {
DataTableFunctionLibrary.GetDataTableRowNames(this.DebugDataTable).forEach(
arrayElement => {
this.DebugDataTable.GetDataTableRow(arrayElement, row => {
this.RegisterDebugPage(row);
});
}
private ShouldShowDebugHUD(): boolean {
return (
this.CurrentMode === ESlateVisibility.Visible &&
this.GetVisiblePages().length > 0
);
}
/**
* Get comprehensive test data for debug system validation
* @returns Object containing initialization status, DataTable reference, and pages array
* @category Testing
*/
public GetTestData(): {
IsInitialized: boolean;
DebugDataTable: DataTable<S_DebugPage>;
DebugPages: UEArray<S_DebugPage>;
} {
return {
IsInitialized: this.IsInitialized,
DebugDataTable: this.DebugDataTable,
DebugPages: this.DebugPages,
};
}
/**
* Initialize debug HUD system with movement component reference
* Sets up pages, creates widget, runs tests, and starts display
* @param MovementComponentRef - Reference to movement component to debug
* @param ToastComponentRef - Reference to toast system for notifications
* @param InputDeviceComponentRef - Reference to input device component for device info
* @param CameraComponentRef - Reference to camera component for camera info
* @example
* // Initialize debug HUD in main character
* this.DebugHUDComponent.InitializeDebugHUD(this.MovementComponent);
* @category System Setup
*/
public InitializeDebugHUD(
MovementComponentRef: AC_Movement,
ToastComponentRef: AC_ToastSystem,
InputDeviceComponentRef: AC_InputDevice,
CameraComponentRef: AC_Camera
): void {
this.MovementComponent = MovementComponentRef;
this.ToastComponent = ToastComponentRef;
this.InputDeviceComponent = InputDeviceComponentRef;
this.CameraComponent = CameraComponentRef;
this.IsInitialized = true;
this.FrameCounter = 0;
this.LastUpdateTime = 0;
this.FPS = 0;
this.RegisterDefaultPages();
this.CreateDebugWidget();
this.DebugSettings.CurrentPageIndex = 0;
this.UpdateWidgetVisibility();
this.ToastComponent.ShowToast(
'Debug HUD Initialized',
E_MessageType.Success
);
this.UpdateCurrentPage();
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Reference to movement component being debugged
* Set during initialization, used for accessing movement data
* @category Components
*/
private MovementComponent: AC_Movement | null = null;
/**
* Reference to toast system component for debug messaging
* Set during initialization, used for displaying debug notifications
@ -609,25 +465,24 @@ export class AC_DebugHUD extends ActorComponent {
public InputDeviceComponent: AC_InputDevice | null = null;
/**
* Reference to camera component for camera-related debug info
* Set externally, used for displaying camera sensitivity and state
* @category Components
*/
public CameraComponent: AC_Camera | null = null;
/**
* Debug system configuration settings
* Controls visibility, update frequency, and current page
* Instance editable for designer customization
* @category DebugConfig
* Current mode of the debug HUD (Visible, Hidden, Collapsed)
* @category Debug Config
* @instanceEditable true
*/
public DebugSettings: S_DebugSettings = {
CurrentMode: ESlateVisibility.Visible,
CurrentPageIndex: 0,
ShowVisualDebug: false,
UpdateFrequency: 0,
};
public CurrentMode: ESlateVisibility = ESlateVisibility.Visible;
/**
* Index of the currently displayed debug page
* @category Debug Config
*/
public CurrentPageIndex: Integer = 0;
/**
* Visual debug rendering toggle (collision shapes, rays, etc.)
* @category Debug Config
* @instanceEditable true
*/
public ShowVisualDebug: boolean = true;
/**
* System initialization state flag
@ -670,11 +525,4 @@ export class AC_DebugHUD extends ActorComponent {
* @category Page System
*/
private DebugPages: UEArray<S_DebugPage> = new UEArray([]);
/**
* DataTable reference for debug pages storage
* Contains structured page data with Name-based indexing for efficient lookup
* @category Page System
*/
private DebugDataTable: DataTable<S_DebugPage> = DT_DebugPages;
}

Binary file not shown.

View File

@ -1,9 +0,0 @@
// Debug/Enums/E_DebugPageID.ts
export enum E_DebugPageID {
MovementInfo = 'MovementInfo',
SurfaceInfo = 'SurfaceInfo',
PerformanceInfo = 'PerformanceInfo',
InputDeviceInfo = 'InputDeviceInfo',
CameraInfo = 'CameraInfo',
}

BIN
Content/Debug/Enums/E_DebugPageID.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,9 +0,0 @@
// Debug/Enums/E_DebugUpdateFunction.ts
export enum E_DebugUpdateFunction {
UpdateMovementPage = 'UpdateMovementPage',
UpdateSurfacePage = 'UpdateSurfacePage',
UpdatePerformancePage = 'UpdatePerformancePage',
UpdateInputDevicePage = 'UpdateInputDevicePage',
UpdateCameraPage = 'UpdateCameraPage',
}

Binary file not shown.

View File

@ -5,7 +5,7 @@
## Тестовая среена
- **Персонаж:** BP_MainCharacter с ShowDebugInfo = true
- **Клавиши:** PageUp/PageDown, Tab, Home
- **Требования:** MovementComponent и ToastSystemComponent инициализированы
- **Требования:** MovementComponent и InputDeviceComponentRef инициализированы
---
@ -23,57 +23,19 @@
---
## 2. Содержимое страниц
## 2. Toggle функциональность
### 2.1 Movement Constants (Page 1)
- [ ] **Title:** "Movement Constants"
- [ ] **Content содержит:**
- Max Speed: 600
- Acceleration: 2000
- Friction: 8
- Gravity: 980
### 2.2 Surface Classification (Page 2)
- [ ] **Title:** "Surface Classification"
- [ ] **Content содержит:**
- Walkable: ≤50°
- Steep Slope: 50°-85°
- Wall: 85°-95°
- Ceiling: >95°
### 2.3 Performance Metrics (Page 3)
- [ ] **Title:** "Performance Metrics"
- [ ] **Content содержит:**
- Frame: [увеличивающийся счетчик]
- FPS: [текущий FPS]
- Update Rate: Every Frame
- ActivePages: 3
---
## 3. Toggle функциональность
### 3.1 Debug HUD toggle
### 2.1 Debug HUD toggle
- [ ] **Tab** скрывает/показывает весь debug HUD
- [ ] **Visibility state** сохраняется при навигации
### 3.2 Visual Debug toggle
### 2.2 Visual Debug toggle
- [ ] **Home** включает/выключает visual debug
- [ ] **Toast notification** появляется: "Visual Debug Enabled/Disabled"
---
## 4. Обновление данных
### 4.1 Real-time updates
- [ ] **Frame counter** увеличивается каждое обновление
- [ ] **FPS** отражает реальную производительность
- [ ] **Movement constants** соответствуют значениям из MovementComponent
---
## Критерии прохождения
- [ ] Все 3 страницы отображаются корректно
- [ ] Навигация работает в обе стороны
- [ ] Toggle функции работают
- [ ] Данные обновляются в реальном времени

View File

@ -1,13 +1,13 @@
// Debug/Structs/S_DebugPage.ts
import type { E_DebugPageID } from '#root/Debug/Enums/E_DebugPageID.js';
import type { E_DebugUpdateFunction } from '#root/Debug/Enums/E_DebugUpdateFunction.js';
import type { Float } from '#root/UE/Float.ts';
import type { Text } from '#root/UE/Text.ts';
export interface S_DebugPage {
PageID: E_DebugPageID;
PageID: string;
Title: Text;
Content: Text;
RefreshRate: Float;
IsVisible: boolean;
UpdateFunction: E_DebugUpdateFunction;
LastUpdateTime: Float;
}

BIN
Content/Debug/Structs/S_DebugPage.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,12 +0,0 @@
// Debug/Enums/S_DebugSettings.ts
import type { ESlateVisibility } from '#root/UE/ESlateVisibility.ts';
import type { Float } from '#root/UE/Float.ts';
import type { Integer } from '#root/UE/Integer.ts';
export interface S_DebugSettings {
CurrentMode: ESlateVisibility;
CurrentPageIndex: Integer;
ShowVisualDebug: boolean;
UpdateFrequency: Float;
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +0,0 @@
// Debug/Tables/DT_DebugPages.ts
import { E_DebugPageID } from '#root/Debug/Enums/E_DebugPageID.ts';
import { E_DebugUpdateFunction } from '#root/Debug/Enums/E_DebugUpdateFunction.ts';
import type { S_DebugPage } from '#root/Debug/Structs/S_DebugPage.ts';
import { DataTable } from '#root/UE/DataTable.ts';
import { Name } from '#root/UE/Name.ts';
import { UEArray } from '#root/UE/UEArray.ts';
export const DT_DebugPages = new DataTable<S_DebugPage>(
null,
new Name('DT_DebugPages'),
new UEArray<S_DebugPage & { Name: Name }>([
{
Name: new Name('MovementInfo'),
PageID: E_DebugPageID.MovementInfo,
Title: 'Movement Constants',
Content: '',
IsVisible: true,
UpdateFunction: E_DebugUpdateFunction.UpdateMovementPage,
},
{
Name: new Name('SurfaceInfo'),
PageID: E_DebugPageID.SurfaceInfo,
Title: 'Surface Classification',
Content: '',
IsVisible: true,
UpdateFunction: E_DebugUpdateFunction.UpdateSurfacePage,
},
{
Name: new Name('PerformanceInfo'),
PageID: E_DebugPageID.PerformanceInfo,
Title: 'Performance Metrics',
Content: '',
IsVisible: true,
UpdateFunction: E_DebugUpdateFunction.UpdatePerformancePage,
},
{
Name: new Name('InputDeviceInfo'),
PageID: E_DebugPageID.InputDeviceInfo,
Title: 'Input Device Info',
Content: '',
IsVisible: true,
UpdateFunction: E_DebugUpdateFunction.UpdateInputDevicePage,
},
{
Name: new Name('CameraInfo'),
PageID: E_DebugPageID.CameraInfo,
Title: 'Camera System',
Content: '',
IsVisible: true,
UpdateFunction: E_DebugUpdateFunction.UpdateCameraPage,
},
])
);

BIN
Content/Debug/Tables/DT_DebugPages.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,9 +1,7 @@
// Debug/Tests/FT_DebugNavigation.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
@ -28,10 +26,8 @@ export class FT_DebugNavigation extends FunctionalTest {
*/
EventStartTest(): void {
this.DebugHUDComponent.InitializeDebugHUD(
this.MovementComponent,
this.ToastSystemComponent,
this.InputDeviceComponent,
this.CameraComponent
this.InputDeviceComponent
);
this.IfValid('Debug HUD: Navigation invalid initial state', () => {
@ -73,17 +69,12 @@ export class FT_DebugNavigation extends FunctionalTest {
currentPage: Integer
): boolean => visiblePagesLength > 0 && currentPage >= visiblePagesLength;
const IsPageIndexNonNegative = (currentPage: Integer): boolean =>
currentPage >= 0;
if (
!IsPageIndexOutOfBounds(
this.DebugHUDComponent.GetVisiblePages().length,
this.DebugHUDComponent.DebugSettings.CurrentPageIndex
this.DebugHUDComponent.GetTestData().VisiblePagesLength,
this.DebugHUDComponent.GetTestData().CurrentPageIndex
) &&
IsPageIndexNonNegative(
this.DebugHUDComponent.DebugSettings.CurrentPageIndex
)
this.DebugHUDComponent.GetTestData().CurrentPageIndex >= 0
) {
Out();
} else {
@ -95,12 +86,6 @@ export class FT_DebugNavigation extends FunctionalTest {
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Movement system component - required for debug HUD initialization
* @category Components
*/
MovementComponent = new AC_Movement();
/**
* Debug HUD system - primary component under test
* Tests page navigation state management
@ -119,10 +104,4 @@ export class FT_DebugNavigation extends FunctionalTest {
* @category Components
*/
InputDeviceComponent = new AC_InputDevice();
/**
* Camera system component - included for completeness, not directly tested
* @category Components
*/
CameraComponent = new AC_Camera();
}

Binary file not shown.

View File

@ -1,125 +0,0 @@
// Debug/Tests/FT_DebugPageContentGenerator.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { E_DebugPageID } from '#root/Debug/Enums/E_DebugPageID.ts';
import { E_DebugUpdateFunction } from '#root/Debug/Enums/E_DebugUpdateFunction.ts';
import type { S_DebugPage } from '#root/Debug/Structs/S_DebugPage.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
/**
* Functional Test: Debug HUD Page Content Generation
* Validates that all registered debug pages generate non-empty content
*/
export class FT_DebugPageContentGenerator extends FunctionalTest {
// ════════════════════════════════════════════════════════════════════════════════════════
// GRAPHS
// ════════════════════════════════════════════════════════════════════════════════════════
// ────────────────────────────────────────────────────────────────────────────────────────
// EventGraph
// ────────────────────────────────────────────────────────────────────────────────────────
/**
* Test entry point - validates content generation for all debug pages
* Iterates through all pages and tests their update functions
*/
EventStartTest(): void {
this.DebugHUDComponent.InitializeDebugHUD(
this.MovementComponent,
this.ToastSystemComponent,
this.InputDeviceComponent,
this.CameraComponent
);
this.DebugHUDComponent.GetTestData().DebugPages.forEach(
(arrayElement, arrayIndex) => {
this.UpdatedPage = arrayElement;
switch (this.UpdatedPage.UpdateFunction) {
case E_DebugUpdateFunction.UpdateMovementPage: {
this.UpdatedPage = this.DebugHUDComponent.UpdateMovementPage(
this.UpdatedPage
);
break;
}
case E_DebugUpdateFunction.UpdateSurfacePage: {
this.UpdatedPage = this.DebugHUDComponent.UpdateSurfacePage(
this.UpdatedPage
);
break;
}
case E_DebugUpdateFunction.UpdatePerformancePage: {
this.UpdatedPage = this.DebugHUDComponent.UpdatePerformancePage(
this.UpdatedPage
);
break;
}
}
if (this.UpdatedPage.Content.length > 0) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`DebugHUD: Page ${arrayIndex + 1} content empty`
);
}
}
);
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Movement system component - required for debug HUD initialization
* @category Components
*/
MovementComponent = new AC_Movement();
/**
* Debug HUD system - primary component under test
* Tests page content generation functionality
* @category Components
*/
DebugHUDComponent = new AC_DebugHUD();
/**
* Toast notification system - required for debug HUD initialization
* @category Components
*/
ToastSystemComponent = new AC_ToastSystem();
/**
* Input device detection system - used for input device debug page testing
* @category Components
*/
InputDeviceComponent = new AC_InputDevice();
/**
* Camera system component - included for completeness, not directly tested
* @category Components
*/
CameraComponent = new AC_Camera();
/**
* Working copy of debug page for content generation testing
* Updated during test execution for each page
* @category Test State
*/
UpdatedPage: S_DebugPage = {
PageID: E_DebugPageID.MovementInfo,
Title: '',
Content: '',
IsVisible: false,
UpdateFunction: E_DebugUpdateFunction.UpdateMovementPage,
};
}

Binary file not shown.

View File

@ -0,0 +1,261 @@
// Debug/Tests/FT_DebugPageManagement.ts
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
import { SystemLibrary } from '#root/UE/SystemLibrary.ts';
/**
* Functional Test: Debug Page Management
* Tests dynamic page registration, content updates, and lifecycle operations
*/
export class FT_DebugPageManagement extends FunctionalTest {
// ════════════════════════════════════════════════════════════════════════════════════════
// GRAPHS
// ════════════════════════════════════════════════════════════════════════════════════════
// ────────────────────────────────────────────────────────────────────────────────────────
// EventGraph
// ────────────────────────────────────────────────────────────────────────────────────────
/**
* Test entry point - validates all page management operations
* Tests: Add, Update, ShouldUpdate, Visibility, Remove
*/
EventStartTest(): void {
this.DebugHUDComponent.InitializeDebugHUD(
this.ToastSystemComponent,
this.InputDeviceComponent
);
this.DebugHUDComponent.AddDebugPage('TestPage1', 'Test Page 1', 30, true);
const pageCount = this.DebugHUDComponent.GetTestData().DebugPages.length;
if (pageCount === 1) {
const testContent = 'Test Content 123';
this.DebugHUDComponent.UpdatePageContent('TestPage1', testContent);
const page = this.DebugHUDComponent.GetTestData().DebugPages.Get(0);
const contentMatches = page.Content === testContent;
if (contentMatches) {
const currentTime = SystemLibrary.GetGameTimeInSeconds();
// First call should return true (no previous update)
const firstCall = this.DebugHUDComponent.ShouldUpdatePage(
'TestPage1',
currentTime
);
// Immediate second call should return false (just updated)
const secondCall = this.DebugHUDComponent.ShouldUpdatePage(
'TestPage1',
currentTime
);
if (firstCall && !secondCall) {
this.DebugHUDComponent.AddDebugPage(
'TestPage2',
'Test Page 2',
60,
true
);
const pageCount =
this.DebugHUDComponent.GetTestData().DebugPages.length;
const visibleCount =
this.DebugHUDComponent.GetTestData().VisiblePagesLength;
if (pageCount === 2 && visibleCount === 2) {
// Hide second page
this.DebugHUDComponent.SetPageVisibility('TestPage2', false);
const totalCount =
this.DebugHUDComponent.GetTestData().DebugPages.length;
const visibleCount =
this.DebugHUDComponent.GetTestData().VisiblePagesLength;
if (totalCount === 2 && visibleCount === 1) {
// Remove first page
this.DebugHUDComponent.RemoveDebugPage('TestPage1');
const totalCount =
this.DebugHUDComponent.GetTestData().DebugPages.length;
const currentIndex =
this.DebugHUDComponent.GetTestData().CurrentPageIndex;
if (totalCount === 1 && currentIndex === 0) {
// Re-add page with same ID but different settings
this.DebugHUDComponent.AddDebugPage(
'TestPage2',
'Updated Title',
120,
true
);
const totalCount =
this.DebugHUDComponent.GetTestData().DebugPages.length;
const visibleCount =
this.DebugHUDComponent.GetTestData().VisiblePagesLength;
const page =
this.DebugHUDComponent.GetTestData().DebugPages.Get(0);
const titleMatches = page.Title === 'Updated Title';
const refreshRateMatches = page.RefreshRate === 120;
if (
totalCount === 1 &&
visibleCount === 1 &&
titleMatches &&
refreshRateMatches
) {
// Add pages with different refresh rates
this.DebugHUDComponent.AddDebugPage(
'FastPage',
'Fast Page',
120,
true
);
this.DebugHUDComponent.AddDebugPage(
'SlowPage',
'Slow Page',
10,
true
);
const currentTime = SystemLibrary.GetGameTimeInSeconds();
// Both should update on first call
const fastShouldUpdate =
this.DebugHUDComponent.ShouldUpdatePage(
'FastPage',
currentTime
);
const slowShouldUpdate =
this.DebugHUDComponent.ShouldUpdatePage(
'SlowPage',
currentTime
);
// Wait for fast page interval (1/120 = 0.0083s) but not slow (1/10 = 0.1s)
const fastUpdateTime = currentTime + 0.01;
const fastShouldUpdateAgain =
this.DebugHUDComponent.ShouldUpdatePage(
'FastPage',
fastUpdateTime
);
const slowShouldNotUpdate =
this.DebugHUDComponent.ShouldUpdatePage(
'SlowPage',
fastUpdateTime
);
if (
fastShouldUpdate &&
slowShouldUpdate &&
fastShouldUpdateAgain &&
!slowShouldNotUpdate
) {
// Try to update non-existent page (should not crash)
this.DebugHUDComponent.UpdatePageContent(
'NonExistentPage',
'Test'
);
// Try to remove non-existent page (should not crash)
this.DebugHUDComponent.RemoveDebugPage('NonExistentPage');
// Try to check non-existent page (should return false)
const currentTime = SystemLibrary.GetGameTimeInSeconds();
const shouldUpdate =
this.DebugHUDComponent.ShouldUpdatePage(
'NonExistentPage',
currentTime
);
if (!shouldUpdate) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Test 9 Failed: ShouldUpdatePage returned true for non-existent page'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 8 Failed: Refresh rates incorrect (fast1: ${fastShouldUpdate}, slow1: ${slowShouldUpdate}, fast2: ${fastShouldUpdateAgain}, slow2: ${slowShouldNotUpdate})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 7 Failed: Update registration incorrect (count: ${totalCount}, title: ${titleMatches}, rate: ${refreshRateMatches})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 6 Failed: Remove incorrect (count: ${totalCount}, index: ${currentIndex})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 5 Failed: Visibility incorrect (total: ${totalCount}, visible: ${visibleCount})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 4 Failed: Expected 2 pages (total: ${pageCount}, visible: ${visibleCount})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 3 Failed: ShouldUpdatePage timing incorrect (first: ${firstCall}, second: ${secondCall})`
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Test 2 Failed: Content did not update correctly'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Test 1 Failed: Expected 1 page, got ${pageCount}`
);
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Debug HUD system - primary component under test
* Tests all page management operations
* @category Components
*/
DebugHUDComponent = new AC_DebugHUD();
/**
* Toast notification system - required for debug HUD initialization
* @category Components
*/
ToastSystemComponent = new AC_ToastSystem();
/**
* Input device detection system - required for debug HUD initialization
* @category Components
*/
InputDeviceComponent = new AC_InputDevice();
}

BIN
Content/Debug/Tests/FT_DebugPageManagement.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,11 +1,8 @@
// Debug/Tests/FT_DebugSystem.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { DataTableFunctionLibrary } from '#root/UE/DataTableFunctionLibrary.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
import { SystemLibrary } from '#root/UE/SystemLibrary.ts';
@ -29,41 +26,17 @@ export class FT_DebugSystem extends FunctionalTest {
*/
EventStartTest(): void {
this.DebugHUDComponent.InitializeDebugHUD(
this.MovementComponent,
this.ToastSystemComponent,
this.InputDeviceComponent,
this.CameraComponent
this.InputDeviceComponent
);
if (this.DebugHUDComponent.GetTestData().IsInitialized) {
if (
DataTableFunctionLibrary.GetDataTableRowNames(
this.DebugHUDComponent.GetTestData().DebugDataTable
).length === this.DebugHUDComponent.GetTestData().DebugPages.length
) {
if (SystemLibrary.IsValid(this.MovementComponent)) {
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'DebugHUD component not valid'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Debug HUD: Movement component not valid'
);
}
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Debug HUD: Expected ${this.DebugHUDComponent.GetTestData().DebugPages.length} pages, got ${
DataTableFunctionLibrary.GetDataTableRowNames(
this.DebugHUDComponent.GetTestData().DebugDataTable
).length
}`
'DebugHUD component not valid'
);
}
} else {
@ -78,12 +51,6 @@ export class FT_DebugSystem extends FunctionalTest {
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Movement system component - required for debug HUD initialization
* @category Components
*/
MovementComponent = new AC_Movement();
/**
* Debug HUD system - primary component under test
* Tests basic system initialization and component validity
@ -102,10 +69,4 @@ export class FT_DebugSystem extends FunctionalTest {
* @category Components
*/
InputDeviceComponent = new AC_InputDevice();
/**
* Camera system component - included for completeness, not directly tested
* @category Components
*/
CameraComponent = new AC_Camera();
}

BIN
Content/Debug/Tests/FT_DebugSystem.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,5 +1,6 @@
// Input/Components/AC_InputDevice.ts
import type { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import type { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { ActorComponent } from '#root/UE/ActorComponent.ts';
import { EHardwareDevicePrimaryType } from '#root/UE/EHardwareDevicePrimaryType.ts';
@ -52,14 +53,27 @@ export class AC_InputDevice extends ActorComponent {
/**
* Initialize device detection system with delegate registration
* @param ToastComponentRef - Toast system for debug notifications
* @param DebugHUDComponentRef - Optional debug HUD for displaying device info
* @category System Setup
*/
public InitializeDeviceDetection(ToastComponentRef: AC_ToastSystem): void {
public InitializeDeviceDetection(
ToastComponentRef: AC_ToastSystem,
DebugHUDComponentRef: AC_DebugHUD
): void {
this.ToastComponent = ToastComponentRef;
this.DebugHUDComponent = DebugHUDComponentRef;
this.RegisterHardwareDeviceDelegate();
this.DetectInitialDevice();
this.IsInitialized = true;
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
this.DebugHUDComponent.AddDebugPage(
this.DebugPageID,
'Input Device Info',
60
);
}
if (SystemLibrary.IsValid(this.ToastComponent)) {
this.ToastComponent.ShowToast(
`Device Detection Initialized: ${this.CurrentDevice}`,
@ -141,6 +155,28 @@ export class AC_InputDevice extends ActorComponent {
return HasCooldownExpired();
}
/**
* Update debug HUD with current device info
* @category Debug
*/
public UpdateDebugPage(): void {
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
if (
this.DebugHUDComponent.ShouldUpdatePage(
this.DebugPageID,
SystemLibrary.GetGameTimeInSeconds()
)
) {
this.DebugHUDComponent.UpdatePageContent(
this.DebugPageID,
`Hardware Device Identifier: ${this.GetCurrentInputDevice()}` +
`Initialized: ${this.IsInitialized}` +
`Last Change: ${this.LastDeviceChangeTime}`
);
}
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
@ -151,6 +187,13 @@ export class AC_InputDevice extends ActorComponent {
*/
private ToastComponent: AC_ToastSystem | null = null;
/**
* Reference to debug HUD component for displaying camera info
* Optional, used for debugging purposes
* @category Components
*/
public DebugHUDComponent: AC_DebugHUD | null = null;
/**
* Current active input device type
* Updated by hardware device change events
@ -178,4 +221,12 @@ export class AC_InputDevice extends ActorComponent {
* @instanceEditable true
*/
private DeviceChangeCooldown: Float = 0.3;
/**
* Debug page identifier for organizing debug output
* Used by debug HUD to categorize information
* @category Debug
* @instanceEditable true
*/
public readonly DebugPageID: string = 'InputDeviceInfo';
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
// Input/Tests/FT_InputDeviceDetection.ts
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -28,7 +29,8 @@ export class FT_InputDeviceDetection extends FunctionalTest {
// Initialize components
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.TestInitialization();
this.TestDeviceQueries();
@ -122,4 +124,10 @@ export class FT_InputDeviceDetection extends FunctionalTest {
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -7,7 +7,7 @@ import { FT_CameraRotation } from '#root/Camera/Tests/FT_CameraRotation.ts';
import { FT_CameraSensitivity } from '#root/Camera/Tests/FT_CameraSensitivity.ts';
import { FT_CameraSmoothing } from '#root/Camera/Tests/FT_CameraSmoothing.ts';
import { FT_DebugNavigation } from '#root/Debug/Tests/FT_DebugNavigation.ts';
import { FT_DebugPageContentGenerator } from '#root/Debug/Tests/FT_DebugPageContentGenerator.ts';
import { FT_DebugPageManagement } from '#root/Debug/Tests/FT_DebugPageManagement.ts';
import { FT_DebugSystem } from '#root/Debug/Tests/FT_DebugSystem.ts';
import { FT_InputDeviceDetection } from '#root/Input/Tests/FT_InputDeviceDetection.ts';
import { FT_BasicMovement } from '#root/Movement/Tests/FT_BasicMovement.ts';
@ -36,11 +36,10 @@ CameraSmoothingTest.EventStartTest();
// Debug Tests
const DebugNavigationTest = new FT_DebugNavigation();
const DebugPageContentGeneratorTest = new FT_DebugPageContentGenerator();
const DebugSystemTest = new FT_DebugSystem();
const DebugPageManagementTest = new FT_DebugPageManagement();
DebugNavigationTest.EventStartTest();
DebugPageContentGeneratorTest.EventStartTest();
DebugSystemTest.EventStartTest();
// Input Tests
@ -69,3 +68,4 @@ ToastsDurationHandlingTest.EventStartTest();
ToastsEdgeCasesTest.EventStartTest();
ToastsSystemInitializationTest.EventStartTest();
ToastsToastCreationTest.EventStartTest();
DebugPageManagementTest.EventStartTest();

BIN
Content/Levels/TestLevel.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -1,5 +1,6 @@
// Movement/Components/AC_Movement.ts
import type { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { BFL_Vectors } from '#root/Math/Libraries/BFL_Vectors.ts';
import { E_MovementState } from '#root/Movement/Enums/E_MovementState.ts';
import { E_SurfaceType } from '#root/Movement/Enums/E_SurfaceType.ts';
@ -9,6 +10,8 @@ import { ActorComponent } from '#root/UE/ActorComponent.ts';
import type { Float } from '#root/UE/Float.ts';
import { MathLibrary } from '#root/UE/MathLibrary.ts';
import { Rotator } from '#root/UE/Rotator.ts';
import { StringLibrary } from '#root/UE/StringLibrary.ts';
import { SystemLibrary } from '#root/UE/SystemLibrary.ts';
import { Vector } from '#root/UE/Vector.ts';
/**
@ -348,7 +351,10 @@ export class AC_Movement extends ActorComponent {
* Converts degree thresholds to radians for runtime performance
* @category System
*/
public InitializeMovementSystem(): void {
public InitializeMovementSystem(
DebugHUDComponentRef: AC_DebugHUD | null
): void {
this.DebugHUDComponent = DebugHUDComponentRef;
this.IsInitialized = true;
this.AngleThresholdsRads = {
@ -360,6 +366,55 @@ export class AC_Movement extends ActorComponent {
),
Wall: MathLibrary.DegreesToRadians(this.AngleThresholdsDegrees.Wall),
};
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
this.DebugHUDComponent.AddDebugPage(
this.DebugPageID,
'Movement Info',
60
);
}
}
/**
* Update debug HUD with current movement info
* @category Debug
*/
public UpdateDebugPage(): void {
if (SystemLibrary.IsValid(this.DebugHUDComponent)) {
if (
this.DebugHUDComponent.ShouldUpdatePage(
this.DebugPageID,
SystemLibrary.GetGameTimeInSeconds()
)
) {
this.DebugHUDComponent.UpdatePageContent(
this.DebugPageID,
// Constants
`Max Speed: ${this.MovementConstants.MaxSpeed}\n` +
`Acceleration: ${this.MovementConstants.Acceleration}\n` +
`Friction: ${this.MovementConstants.Friction}\n` +
`Gravity: ${this.MovementConstants.Gravity}\n` +
`Initialized: ${this.IsInitialized}\n` +
`\n` +
// Current State
`Current Velocity: ${StringLibrary.ConvVectorToString(this.CurrentVelocity)}\n` +
`Speed: ${this.CurrentSpeed}\n` +
`Is Grounded: ${this.IsGrounded}\n` +
`Surface Type: ${this.CurrentSurface}\n` +
`Movement State: ${this.MovementState}\n` +
`Input Magnitude: ${this.InputMagnitude}` +
`\n` +
// Rotation
`Current Yaw: ${this.CurrentRotation.yaw}\n` +
`Target Yaw: ${this.TargetRotation.yaw}\` +
`Rotation Delta: ${this.RotationDelta}\` +
`Is Rotating: ${this.IsCharacterRotating}\n` +
`Rotation Speed: ${this.RotationSpeed}\` +
`Min Speed: ${this.MinSpeedForRotation}`
);
}
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
@ -409,6 +464,13 @@ export class AC_Movement extends ActorComponent {
*/
public IsInitialized = false;
/**
* Debug page identifier for organizing debug output
* Used by debug HUD to categorize information
* @category Debug
*/
public readonly DebugPageID: string = 'MovementInfo';
/**
* Current character velocity in world space
* Updated every frame by movement calculations
@ -502,4 +564,11 @@ export class AC_Movement extends ActorComponent {
* @category Character Rotation State
*/
public RotationDelta: Float = 0.0;
/**
* Reference to debug HUD component for displaying camera info
* Optional, used for debugging purposes
* @category Components
*/
public DebugHUDComponent: AC_DebugHUD | null = null;
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
// Movement/Tests/FT_BasicMovement.ts
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import { E_MovementState } from '#root/Movement/Enums/E_MovementState.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
@ -26,7 +27,7 @@ export class FT_BasicMovement extends FunctionalTest {
*/
EventStartTest(): void {
// Initialize movement system
this.MovementComponent.InitializeMovementSystem();
this.MovementComponent.InitializeMovementSystem(this.DebugHUDComponent);
// Test 1: Initialization
if (this.MovementComponent.IsInitialized) {
@ -125,4 +126,10 @@ export class FT_BasicMovement extends FunctionalTest {
* @category Components
*/
private MovementComponent = new AC_Movement();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
// Movement/Tests/FT_DiagonalMovement.ts
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_Movement } from '#root/Movement/Components/AC_Movement.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
@ -26,7 +27,7 @@ export class FT_DiagonalMovement extends FunctionalTest {
*/
EventStartTest(): void {
// Initialize movement system
this.MovementComponent.InitializeMovementSystem();
this.MovementComponent.InitializeMovementSystem(this.DebugHUDComponent);
// Test 1: Cardinal movement (forward only)
for (let i = 0; i < 100; i++) {
@ -94,4 +95,10 @@ export class FT_DiagonalMovement extends FunctionalTest {
* @category Components
*/
private MovementComponent = new AC_Movement();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}

Binary file not shown.