tdog442

Anti-spark for Powder Toy

May 25th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. #include "varpmap.h"
  3. //#TPT-Directive ElementClass Element_ASPK PT_ASPK 178
  4. Element_ASPK::Element_ASPK()
  5. {
  6. Identifier = "DEFAULT_PT_ASPK";
  7. Name = "ASPK";
  8. Colour = PIXPACK(0x5cb8ff);
  9. MenuVisible = 1;
  10. MenuSection = SC_ELEC;
  11. Enabled = 1;
  12.  
  13. Advection = 0.4f;
  14. AirDrag = 0.04f * CFDS;
  15. AirLoss = 0.94f;
  16. Loss = 0.95f;
  17. Collision = -0.1f;
  18. Gravity = 0.18f;
  19. Diffusion = 0.00f;
  20. HotAir = 0.000f * CFDS;
  21. Falldown = 1;
  22.  
  23. Flammable = 0;
  24. Explosive = 0;
  25. Meltable = 2;
  26. Hardness = 2;
  27.  
  28. Weight = 90;
  29.  
  30. Temperature = R_TEMP+0.0f +273.15f;
  31. HeatConduct = 211;
  32. Description = "Anti-spark. Inhibits conductors on contact.";
  33.  
  34. State = ST_SOLID;
  35. Properties = TYPE_PART|PROP_LIFE_DEC;
  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 = &Element_ASPK::update;
  47.  
  48. }
  49.  
  50. //#TPT-Directive ElementHeader Element_ASPK static int update(UPDATE_FUNC_ARGS)
  51. int Element_ASPK::update(UPDATE_FUNC_ARGS)
  52. {
  53. int r, rx, ry, rt, a, a1, b, b1;
  54. a = xpmap(parts[i].tmp);
  55. b = xmax();
  56. a1 = ypmap(parts[i].tmp2, parts[i].ctype);
  57. b1 = ymax();
  58. for (rx=a; rx<b; rx++)
  59. for (ry=a1; ry<b1; ry++)
  60. if (BOUNDS_CHECK)
  61. {
  62. r = sim->photons[y+ry][x+rx];
  63. if (!r)
  64. r = pmap[y+ry][x+rx];
  65. if (!r)
  66. continue;
  67. if(parts[i].tmp<=0) parts[i].tmp = 1;
  68. if((r&0xFF)==PT_SPRK)
  69. {
  70. sim->part_change_type(r>>8, x+rx, y+ry, parts[r>>8].ctype);
  71. }
  72. if((r&0xFF)==PT_INST && parts[r>>8].life < 4)
  73. {
  74. parts[r>>8].life=4;
  75. }
  76. if((r&0xFF)==PT_FELE) sim->kill_part(r>>8);
  77. if((r&0xFF)==PT_WIRE && parts[r>>8].ctype!=PT_NONE)
  78. {
  79. parts[r>>8].ctype = PT_NONE;
  80. }
  81. if(a||b||a1||b1 == 0)
  82. {
  83. std::cout << "System Malfunction. Computational Error in varpmap header. Self-terminate.\n";
  84. system("pause");
  85. sim->kill_part(i);
  86. return 1;
  87. }
  88. }
  89. return(0);
  90. }
  91.  
  92. Element_ASPK::~Element_ASPK() {}
Advertisement
Add Comment
Please, Sign In to add comment