import { GameObject } from "./GameObject"; import { Container as PIXIContainer, Container as DisplayObject, FederatedEvent as PIXIInteractionEvent, ObservablePoint, Sprite, Container } from "pixi.js"; import { InteractionEvent } from "./Types/InteractionEvent"; import { Engine } from "./Engine"; import { DIRECTION } from "./Types/Direction"; import { IVector2 } from "./Types/IVector2"; import * as TWEEN from '@tweenjs/tween.js'; import { Vector2 } from "../lib/Vector2"; import { TWEENDirection, TWEENFunctions } from "./HelperFunctions/TWEENFunctions"; export interface TooltipProperties { x: number; y: number; width: number; height: number; title: string; body: string; dontAddToUI?: boolean; } export interface ITweenAnimationReturnValue { cancel: () => void; progress: number; promise: Promise; } export declare class HelperFunctions { constructor(); static isWebAssemblySupported(): boolean; static traverseChildren

(baseObject: P | C, funcToCall: (e: C) => void): void; static createCloseButton(): Sprite; static findPropByHierarchy(_targetHierarchy: string, _startingNode: GameObject, _hierarchyIndex?: number): GameObject | null; /** * Scales a target object based on specified width/height. * Use `null` in the targetSize object to scale with the other axis * Example: smartScale2D({x: 100, y: null}, aSprite); * @param targetSize IVector2 In pixels; width/height * @param obj PIXI.Sprite */ static smartScale2D(targetSize: IVector2, // obj: Sprite | Container): void; static roundToSpecifiedDivider(num: number, div: number): number; static isPromise(p: any): boolean; static stopAllSoundsOfId(id: string): void; static playSound_s(id: string, options?: { [key: string]: any; }): Promise; static playSound(id: string, options?: { [key: string]: any; }): Promise; static getDirectionFromOffset(_offset: IVector2): DIRECTION; /** * * @param func Function which returns a boolean (if true, resolve the promise) * @param refreshRateMs Optional: how often in ms to call `func` * @param maxAttempts Optional: how many attempts before rejecting (if zero, go infinitely) */ static waitForTruth(func: () => boolean, refreshRateMs?: number, maxAttempts?: number): Promise; /** * Returns array of enum keys * @author https://www.petermorlion.com/iterating-a-typescript-enum/ * @param obj */ static enumKeys(obj: O): K[]; static roundToDecimalPlaces(num: number, decimalPlaces?: number): number; static getMainCanvasElement(): HTMLCanvasElement; static clamp(val: number, min: number, max: number): number; static makeInteractive(_obj: DisplayObject, _skipButtonMode?: boolean): void; static makeUninteractive(_obj: DisplayObject): void; static parseInteractionEvent(ev: PIXIInteractionEvent, canvasWidth?: number, canvasHeight?: number): IVector2; static getUICanvas(): HTMLCanvasElement; static calculateScaleFactor(_screenSize: IVector2): number; static deg2rad(num: number): number; static rad2deg(num: number): number; static randomRange(min: number | IVector2, max?: number): number; static removeFromStage(stage: Container, obj: DisplayObject | GameObject, unsafe?: boolean): void; static addToStage(stage: Container, obj: GameObject | Container | DisplayObject): void; static formatTimeToHHMMSS(_time: number): string; /** * Modified from https://stackoverflow.com/questions/29816872/how-can-i-convert-milliseconds-to-hhmmss-format-using-javascript * @param _time */ static formatTimeToMMSS(_time: number): string; static addToStage2D(stage: Container, obj: DisplayObject | GameObject, unsafe?: boolean): void; static shakeObject(_target: Vector2, _iterations?: number): Promise; static rotateIVec2(_input: IVector2, _degrees: number): IVector2; static getDirectionOfSwipe(_pointerUpEvent: PIXIInteractionEvent, _pointerDownPos: IVector2 | PIXIInteractionEvent, _scrSize?: IVector2): DIRECTION; static lerp(v0: number, v1: number, t: number): number; static setPositionWithConstraint(_target: IVector2, _newVal: IVector2, _min: IVector2, _max: IVector2): void; static TWEENVec2AsPromise(_target: Vector2 | ObservablePoint | IVector2, _destVal: Vector2 | ObservablePoint | IVector2, _func: typeof TWEEN.Easing.Linear.None | { function: TWEENFunctions; direction: TWEENDirection; }, _duration?: number, _onTick?: (obj?: any, elapsed?: number) => boolean): ITweenAnimationReturnValue; /** * NOTE: There is no protection against calling `await` on this function * So if you wonder why your animation finishes instantly, it's because you * need to `await TWEENAsPromise(...).promise`. * @param _target * @param _key * @param _destVal * @param _func * @param _duration * @param _onTick * @param _postTick * @constructor */ static TWEENAsPromise(_target: any, _key: string, _destVal: number, _func: typeof TWEEN.Easing.Linear.None | { function: TWEENFunctions; direction: TWEENDirection; }, _duration?: number, _onTick?: (obj?: any, elapsed?: number) => boolean, _postTick?: (obj?: any, elapsed?: number) => void): ITweenAnimationReturnValue; static tryGetPIXIResource(_key: string, _refreshRate?: number, _maxAttempts?: number): Promise; static easeInBack(x: number): number; static tweenScalarPromise(_target: any, _key: string, _destValue: number, _tweenFunc?: (v0: number, v1: number, t: number) => number, _speed?: number, _engine?: Engine): Promise; static wait(ms: number): Promise; /** * @deprecated Use `HelperFunctions.TWEENVec3AsPromise` * @param _sprite * @param _destination * @param _duration */ static lerpToPromise(_sprite: Vector2 | ObservablePoint, _destination: { x: number; y: number; z?: number; }, _duration?: number): Promise; /** * @param self * @param propKey */ static createInteractionEvent(self: object, propKey: string): InteractionEvent; static isGameObject(obj: unknown): boolean; static isDisplayObject(obj: unknown): boolean; }