#include "simulation/Elements.h" Element::Element(): Identifier("DEFAULT_INVALID"), Name(""), Colour(PIXPACK(0xFF00FF)), MenuVisible(0), MenuSection(0), Enabled(0), Advection(0.0f), AirDrag(-0.0f * CFDS), AirLoss(1.0f), Loss(1.0f), Collision(0.0f), Gravity(0.0f), Diffusion(0.0f), HotAir(0.0f * CFDS), Falldown(0), Flammable(0), Explosive(0), Meltable(0), Hardness(30), Weight(50), Temperature(273.15f), HeatConduct(128), Description("No description"), State(ST_SOLID), Properties(TYPE_SOLID), LowPressure(IPL), LowPressureTransition(NT), HighPressure(IPH), HighPressureTransition(NT), LowTemperature(ITL), LowTemperatureTransition(NT), HighTemperature(ITH), HighTemperatureTransition(NT), Update(NULL), Graphics(&Element::defaultGraphics), IconGenerator(NULL) { } int Element::legacyUpdate(UPDATE_FUNC_ARGS) { int r, rx, ry, rt; int t = parts[i].type; if (t==PT_WTRV) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) { sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); } if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) { sim->part_change_type(i,x,y,PT_WATR); if (1>(rand()%1000)) sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); } } } else if (t==PT_WATR) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%10)) { sim->part_change_type(i,x,y,PT_WTRV); } } } else if (t==PT_SLTW) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%10)) { if (rand()%4==0) sim->part_change_type(i,x,y,PT_SALT); else sim->part_change_type(i,x,y,PT_WTRV); } } } else if (t==PT_DSTW) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%10)) { sim->part_change_type(i,x,y,PT_WTRV); } } } else if (t==PT_ICEI) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) { sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); } } } else if (t==PT_SNOW) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) { sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); } if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) sim->part_change_type(i,x,y,PT_WATR); } } if (t==PT_WTRV && sim->pv[y/CELL][x/CELL]>4.0f) sim->part_change_type(i,x,y,PT_DSTW); if (t==PT_OIL && sim->pv[y/CELL][x/CELL]<-6.0f) sim->part_change_type(i,x,y,PT_GAS); if (t==PT_GAS && sim->pv[y/CELL][x/CELL]>6.0f) sim->part_change_type(i,x,y,PT_OIL); if (t==PT_DESL && sim->pv[y/CELL][x/CELL]>12.0f) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = rand()%50+120; } return 0; } int Element::defaultGraphics(GRAPHICS_FUNC_ARGS) { int t = cpart->type; //Property based defaults if(ren->sim->elements[t].Properties & PROP_RADIOACTIVE) *pixel_mode |= PMODE_GLOW; if(ren->sim->elements[t].Properties & TYPE_LIQUID) { *pixel_mode |= PMODE_BLUR; } if(ren->sim->elements[t].Properties & TYPE_GAS) { *pixel_mode &= ~PMODE; *pixel_mode |= FIRE_BLEND; *firer = *colr/2; *fireg = *colg/2; *fireb = *colb/2; *firea = 125; *pixel_mode |= DECO_FIRE; } return 1; }