• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ trap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中trap的典型用法代码示例。如果您正苦于以下问题:C++ trap类的具体用法?C++ trap怎么用?C++ trap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了trap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: retroactively_fill_from_funnel

/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    rainfall_data rainfall = get_rainfall( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( rainfall.rain_amount > 0 ) {
        // This is kinda weird: we're dumping a "block" of water all at once
        // but the old formula ( rain_turns / turn_per_charge(total_amount) ) resulted in
        // water being produced at quadratic rate rather than linear with time
        const int rain = 1.0 / tr.funnel_turns_per_charge( rainfall.rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( rainfall.acid_amount > 0 ) {
        const int acid = 1.0 / tr.funnel_turns_per_charge( rainfall.acid_amount );
        it.add_rain_to_container( true, acid );
    }
}
开发者ID:0x90sled,项目名称:Cataclysm-DDA,代码行数:29,代码来源:weather.cpp


示例2: retroactively_fill_from_funnel

/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }
    it.bday = endturn; // bday == last fill check
    int rain_amount = 0;
    int acid_amount = 0;
    int rain_turns = 0;
    int acid_turns = 0;
    for( calendar turn(startturn); turn < endturn; turn += 10) {
        // TODO: Z-level weather
        switch(g->weatherGen.get_weather_conditions(point(location.x, location.y), turn)) {
        case WEATHER_DRIZZLE:
            rain_amount += 4;
            rain_turns++;
            break;
        case WEATHER_RAINY:
        case WEATHER_THUNDER:
        case WEATHER_LIGHTNING:
            rain_amount += 8;
            rain_turns++;
            break;
        case WEATHER_ACID_DRIZZLE:
            acid_amount += 4;
            acid_turns++;
            break;
        case WEATHER_ACID_RAIN:
            acid_amount += 8;
            acid_turns++;
            break;
        default:
            break;
        }
    }

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( rain_amount > 0 ) {
        int rain = rain_turns / tr.funnel_turns_per_charge( rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( acid_amount > 0 ) {
        int acid = acid_turns / tr.funnel_turns_per_charge( acid_amount );
        it.add_rain_to_container( true, acid );
    }
}
开发者ID:Acherontius,项目名称:Cataclysm-DDA,代码行数:53,代码来源:weather.cpp


示例3: fill_funnels

/**
 * Main routine for filling funnels from weather effects.
 */
void fill_funnels(int rain_depth_mm_per_hour, bool acid, const trap &tr)
{
    const double turns_per_charge = tr.funnel_turns_per_charge(rain_depth_mm_per_hour);
    // Give each funnel on the map a chance to collect the rain.
    const auto &funnel_locs = g->m.trap_locations( tr.loadid );
    for( auto loc : funnel_locs ) {
        int maxcontains = 0;
        auto items = g->m.i_at( loc );
        if (one_in(turns_per_charge)) { // todo; fixme. todo; fixme
            //add_msg("%d mm/h %d tps %.4f: fill",int(calendar::turn),rain_depth_mm_per_hour,turns_per_charge);
            // This funnel has collected some rain! Put the rain in the largest
            // container here which is either empty or contains some mixture of
            // impure water and acid.
            auto container = items.end();
            for( auto candidate_container = items.begin(); candidate_container != items.end();
                 ++candidate_container ) {
                if ( candidate_container->is_funnel_container( maxcontains ) ) {
                    container = candidate_container;
                }
            }

            if( container != items.end() ) {
                container->add_rain_to_container(acid, 1);
                container->bday = int(calendar::turn);
            }
        }
    }
}
开发者ID:0x90sled,项目名称:Cataclysm-DDA,代码行数:31,代码来源:weather.cpp


示例4: retroactively_fill_from_funnel

/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, int startturn, int endturn,
                                     const tripoint &location )
{
    if( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.rain_amount ), 1.0f );
        it.add_rain_to_container( false, rain );
        // add_msg(m_debug, "Retroactively adding %d water from turn %d to %d", rain, startturn, endturn);
    }

    if( data.acid_amount > 0 ) {
        const int acid = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.acid_amount ), 1.0f );
        it.add_rain_to_container( true, acid );
    }
}
开发者ID:Bubbadoo,项目名称:Cataclysm-DDA,代码行数:25,代码来源:weather.cpp


示例5: retroactively_fill_from_funnel

/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = 1.0 / tr.funnel_turns_per_charge( data.rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( data.acid_amount > 0 ) {
        const int acid = 1.0 / tr.funnel_turns_per_charge( data.acid_amount );
        it.add_rain_to_container( true, acid );
    }
}
开发者ID:pipehat,项目名称:Cataclysm-DDA,代码行数:26,代码来源:weather.cpp



注:本文中的trap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ tree类代码示例发布时间:2022-05-31
下一篇:
C++ transform_iterator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap