npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dao3fun/component

v1.0.0

Published

模拟Cocos,Untity等引擎的组件模式。

Downloads

69

Readme

BOX3引擎组件

模拟Cocos,Untity等引擎的组件模式。

文档介绍:https://docs.box3lab.com/arenapro/package/component/

/**
 * 抽象类Component,作为所有组件的基类
 * 定义了组件的基本属性和生命周期方法
 */
export default class Component {
    constructor(init?: {
        /** 组件的权重值,权重越大刷新优先级越高,默认为0  */
        weight?: number;
        /** 组件的总时间初始值,后续刷新间隔的毫秒数在此基础上累加,默认为0 */
        timeCount?: number;
    });
    /** 如果该组件第一次启用,则在组件 onUpdate 开始调用之前调用。<br/>
    * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
    */
    protected onStart(): void;
    /** 在组件 onStart 执行后,每帧(30ms)更新时调用。<br/>
     * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
     * @param {number} deltaTime - 两次调用之间的时间间隔
     */
    protected onUpdate(deltaTime: number): void;
    /** 启用组件时调用。<br/>
     * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
     */
    protected onEnable(): void;
    /** 禁用组件时调用。<br/>
     * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
     */
    protected onDisable(): void;
    /** 生命周期方法,当组件重置时调用。<br/>
     * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
    */
    protected onRestore(): void;
    /** 生命周期方法,当组件销毁时调用。<br/>
     * 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
    */
    protected onDestroy(): void;
    /**
     * 获取/设置当前组件的权重值
     * @returns {number} 当前组件的权重值
     */
    weight: number;
    /**
     * 获取/设置当前组件是否启用
     * @returns {boolean} 组件的启用状态
     */
    enable: boolean;
    /**
     * 获取/设置当前组件的时间总时间值
     * @returns {number} 当前的总时间
     */
    timeCount: number;
    /**
     * 获取当前组件的禁用次数
     * @returns {number} 当前组件的禁用次数
     */
    readonly disableCount: number;
    /**
     * 获取当前组件的重置次数
     * @returns {number} 当前组件的重置次数
     */
    readonly restoreCount: number;
    /**
     * 获取当前组件的启用次数
     * @returns {number} 当前组件的启用次数
     */
    readonly enableCount: number;
    /**
     * 销毁组件
     * @returns 如果组件已启动,则销毁组件并返回true,否则返回false
     */
    destroy(): boolean;
    /**
     * 重置组件,组件不会干预重置权重,总时间等预设值。
     */
    restore(): void;
}