2012-05-07 11:59:50 -05:00
|
|
|
#include "simulation/Elements.h"
|
|
|
|
//#TPT-Directive ElementClass Element_PHOT PT_PHOT 31
|
|
|
|
Element_PHOT::Element_PHOT()
|
|
|
|
{
|
2013-03-13 14:54:34 -05:00
|
|
|
Identifier = "DEFAULT_PT_PHOT";
|
|
|
|
Name = "PHOT";
|
|
|
|
Colour = PIXPACK(0xFFFFFF);
|
|
|
|
MenuVisible = 1;
|
|
|
|
MenuSection = SC_NUCLEAR;
|
|
|
|
Enabled = 1;
|
|
|
|
|
|
|
|
Advection = 0.0f;
|
|
|
|
AirDrag = 0.00f * CFDS;
|
|
|
|
AirLoss = 1.00f;
|
|
|
|
Loss = 1.00f;
|
|
|
|
Collision = -0.99f;
|
|
|
|
Gravity = 0.0f;
|
|
|
|
Diffusion = 0.00f;
|
|
|
|
HotAir = 0.000f * CFDS;
|
|
|
|
Falldown = 0;
|
|
|
|
|
|
|
|
Flammable = 0;
|
|
|
|
Explosive = 0;
|
|
|
|
Meltable = 0;
|
|
|
|
Hardness = 0;
|
|
|
|
|
|
|
|
Weight = -1;
|
|
|
|
|
|
|
|
Temperature = R_TEMP+900.0f+273.15f;
|
|
|
|
HeatConduct = 251;
|
2013-05-03 21:42:36 -05:00
|
|
|
Description = "Photons. Refracts through glass, scattered by quartz, and color-changed by different elements. Ignites flammable materials.";
|
2013-03-13 14:54:34 -05:00
|
|
|
|
|
|
|
State = ST_GAS;
|
|
|
|
Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC;
|
|
|
|
|
|
|
|
LowPressure = IPL;
|
|
|
|
LowPressureTransition = NT;
|
|
|
|
HighPressure = IPH;
|
|
|
|
HighPressureTransition = NT;
|
|
|
|
LowTemperature = ITL;
|
|
|
|
LowTemperatureTransition = NT;
|
|
|
|
HighTemperature = ITH;
|
|
|
|
HighTemperatureTransition = NT;
|
|
|
|
|
|
|
|
Update = &Element_PHOT::update;
|
|
|
|
Graphics = &Element_PHOT::graphics;
|
2012-05-07 11:59:50 -05:00
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
|
2012-05-07 11:59:50 -05:00
|
|
|
//#TPT-Directive ElementHeader Element_PHOT static int update(UPDATE_FUNC_ARGS)
|
|
|
|
int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
|
|
|
{
|
2013-09-11 19:41:43 -05:00
|
|
|
int r, rx, ry;
|
2012-01-08 11:39:03 -06:00
|
|
|
float rr, rrr;
|
2012-04-17 10:33:04 -05:00
|
|
|
if (!(parts[i].ctype&0x3FFFFFFF)) {
|
2012-01-08 11:39:03 -06:00
|
|
|
sim->kill_part(i);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-08-28 09:09:32 -05:00
|
|
|
if (parts[i].temp > 506)
|
2013-02-27 16:20:05 -06:00
|
|
|
if (!(rand()%10)) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
|
2012-01-08 11:39:03 -06:00
|
|
|
for (rx=-1; rx<2; rx++)
|
|
|
|
for (ry=-1; ry<2; ry++)
|
2013-03-13 14:54:34 -05:00
|
|
|
if (BOUNDS_CHECK) {
|
2012-01-08 11:39:03 -06:00
|
|
|
r = pmap[y+ry][x+rx];
|
|
|
|
if (!r)
|
|
|
|
continue;
|
2013-03-01 23:42:07 -06:00
|
|
|
if ((r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS)
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2013-03-01 23:42:07 -06:00
|
|
|
if (!(rand()%400))
|
|
|
|
{
|
|
|
|
parts[i].vx *= 0.90;
|
|
|
|
parts[i].vy *= 0.90;
|
|
|
|
sim->create_part(r>>8, x+rx, y+ry, PT_PHOT);
|
|
|
|
rrr = (rand()%360)*3.14159f/180.0f;
|
2014-11-14 11:47:51 -06:00
|
|
|
if ((r&0xFF) == PT_ISOZ)
|
|
|
|
rr = (rand()%128+128)/127.0f;
|
|
|
|
else
|
|
|
|
rr = (rand()%228+128)/127.0f;
|
2013-03-01 23:42:07 -06:00
|
|
|
parts[r>>8].vx = rr*cosf(rrr);
|
|
|
|
parts[r>>8].vy = rr*sinf(rrr);
|
|
|
|
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
|
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
2013-03-01 23:42:07 -06:00
|
|
|
else if((r&0xFF) == PT_QRTZ && !ry && !rx)//if on QRTZ
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2013-03-01 23:42:07 -06:00
|
|
|
float a = (rand()%360)*3.14159f/180.0f;
|
|
|
|
parts[i].vx = 3.0f*cosf(a);
|
|
|
|
parts[i].vy = 3.0f*sinf(a);
|
|
|
|
if(parts[i].ctype == 0x3FFFFFFF)
|
|
|
|
parts[i].ctype = 0x1F<<(rand()%26);
|
|
|
|
parts[i].life++; //Delay death
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
2013-08-29 12:28:49 -05:00
|
|
|
else if ((r&0xFF) == PT_FILT && parts[r>>8].tmp==9)
|
|
|
|
{
|
|
|
|
parts[i].vx += ((float)(rand()%1000-500))/1000.0f;
|
|
|
|
parts[i].vy += ((float)(rand()%1000-500))/1000.0f;
|
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-07 11:59:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
//#TPT-Directive ElementHeader Element_PHOT static int graphics(GRAPHICS_FUNC_ARGS)
|
|
|
|
int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS)
|
|
|
|
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
*colr = *colg = *colb = 0;
|
|
|
|
for (x=0; x<12; x++) {
|
|
|
|
*colr += (cpart->ctype >> (x+18)) & 1;
|
|
|
|
*colb += (cpart->ctype >> x) & 1;
|
|
|
|
}
|
|
|
|
for (x=0; x<12; x++)
|
|
|
|
*colg += (cpart->ctype >> (x+9)) & 1;
|
|
|
|
x = 624/(*colr+*colg+*colb+1);
|
|
|
|
*colr *= x;
|
|
|
|
*colg *= x;
|
|
|
|
*colb *= x;
|
|
|
|
|
|
|
|
*firea = 100;
|
|
|
|
*firer = *colr;
|
|
|
|
*fireg = *colg;
|
|
|
|
*fireb = *colb;
|
|
|
|
|
2012-10-01 15:54:52 -05:00
|
|
|
*pixel_mode &= ~PMODE_FLAT;
|
2014-05-22 19:06:09 -05:00
|
|
|
*pixel_mode |= FIRE_ADD | PMODE_ADD | NO_DECO;
|
2014-08-05 16:09:34 -05:00
|
|
|
if (cpart->flags & FLAG_PHOTDECO)
|
|
|
|
{
|
|
|
|
*pixel_mode &= ~NO_DECO;
|
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-07 11:59:50 -05:00
|
|
|
|
|
|
|
|
2013-02-27 16:20:05 -06:00
|
|
|
Element_PHOT::~Element_PHOT() {}
|