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/LAVA.cpp
Tamás Bálint Misius a13c29875f
Don't mangle custom element types in life, ctype, tmp{,2,3,4}
Achieved by adding a new element property called CarriesTypeIn, whose bits signal to save loading code which properties of particles of the element class in question carry element IDs. The bits in this property are numbered the same way as sim.FIELD_* constants for consistency. One would signal from Lua that a custom element carries element IDs in its tmp like this:

	elem.property(id, "CarriesTypeIn", 2 ^ sim.FIELD_TMP)

"Carrying an element ID in a property" is to be interpreted as follows: the property is treated as a combination of a PMAPBITS-bit (so, currently 9-bit) unsigned integer lower part holding an element ID and a 32-PMAPBITS-bit (so, currently 23-bit) signed integer upper part holding whatever makes sense for the element. CONV, for example, uses this signed integer in its ctype as the extra "v" parameter for particle creation.
2023-02-28 12:43:45 +01:00

77 lines
1.7 KiB
C++

#include "simulation/ElementCommon.h"
int Element_FIRE_update(UPDATE_FUNC_ARGS);
static int graphics(GRAPHICS_FUNC_ARGS);
static void create(ELEMENT_CREATE_FUNC_ARGS);
void Element::Element_LAVA()
{
Identifier = "DEFAULT_PT_LAVA";
Name = "LAVA";
Colour = PIXPACK(0xE05010);
MenuVisible = 1;
MenuSection = SC_LIQUID;
Enabled = 1;
Advection = 0.3f;
AirDrag = 0.02f * CFDS;
AirLoss = 0.95f;
Loss = 0.80f;
Collision = 0.0f;
Gravity = 0.15f;
Diffusion = 0.00f;
HotAir = 0.0003f * CFDS;
Falldown = 2;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 2;
PhotonReflectWavelengths = 0x3FF00000;
Weight = 45;
DefaultProperties.temp = R_TEMP + 1500.0f + 273.15f;
HeatConduct = 60;
Description = "Molten lava. Ignites flammable materials. Generated when metals and other materials melt, solidifies when cold.";
Properties = TYPE_LIQUID|PROP_LIFE_DEC;
CarriesTypeIn = 1U << FIELD_CTYPE;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = MAX_TEMP;// check for lava solidification at all temperatures
LowTemperatureTransition = ST;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_FIRE_update;
Graphics = &graphics;
Create = &create;
}
static int graphics(GRAPHICS_FUNC_ARGS)
{
*colr = cpart->life * 2 + 0xE0;
*colg = cpart->life * 1 + 0x50;
*colb = cpart->life / 2 + 0x10;
if (*colr>255) *colr = 255;
if (*colg>192) *colg = 192;
if (*colb>128) *colb = 128;
*firea = 40;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode |= FIRE_ADD;
*pixel_mode |= PMODE_BLUR;
//Returning 0 means dynamic, do not cache
return 0;
}
static void create(ELEMENT_CREATE_FUNC_ARGS)
{
sim->parts[i].life = RNG::Ref().between(240, 359);
}