1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 static int graphics(GRAPHICS_FUNC_ARGS);
5 
Element_DLAY()6 void Element::Element_DLAY()
7 {
8 	Identifier = "DEFAULT_PT_DLAY";
9 	Name = "DLAY";
10 	Colour = PIXPACK(0x753590);
11 	MenuVisible = 1;
12 	MenuSection = SC_POWERED;
13 	Enabled = 1;
14 
15 	Advection = 0.0f;
16 	AirDrag = 0.00f * CFDS;
17 	AirLoss = 0.90f;
18 	Loss = 0.00f;
19 	Collision = 0.0f;
20 	Gravity = 0.0f;
21 	Diffusion = 0.00f;
22 	HotAir = 0.000f	* CFDS;
23 	Falldown = 0;
24 
25 	Flammable = 0;
26 	Explosive = 0;
27 	Meltable = 0;
28 	Hardness = 1;
29 
30 	Weight = 100;
31 
32 	DefaultProperties.temp = 4.0f + 273.15f;
33 	HeatConduct = 0;
34 	Description = "Conducts with temperature-dependent delay. (use HEAT/COOL).";
35 
36 	Properties = TYPE_SOLID;
37 
38 	LowPressure = IPL;
39 	LowPressureTransition = NT;
40 	HighPressure = IPH;
41 	HighPressureTransition = NT;
42 	LowTemperature = ITL;
43 	LowTemperatureTransition = NT;
44 	HighTemperature = ITH;
45 	HighTemperatureTransition = NT;
46 
47 	Update = &update;
48 	Graphics = &graphics;
49 }
50 
update(UPDATE_FUNC_ARGS)51 static int update(UPDATE_FUNC_ARGS)
52 {
53 	int r, rx, ry, oldl;
54 	oldl = parts[i].life;
55 	if (parts[i].life>0)
56 		parts[i].life--;
57 	if (parts[i].temp<= 1.0f+273.15f)
58 		parts[i].temp = 1.0f+273.15f;
59 	for (rx=-2; rx<3; rx++)
60 		for (ry=-2; ry<3; ry++)
61 			if (BOUNDS_CHECK && (rx || ry))
62 			{
63 				r = pmap[y+ry][x+rx];
64 				if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL)
65 					continue;
66 				if (TYP(r)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN)
67 				{
68 					parts[i].life = (int)(parts[i].temp-273.15f+0.5f);
69 				}
70 				else if (TYP(r)==PT_DLAY)
71 				{
72 					if (!parts[i].life)
73 					{
74 						if (parts[ID(r)].life)
75 						{
76 							parts[i].life = parts[ID(r)].life;
77 							if((ID(r))>i) //If the other particle hasn't been life updated
78 								parts[i].life--;
79 						}
80 					}
81 					else if (!parts[ID(r)].life)
82 					{
83 						parts[ID(r)].life = parts[i].life;
84 						if((ID(r))>i) //If the other particle hasn't been life updated
85 							parts[ID(r)].life++;
86 					}
87 				}
88 				else if(TYP(r)==PT_NSCN && oldl==1)
89 				{
90 					sim->create_part(-1, x+rx, y+ry, PT_SPRK);
91 				}
92 			}
93 	//}
94 	return 0;
95 }
96 
graphics(GRAPHICS_FUNC_ARGS)97 static int graphics(GRAPHICS_FUNC_ARGS)
98 {
99 	int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f);
100 	*colr += stage;
101 	*colg += stage;
102 	*colb += stage;
103 	return 0;
104 }
105