1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_ELEC PT_ELEC 136
Element_ELEC::Element_ELEC()
{
Identifier = "DEFAULT_PT_ELEC";
Name = "ELEC";
Colour = PIXPACK(0xDFEFFF);
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+200.0f+273.15f;
HeatConduct = 251;
Description = "Electrons";
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_ELEC::update;
Graphics = &Element_ELEC::graphics;
}
//#TPT-Directive ElementHeader Element_ELEC static int update(UPDATE_FUNC_ARGS)
int Element_ELEC::update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry, nb, rrx, rry;
parts[i].pavg[0] = x;
parts[i].pavg[1] = y;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
rt = r&0xFF;
switch (rt)
{
case PT_GLAS:
for (rrx=-1; rrx<=1; rrx++)
for (rry=-1; rry<=1; rry++)
if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) {
nb = sim->create_part(-1, x+rx+rrx, y+ry+rry, PT_EMBR);
if (nb!=-1) {
parts[nb].tmp = 0;
parts[nb].life = 50;
parts[nb].temp = parts[i].temp*0.8f;
parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10;
}
}
sim->kill_part(i);
return 1;
case PT_LCRY:
parts[r>>8].tmp2 = 5+rand()%5;
break;
case PT_WATR:
case PT_DSTW:
case PT_SLTW:
case PT_CBNW:
if(!(rand()%3))
sim->create_part(r>>8, x+rx, y+ry, PT_O2);
else
sim->create_part(r>>8, x+rx, y+ry, PT_H2);
return 1;
case PT_NEUT:
sim->part_change_type(r>>8, x+rx, y+ry, PT_H2);
parts[r>>8].life = 0;
parts[r>>8].ctype = 0;
break;
case PT_DEUT:
if(parts[r>>8].life < 6000)
parts[r>>8].life += 1;
parts[r>>8].temp = 0;
sim->kill_part(i);
return 1;
case PT_EXOT:
parts[r>>8].tmp2 += 5;
parts[r>>8].life = 1000;
break;
case PT_GLOW:
if (!rx && !ry)//if on GLOW
sim->part_change_type(i, x, y, PT_PHOT);
break;
case PT_NONE: //seems to speed up ELEC even if it isn't used
break;
default:
if ((sim->elements[rt].Properties & PROP_CONDUCTS) && (rt!=PT_NBLE||parts[i].temp<2273.15))
{
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
sim->kill_part(i);
return 1;
}
break;
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_ELEC static int graphics(GRAPHICS_FUNC_ARGS)
int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS)
{
*firea = 70;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode |= FIRE_ADD;
return 0;
}
Element_ELEC::~Element_ELEC() {}
|