From 692bb4ec819f558568dc3a7019de22a9af0674ec Mon Sep 17 00:00:00 2001 From: Rebmiami <59275598+Rebmiami@users.noreply.github.com> Date: Fri, 15 Mar 2024 07:21:59 -0400 Subject: [PATCH] Added reaction to create PAPR --- src/simulation/Simulation.cpp | 2 +- src/simulation/SimulationData.cpp | 5 +++- src/simulation/elements/PAPR.cpp | 8 +++++- src/simulation/elements/SAWD.cpp | 45 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index d601be429..2a8b864ad 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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; diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index 4a14c1d47..e81bd7bd1 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -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 diff --git a/src/simulation/elements/PAPR.cpp b/src/simulation/elements/PAPR.cpp index 141a31039..2c382f9c6 100644 --- a/src/simulation/elements/PAPR.cpp +++ b/src/simulation/elements/PAPR.cpp @@ -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) { diff --git a/src/simulation/elements/SAWD.cpp b/src/simulation/elements/SAWD.cpp index 19ad799c4..e7cc01156 100644 --- a/src/simulation/elements/SAWD.cpp +++ b/src/simulation/elements/SAWD.cpp @@ -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; +} \ No newline at end of file