tengri/Content/UE/SystemLibrary.ts

56 lines
1.6 KiB
TypeScript

// UE/SystemLibrary.ts
import { BlueprintFunctionLibrary } from '#root/UE/BlueprintFunctionLibrary.ts';
import type { Float } from '#root/UE/Float.ts';
import { LinearColor } from '#root/UE/LinearColor.ts';
import { Name } from '#root/UE/Name.ts';
import type { UEObject } from '#root/UE/UEObject.ts';
class SystemLibraryClass extends BlueprintFunctionLibrary {
constructor(
outer: null | BlueprintFunctionLibrary = null,
name: string = 'SystemLibrary'
) {
super(outer, name);
}
public IsValid<T extends UEObject>(
object: T | null | undefined
): object is T {
return object !== null && object !== undefined;
}
public GetGameTimeInSeconds(): number {
// Placeholder implementation; replace with actual game time retrieval logic
return Date.now() / 1000;
}
public PrintString(
string: string = 'Hello',
printToScreen: boolean = true,
printToLog: boolean = true,
textColor: LinearColor = new LinearColor(0, 0.66, 1, 1),
duration: Float = 2.0,
key: Name = Name.NONE
): void {
if (printToScreen) {
console.log(
`%c${string}`,
`color: rgba(${textColor.R * 255}, ${textColor.G * 255}, ${
textColor.B * 255
}, ${textColor.A}); font-weight: bold;`
);
// In a real game engine, this would display the string on the screen for the specified duration
}
if (printToLog) {
console.log(string);
// In a real game engine, this would log the string to the console or log file
}
console.log(duration);
console.log(key);
}
}
export const SystemLibrary = new SystemLibraryClass();