当前位置: 首页>>代码示例>>C++>>正文


C++ trap::is_funnel方法代码示例

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


在下文中一共展示了trap::is_funnel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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