UNPKG

@fivem-ts/shared

Version:

FiveM Typescript wrapper shared part

34 lines (33 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Tick = Tick; /** * A decorator that schedules a method to be executed every game tick. * * The `@Tick` decorator registers the decorated method to be executed on each game tick. This is particularly useful * where a method needs to be run continuously at every update cycle. * * @example * ```ts * class GameLogic { * @Tick * public update() { * console.log('Updating game state...'); * } * } * * const game = new GameLogic(); * // The `update` method will now be called on every game tick. * ``` * * @param _target The prototype of the class. * @param propertyKey The name of the method being decorated. * @param descriptor The property descriptor for the method. */ function Tick(_target, propertyKey, descriptor) { const originalMethod = descriptor.value; setTick(() => { originalMethod(); }); console.log(`Registered tick for function: ${propertyKey}`); }