Added reaction to create PAPR

This commit is contained in:
Rebmiami 2024-03-15 07:21:59 -04:00
parent c0f248c6db
commit 692bb4ec81
4 changed files with 57 additions and 3 deletions

View File

@ -1097,7 +1097,7 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr) const
case PT_PAPR:
// BCOL can always pass through PAPR in order to color it
// Most elements are blocked by marked PAPR, except for certified "weird" elements where it's inverse
if ((pt == PT_BCOL) || (parts[ID(r)].life ^ (pt != PT_ANAR && pt != PT_BIZR && pt != PT_BIZRG)))
if ((pt == PT_BCOL) || (!parts[ID(r)].life != !(pt != PT_ANAR && pt != PT_BIZR && pt != PT_BIZRG)))
result = 2;
else
result = 0;

View File

@ -187,7 +187,7 @@ void SimulationData::init_can_move()
can_move[movingType][PT_SAWD] = 0;
// Let most non-solids pass through unmarked PAPR
if (elements[movingType].Properties & (TYPE_GAS | TYPE_PART | TYPE_LIQUID) && (movingType != PT_FIRE && movingType != PT_SMKE))
if (elements[movingType].Properties & (TYPE_GAS | TYPE_PART | TYPE_LIQUID) && (movingType != PT_FIRE && movingType != PT_SMKE && movingType != PT_SAWD))
can_move[movingType][PT_PAPR] = 3;
}
//a list of lots of things PHOT can move through
@ -239,6 +239,9 @@ void SimulationData::init_can_move()
can_move[PT_TRON][PT_SWCH] = 3;
can_move[PT_SOAP][PT_OIL] = 0;
can_move[PT_OIL][PT_SOAP] = 1;
can_move[PT_MWAX][PT_SAWD] = 0;
can_move[PT_SAWD][PT_MWAX] = 0;
}
const CustomGOLData *SimulationData::GetCustomGOLByRule(int rule) const

View File

@ -34,7 +34,7 @@ void Element::Element_PAPR()
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 15;
Hardness = 60;
Weight = 100;
@ -85,6 +85,12 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].dcolour = 0xFF22222A;
}
// Doesn't guarantee layering won't happen, but makes it far less likely
if (TYP(pmap[y][x]) == PT_SAWD)
{
parts[ID(pmap[y][x])].tmp = 0;
}
// Generally, these should correspond, but correct if they don't.
if (!parts[i].life != !parts[i].dcolour)
{

View File

@ -1,5 +1,7 @@
#include "simulation/ElementCommon.h"
static int update(UPDATE_FUNC_ARGS);
void Element::Element_SAWD()
{
Identifier = "DEFAULT_PT_SAWD";
@ -40,5 +42,48 @@ void Element::Element_SAWD()
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &update;
Graphics = NULL; // is this needed?
}
static int update(UPDATE_FUNC_ARGS)
{
int nearbyWax = 0;
for (auto rx = -3; rx <= 3; rx++)
{
for (auto ry = -3; ry <= 3; ry++)
{
if (rx || ry)
{
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) == PT_MWAX)
{
nearbyWax++;
}
}
}
}
parts[i].tmp += nearbyWax / 2;
if (parts[i].tmp > 100)
{
int rx = sim->rng.between(-2, 2);
int ry = sim->rng.between(-2, 2);
int p = pmap[y+ry][x+rx];
if (p && TYP(p) == PT_MWAX)
{
sim->create_part(i, x, y, PT_PAPR);
sim->kill_part(ID(p));
return 1;
}
}
if (parts[i].tmp > 0)
{
parts[i].vx = 0;
parts[i].vy = 0;
parts[i].tmp--;
}
return 0;
}