This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
The-Powder-Toy/src/simulation/elements/WTRV.cpp
2012-07-18 17:22:35 +01:00

73 lines
1.7 KiB
C++

#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_WTRV PT_WTRV 23
Element_WTRV::Element_WTRV()
{
Identifier = "DEFAULT_PT_WTRV";
Name = "WTRV";
Colour = PIXPACK(0xA0A0FF);
MenuVisible = 1;
MenuSection = SC_GAS;
Enabled = 1;
Advection = 1.0f;
AirDrag = 0.01f * CFDS;
AirLoss = 0.99f;
Loss = 0.30f;
Collision = -0.1f;
Gravity = -0.1f;
Diffusion = 0.75f;
HotAir = 0.0003f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 4;
Weight = 1;
Temperature = R_TEMP+100.0f+273.15f;
HeatConduct = 48;
Description = "Steam, heats up air, produced from hot water.";
State = ST_GAS;
Properties = TYPE_GAS;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = 371.0f;
LowTemperatureTransition = ST;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_WTRV::update;
}
//#TPT-Directive ElementHeader Element_WTRV static int update(UPDATE_FUNC_ARGS)
int Element_WTRV::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
parts[i].ctype = PT_WATR;
}
}
if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE)
parts[i].temp-=parts[i].temp/1000;
return 0;
}
Element_WTRV::~Element_WTRV() {}