diff --git a/src/simulation/elements/GRAV.cpp b/src/simulation/elements/GRAV.cpp index f112d247e..7b507261b 100644 --- a/src/simulation/elements/GRAV.cpp +++ b/src/simulation/elements/GRAV.cpp @@ -1,4 +1,5 @@ #include "simulation/Elements.h" + //#TPT-Directive ElementClass Element_GRAV PT_GRAV 102 Element_GRAV::Element_GRAV() { @@ -30,7 +31,7 @@ Element_GRAV::Element_GRAV() HeatConduct = 70; Description = "Very light dust. Changes colour based on velocity."; - Properties = TYPE_PART; + Properties = TYPE_PART | PROP_LIFE_DEC; LowPressure = IPL; LowPressureTransition = NT; @@ -41,12 +42,24 @@ Element_GRAV::Element_GRAV() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = NULL; + Update = &Element_GRAV::update; Graphics = &Element_GRAV::graphics; } + +//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS) +int Element_GRAV::update(UPDATE_FUNC_ARGS) +{ + if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && (rand() % 512) == 0) + { + if (!parts[i].life) + parts[i].life = 48; + } + + return 0; +} + //#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS) int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) - { int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2; @@ -87,6 +100,19 @@ int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) *colg -= (cpart->vy)*GRAV_G2; *colb -= (cpart->vy)*GRAV_B2; } + + if (cpart->life) + { + *pixel_mode = FIRE_ADD | PMODE_ADD | PMODE_GLOW | PMODE_FLARE; + *firer = std::min(*colr * 3, 255); + *fireg = std::min(*colg * 3, 255); + *fireb = std::min(*colb * 3, 255); + *firea = (cpart->life+15)*4; + *cola = (cpart->life+15)*4; + } + else + *pixel_mode = PMODE_ADD; + return 0; }