• map初始化定时器


    init_timer();    
    //各种定时器的初始化
    void Map::init_timer()
    {
        //auto tf = GetPlug(TimerFactory);
        auto tf = m_spTimerFactory;
        m_updateMovePosTimer.reset(tf->createTimer());
        m_updateMovePosTimer->setInterval(50);
        m_updateMovePosTimer->regTimer(std::bind(&Map::updateMovePosTimer, this));//这个是最重要的定时跟新所有NCP的位置信息,50ms是相当快的
        m_updateMovePosTimer->start();
    
        //单人组队定时
        m_updateTeamTimer.reset(tf->createTimer());
        m_updateTeamTimer->setInterval(15 * 1000);
        m_updateTeamTimer->regTimer(std::bind(&Map::updateTeamTimer, this));
        m_updateTeamTimer->start();
    
        //宝物限时消失
        //m_checkPropExistTimer.reset(tf->createTimer());
        //m_checkPropExistTimer->setInterval(10 * 6000);
        //m_checkPropExistTimer->regTimer(std::bind(&Map::checkPropExistTimer, this));
        ////m_checkPropExistTimer->start();
    
        //定时器监视buff
        m_updateStatTimer.reset(tf->createTimer());
        m_updateStatTimer->setInterval(1000);
        m_updateStatTimer->regTimer(std::bind(&Map::updateStatTimer, this));
        m_updateStatTimer->start();
    
        //压测复活
        m_checkRebornTimer.reset(tf->createTimer());
        m_checkRebornTimer->setInterval(2000);
        m_checkRebornTimer->regTimer(std::bind(&Map::checkRebornTimer, this));
        m_checkRebornTimer->start();
    
        //Item 消失
        m_updateItemDisappearTimer.reset(tf->createTimer());
        m_updateItemDisappearTimer->setInterval(2000);
        m_updateItemDisappearTimer->regTimer(std::bind(&Map::updateItemDisappearTimer, this));
        m_updateItemDisappearTimer->start();
    
        //Spell消失(因玩家而定) + 施法
        m_updateSpellWorkTimer.reset(tf->createTimer());
        m_updateSpellWorkTimer->setInterval(500);
        m_updateSpellWorkTimer->regTimer(std::bind(&Map::updateSpellWorkTimer, this));
        m_updateSpellWorkTimer->start();
    
    
    }
    //-------------------这所有的定时器都是map线程驱动的--------------------------
  • 相关阅读:
    Jenkins分享
    Java静态绑定和动态绑定
    SpringBoot中RedisTemplate订阅发布对象
    Idea项目:Failed to create a Maven project ‘…pom.xml’ already exists in VFS 解决
    Java Web不能不懂的知识
    Required String parameter 'id' is not present
    Hive使用druid做连接池代码实现
    Docker Toolbox常见错误解决方案
    初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)
    SpringMVC日志管理(自定义异常及自定义注解)
  • 原文地址:https://www.cnblogs.com/zzyoucan/p/3945837.html
Copyright © 2020-2023  润新知