1 #include "simulation/ElementCommon.h" 2 3 static int update(UPDATE_FUNC_ARGS); 4 Element_RPEL()5void Element::Element_RPEL() 6 { 7 Identifier = "DEFAULT_PT_RPEL"; 8 Name = "RPEL"; 9 Colour = PIXPACK(0x99CC00); 10 MenuVisible = 1; 11 MenuSection = SC_FORCE; 12 Enabled = 1; 13 14 Advection = 0.0f; 15 AirDrag = 0.00f * CFDS; 16 AirLoss = 0.90f; 17 Loss = 0.00f; 18 Collision = 0.0f; 19 Gravity = 0.0f; 20 Diffusion = 0.00f; 21 HotAir = 0.000f * CFDS; 22 Falldown = 0; 23 24 Flammable = 0; 25 Explosive = 0; 26 Meltable = 0; 27 Hardness = 1; 28 29 Weight = 100; 30 31 DefaultProperties.temp = 20.0f + 273.15f; 32 HeatConduct = 0; 33 Description = "Repels or attracts particles based on its temperature."; 34 35 Properties = TYPE_SOLID; 36 37 LowPressure = IPL; 38 LowPressureTransition = NT; 39 HighPressure = IPH; 40 HighPressureTransition = NT; 41 LowTemperature = ITL; 42 LowTemperatureTransition = NT; 43 HighTemperature = ITH; 44 HighTemperatureTransition = NT; 45 46 Update = &update; 47 CtypeDraw = &Element::basicCtypeDraw; 48 } 49 update(UPDATE_FUNC_ARGS)50static int update(UPDATE_FUNC_ARGS) 51 { 52 int r, rx, ry, ri; 53 for(ri = 0; ri <= 10; ri++) 54 { 55 rx = RNG::Ref().between(-10, 10); 56 ry = RNG::Ref().between(-10, 10); 57 if (x+rx >= 0 && x+rx < XRES && y+ry >= 0 && y+ry < YRES && (rx || ry)) 58 { 59 r = pmap[y+ry][x+rx]; 60 if (!r) 61 r = sim->photons[y+ry][x+rx]; 62 63 if (r && !(sim->elements[TYP(r)].Properties & TYPE_SOLID)) { 64 if (!parts[i].ctype || parts[i].ctype == parts[ID(r)].type) { 65 parts[ID(r)].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); 66 parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); 67 } 68 } 69 } 70 } 71 return 0; 72 } 73