本文整理汇总了C++中item::add_rain_to_container方法的典型用法代码示例。如果您正苦于以下问题:C++ item::add_rain_to_container方法的具体用法?C++ item::add_rain_to_container怎么用?C++ item::add_rain_to_container使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::add_rain_to_container方法的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 );
}
}
示例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 );
}
}
示例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 );
}
}
示例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 );
}
}