77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
// Content/Blueprints/BP_MainCharacter.ts
|
|
|
|
import {AC_Movement} from "../Movement/Components/AC_Movement.js";
|
|
import type {Controller, Float} from "../types.js";
|
|
import {
|
|
AddMappingContext,
|
|
CastToPlayController,
|
|
EnhancedInputLocalPlayerSubsystem,
|
|
GetGameTimeInSeconds,
|
|
} from "../functions.js";
|
|
import {IMC_Default} from "../Input/IMC_Default.js";
|
|
import {AC_DebugHUD} from "../Debug/Components/AC_DebugHUD.js";
|
|
import {AC_ToastSystem} from "../Toasts/Compontents/AC_ToastSystem.js";
|
|
|
|
export class BP_MainCharacter {
|
|
// Category: "Components"
|
|
MovementComponent = new AC_Movement();
|
|
|
|
// Category: "Components"
|
|
DebugHUDComponent = new AC_DebugHUD();
|
|
|
|
// Category: "Components"
|
|
ToastSystemComponent = new AC_ToastSystem();
|
|
|
|
// Category: "Debug"
|
|
// Instance Editable: true
|
|
ShowDebugInfo: boolean = true;
|
|
|
|
// EventGraph
|
|
EventReceiveControllerChanged(NewController: Controller): void {
|
|
const AsPlayerController = CastToPlayController(NewController);
|
|
const Target = EnhancedInputLocalPlayerSubsystem(AsPlayerController);
|
|
|
|
AddMappingContext(Target, IMC_Default);
|
|
}
|
|
|
|
EnhancedInputActionIA_PrevDebugMode() {
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.PreviousPage();
|
|
}
|
|
}
|
|
|
|
EnhancedInputActionIA_NextDebugMode() {
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.NextPage();
|
|
}
|
|
}
|
|
|
|
EnhancedInputActionToggleHUD() {
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.ToggleDebugHUD();
|
|
}
|
|
}
|
|
|
|
EnhancedInputActionIA_ToggleVisualDebug() {
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.ToggleVisualDebug();
|
|
}
|
|
}
|
|
|
|
EventBeginPlay() {
|
|
this.MovementComponent.InitializeMovementSystem();
|
|
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.InitializeDebugHUD(this.MovementComponent);
|
|
this.ToastSystemComponent.InitializeToastSystem();
|
|
}
|
|
}
|
|
|
|
EventTick(DeltaTime: Float): void {
|
|
if (this.ShowDebugInfo) {
|
|
this.DebugHUDComponent.UpdateHUD(GetGameTimeInSeconds(), DeltaTime);
|
|
this.ToastSystemComponent.UpdateToastSystem();
|
|
}
|
|
}
|
|
}
|