This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
The-Powder-Toy/src/simulation/elements/GLAS.cpp
2023-04-16 22:13:39 +02:00

71 lines
1.5 KiB
C++

#include "simulation/ElementCommon.h"
static int update(UPDATE_FUNC_ARGS);
static void create(ELEMENT_CREATE_FUNC_ARGS);
void Element::Element_GLAS()
{
Identifier = "DEFAULT_PT_GLAS";
Name = "GLAS";
Colour = 0x404040_rgb .Pack();
MenuVisible = 1;
MenuSection = SC_SOLIDS;
Enabled = 1;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.90f;
Loss = 0.00f;
Collision = 0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 100;
HeatConduct = 150;
Description = "Glass. Meltable. Shatters under pressure, and refracts photons.";
Properties = TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW | PROP_SPARKSETTLE;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = 1973.0f;
HighTemperatureTransition = PT_LAVA;
Update = &update;
Create = &create;
}
static int update(UPDATE_FUNC_ARGS)
{
auto press = int(sim->pv[y/CELL][x/CELL] * 64);
auto diff = press - parts[i].tmp3;
// Determine whether the GLAS is chemically strengthened via .life setting. (250 = Max., 16 = Min.)
int strength = (parts[i].life / 120) + 16;
if (strength < 16)
strength = 16;
if (diff > strength || diff < -1 * strength)
{
sim->part_change_type(i, x, y, PT_BGLA);
}
parts[i].tmp3 = press;
return 0;
}
static void create(ELEMENT_CREATE_FUNC_ARGS)
{
sim->parts[i].tmp3 = int(sim->pv[y/CELL][x/CELL] * 64);
}