1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 static int graphics(GRAPHICS_FUNC_ARGS);
5 
Element_HSWC()6 void Element::Element_HSWC()
7 {
8 	Identifier = "DEFAULT_PT_HSWC";
9 	Name = "HSWC";
10 	Colour = PIXPACK(0x3B0A0A);
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 	HeatConduct = 251;
33 	Description = "Heat switch. Conducts heat only when activated.";
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 	Graphics = &graphics;
48 }
49 
update(UPDATE_FUNC_ARGS)50 static int update(UPDATE_FUNC_ARGS)
51 {
52 	int r, rx, ry;
53 	if (parts[i].life!=10)
54 	{
55 		if (parts[i].life>0)
56 			parts[i].life--;
57 	}
58 	else
59 	{
60 		bool deserializeTemp = parts[i].tmp == 1;
61 		for (rx=-2; rx<3; rx++)
62 			for (ry=-2; ry<3; ry++)
63 				if (BOUNDS_CHECK && (rx || ry))
64 				{
65 					r = pmap[y+ry][x+rx];
66 					if (!r)
67 						continue;
68 					if (TYP(r) == PT_HSWC)
69 					{
70 						if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
71 							parts[i].life = 9;
72 						else if (parts[ID(r)].life==0)
73 							parts[ID(r)].life = 10;
74 					}
75 					if (deserializeTemp && TYP(r) == PT_FILT)
76 					{
77 						if (rx >= -1 && rx <= 1 && ry >= -1 && ry <= 1)
78 						{
79 							int newTemp = parts[ID(r)].ctype - 0x10000000;
80 							if (newTemp >= MIN_TEMP && newTemp <= MAX_TEMP)
81 								parts[i].temp = parts[ID(r)].ctype - 0x10000000;
82 						}
83 					}
84 				}
85 	}
86 	return 0;
87 }
88 
graphics(GRAPHICS_FUNC_ARGS)89 static int graphics(GRAPHICS_FUNC_ARGS)
90 {
91 	int lifemod = ((cpart->life>10?10:cpart->life)*19);
92 	*colr += lifemod;
93 	return 0;
94 }
95