From 93cbb065ddd72f7d9ff7f78bde1c063b6767e078 Mon Sep 17 00:00:00 2001 From: Saveliy Skresanov Date: Sat, 30 Sep 2023 20:05:29 +0700 Subject: [PATCH] Add liquid resist (RSST) and solid resist (RSSS). --- src/simulation/Simulation.cpp | 4 ++- src/simulation/elements/BTRY.cpp | 3 +- src/simulation/elements/DLAY.cpp | 3 +- src/simulation/elements/DTEC.cpp | 3 +- src/simulation/elements/ELEC.cpp | 9 +++++ src/simulation/elements/GRVT.cpp | 19 ++++++++++ src/simulation/elements/LITH.cpp | 6 ++-- src/simulation/elements/LSNS.cpp | 3 +- src/simulation/elements/NEUT.cpp | 8 +++++ src/simulation/elements/PHOT.cpp | 7 ++++ src/simulation/elements/PROT.cpp | 12 +++++++ src/simulation/elements/PSNS.cpp | 3 +- src/simulation/elements/RSSS.cpp | 55 +++++++++++++++++++++++++++++ src/simulation/elements/RSST.cpp | 43 ++++++++++++++++++++++ src/simulation/elements/SPRK.cpp | 13 +++---- src/simulation/elements/SWCH.cpp | 3 +- src/simulation/elements/TSNS.cpp | 3 +- src/simulation/elements/VSNS.cpp | 3 +- src/simulation/elements/meson.build | 2 ++ 19 files changed, 185 insertions(+), 17 deletions(-) create mode 100644 src/simulation/elements/RSSS.cpp create mode 100644 src/simulation/elements/RSST.cpp diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 04c66700c..a772e6283 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1197,7 +1197,7 @@ void Simulation::init_can_move() || destinationType == PT_CLNE || destinationType == PT_PCLN || destinationType == PT_BCLN || destinationType == PT_PBCN || destinationType == PT_WATR || destinationType == PT_DSTW || destinationType == PT_SLTW || destinationType == PT_GLOW || destinationType == PT_ISOZ || destinationType == PT_ISZS || destinationType == PT_QRTZ || destinationType == PT_PQRT - || destinationType == PT_H2 || destinationType == PT_BGLA || destinationType == PT_C5) + || destinationType == PT_H2 || destinationType == PT_BGLA || destinationType == PT_C5 || destinationType == PT_RSST) can_move[PT_PHOT][destinationType] = 2; if (destinationType != PT_DMND && destinationType != PT_INSL && destinationType != PT_VOID && destinationType != PT_PVOD && destinationType != PT_VIBR && destinationType != PT_BVBR && destinationType != PT_PRTI && destinationType != PT_PRTO) { @@ -1238,6 +1238,8 @@ void Simulation::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_ELEC][PT_RSST] = 2; + can_move[PT_ELEC][PT_RSSS] = 2; } /* diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index 2f5dd934a..c580132b3 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -57,7 +57,8 @@ static int update(UPDATE_FUNC_ARGS) if (!r) continue; auto rt = TYP(r); - if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i,ID(r),PT_INSL); + if (pavg!=PT_INSL && pavg!=PT_RSSS) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) { diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp index bbc14ad0b..f3a071ec3 100644 --- a/src/simulation/elements/DLAY.cpp +++ b/src/simulation/elements/DLAY.cpp @@ -62,7 +62,8 @@ static int update(UPDATE_FUNC_ARGS) if (rx || ry) { auto r = pmap[y+ry][x+rx]; - if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL) + auto pavg = sim->parts_avg(ID(r), i, PT_INSL); + if (!r || pavg==PT_INSL || pavg==PT_RSSS) continue; if (TYP(r)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN) { diff --git a/src/simulation/elements/DTEC.cpp b/src/simulation/elements/DTEC.cpp index 911bd2dde..f9eb703b0 100644 --- a/src/simulation/elements/DTEC.cpp +++ b/src/simulation/elements/DTEC.cpp @@ -66,7 +66,8 @@ static int update(UPDATE_FUNC_ARGS) if (!r) continue; auto rt = TYP(r); - if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i,ID(r),PT_INSL); + if (pavg != PT_INSL && pavg != PT_RSSS) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) { diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp index 9874019e9..9b3c10086 100644 --- a/src/simulation/elements/ELEC.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -115,6 +115,15 @@ static int update(UPDATE_FUNC_ARGS) parts[ID(r)].tmp2 += 5; parts[ID(r)].life = 1000; break; + case PT_RSST: + if(!rx && !ry) + { + sim->kill_part(ID(r)); + sim->kill_part(i); + + return 1; + } + break; case PT_NONE: //seems to speed up ELEC even if it isn't used break; default: diff --git a/src/simulation/elements/GRVT.cpp b/src/simulation/elements/GRVT.cpp index 55fc9608a..348f06d97 100644 --- a/src/simulation/elements/GRVT.cpp +++ b/src/simulation/elements/GRVT.cpp @@ -59,6 +59,25 @@ static int update(UPDATE_FUNC_ARGS) if (parts[i].tmp <= -100) parts[i].tmp = -100; + int under = pmap[y][x]; + int utype = TYP(under); + int uID = ID(under); + + if(utype == PT_RSST) + { + sim->part_change_type(uID, x, y, PT_SWCH); + sim->kill_part(i); + + return 1; + } + else if(utype == PT_RSSS) + { + sim->part_change_type(uID, x, y, PT_NSCN); + sim->kill_part(i); + + return 1; + } + sim->gravmap[(y/CELL)*XCELLS+(x/CELL)] = 0.2f*parts[i].tmp; return 0; } diff --git a/src/simulation/elements/LITH.cpp b/src/simulation/elements/LITH.cpp index 4ace0e832..10605a255 100644 --- a/src/simulation/elements/LITH.cpp +++ b/src/simulation/elements/LITH.cpp @@ -93,6 +93,8 @@ static int update(UPDATE_FUNC_ARGS) } Particle &neighbor = parts[ID(neighborData)]; + auto pavg = sim->parts_avg(i, ID(neighborData), PT_INSL); + switch (TYP(neighborData)) { case PT_SLTW: @@ -134,7 +136,7 @@ static int update(UPDATE_FUNC_ARGS) break; case PT_SPRK: - if (sim->parts_avg(i, ID(neighborData), PT_INSL) == PT_INSL) + if (pavg == PT_INSL || pavg == PT_RSSS) { break; } @@ -149,7 +151,7 @@ static int update(UPDATE_FUNC_ARGS) break; case PT_NSCN: - if (sim->parts_avg(i, ID(neighborData), PT_INSL) == PT_INSL) + if (pavg == PT_INSL || pavg == PT_RSSS) { break; } diff --git a/src/simulation/elements/LSNS.cpp b/src/simulation/elements/LSNS.cpp index a70f4a22e..794ad3fe5 100644 --- a/src/simulation/elements/LSNS.cpp +++ b/src/simulation/elements/LSNS.cpp @@ -67,7 +67,8 @@ static int update(UPDATE_FUNC_ARGS) if (!r) continue; int rt = TYP(r); - if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i, ID(r), PT_INSL); + if (pavg != PT_INSL && pavg != PT_RSSS) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0) { diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index bfd0c146a..d367556a5 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -164,6 +164,14 @@ static int update(UPDATE_FUNC_ARGS) else sim->create_part(ID(r), x+rx, y+ry, PT_CAUS); break; + case PT_RSSS: + if(!rx && !ry) + { + sim->part_change_type(ID(r), x, y, PT_RSST); + sim->kill_part(i); + return 1; + } + break; default: break; } diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index 56432a48b..74b03d395 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -107,6 +107,13 @@ static int update(UPDATE_FUNC_ARGS) parts[i].vx = vx; parts[i].vy = vy; } + else if(TYP(r) == PT_RSST && !ry && !rx)//if on RSST + { + sim->part_change_type(ID(r),x,y,PT_RSSS); + sim->kill_part(i); + + return 1; + } else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9) { parts[i].vx += ((float)sim->rng.between(-500, 500))/1000.0f; diff --git a/src/simulation/elements/PROT.cpp b/src/simulation/elements/PROT.cpp index 5d0c7a2a3..f5a997932 100644 --- a/src/simulation/elements/PROT.cpp +++ b/src/simulation/elements/PROT.cpp @@ -101,6 +101,18 @@ static int update(UPDATE_FUNC_ARGS) else change = 0.0f; parts[uID].temp = restrict_flt(parts[uID].temp + change, MIN_TEMP, MAX_TEMP); break; + case PT_RSST: + { + sim->part_change_type(uID, x, y, PT_METL); + sim->kill_part(i); + } + break; + case PT_RSSS: + { + sim->part_change_type(uID, x, y, PT_PSCN); + sim->kill_part(i); + } + break; case PT_NONE: //slowly kill if it's not inside an element if (parts[i].life) diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index 3d893f287..06b94113d 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -59,7 +59,8 @@ static int update(UPDATE_FUNC_ARGS) auto r = pmap[y+ry][x+rx]; if (!r) continue; - if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i,ID(r),PT_INSL); + if (pavg != PT_INSL && pavg != PT_RSSS) { auto rt = TYP(r); if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) diff --git a/src/simulation/elements/RSSS.cpp b/src/simulation/elements/RSSS.cpp new file mode 100644 index 000000000..a853ddd13 --- /dev/null +++ b/src/simulation/elements/RSSS.cpp @@ -0,0 +1,55 @@ +#include "simulation/ElementCommon.h" +#include "simulation/Air.h" + +static int update(UPDATE_FUNC_ARGS); + +void Element::Element_RSSS() +{ + Identifier = "DEFAULT_PT_RSSS"; + Name = "RSSS"; + Colour = 0xC43626_rgb; + 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 = 251; + Description = "Solidified resist."; + + Properties = TYPE_SOLID|PROP_NEUTPASS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &update; +} + +static int update(UPDATE_FUNC_ARGS) +{ + sim->air->bmap_blockair[y/CELL][x/CELL] = 1; + sim->air->bmap_blockairh[y/CELL][x/CELL] = 0x8; + + return 0; +} diff --git a/src/simulation/elements/RSST.cpp b/src/simulation/elements/RSST.cpp new file mode 100644 index 000000000..bfe304284 --- /dev/null +++ b/src/simulation/elements/RSST.cpp @@ -0,0 +1,43 @@ +#include "simulation/ElementCommon.h" + +void Element::Element_RSST() +{ + Identifier = "DEFAULT_PT_RSST"; + Name = "RSST"; + Colour = 0xF95B49_rgb; + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.3f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.98f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.15f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 50; + + Weight = 40; + + DefaultProperties.temp = R_TEMP + 20.0f + 273.15f; + HeatConduct = 44; + Description = "Resist."; + + Properties = TYPE_LIQUID|PROP_NEUTPASS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; +} diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 4b43a5869..cc06f8aae 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -89,7 +89,8 @@ static int update(UPDATE_FUNC_ARGS) { int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId); auto nearp = Element_ETRD_nearestSparkablePart(sim, i); - if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL) + auto pavg = sim->parts_avg(i, nearp, PT_INSL); + if (nearp!=-1 && pavg!=PT_INSL && pavg!=PT_RSSS) { sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM); parts[i].life = 20; @@ -197,7 +198,7 @@ static int update(UPDATE_FUNC_ARGS) switch (receiver) { case PT_SWCH: - if (pavg!=PT_INSL && parts[i].life<4) + if (pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4) { if(sender==PT_PSCN && parts[ID(r)].life<10) { parts[ID(r)].life = 10; @@ -210,7 +211,7 @@ static int update(UPDATE_FUNC_ARGS) } break; case PT_SPRK: - if (pavg!=PT_INSL && parts[i].life<4) + if (pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4) { if (parts[ID(r)].ctype==PT_SWCH) { @@ -243,7 +244,7 @@ static int update(UPDATE_FUNC_ARGS) } continue; case PT_PPIP: - if (parts[i].life == 3 && pavg!=PT_INSL) + if (parts[i].life == 3 && pavg!=PT_INSL && pavg!=PT_RSSS) { void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy); if (sender == PT_NSCN || sender == PT_PSCN || sender == PT_INST) @@ -251,7 +252,7 @@ static int update(UPDATE_FUNC_ARGS) } continue; case PT_NTCT: case PT_PTCT: case PT_INWR: - if (sender==PT_METL && pavg!=PT_INSL && parts[i].life<4) + if (sender==PT_METL && pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4) { parts[ID(r)].temp = 473.0f; if (receiver==PT_NTCT||receiver==PT_PTCT) @@ -270,7 +271,7 @@ static int update(UPDATE_FUNC_ARGS) continue; } - if (pavg == PT_INSL) continue; //Insulation blocks everything past here + if ((pavg == PT_INSL) || (pavg == PT_RSSS)) continue; //Insulation blocks everything past here if (!((sim->elements[receiver].Properties&PROP_CONDUCTS)||receiver==PT_INST||receiver==PT_QRTZ)) continue; //Stop non-conducting receivers, allow INST and QRTZ as special cases if (abs(rx)+abs(ry)>=4 &&sender!=PT_SWCH&&receiver!=PT_SWCH) continue; //Only switch conducts really far if (receiver==sender && receiver!=PT_INST && receiver!=PT_QRTZ) goto conduct; //Everything conducts to itself, except INST. diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp index c41525b28..ed8806bfe 100644 --- a/src/simulation/elements/SWCH.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -65,7 +65,8 @@ static int update(UPDATE_FUNC_ARGS) auto r = pmap[y+ry][x+rx]; if (!r) continue; - if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) + auto pavg = sim->parts_avg(i,ID(r),PT_INSL); + if (pavg!=PT_INSL && pavg!=PT_RSSS) { auto rt = TYP(r); if (rt==PT_SWCH) diff --git a/src/simulation/elements/TSNS.cpp b/src/simulation/elements/TSNS.cpp index 7da107e06..488638514 100644 --- a/src/simulation/elements/TSNS.cpp +++ b/src/simulation/elements/TSNS.cpp @@ -67,7 +67,8 @@ static int update(UPDATE_FUNC_ARGS) if (!r) continue; int rt = TYP(r); - if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i, ID(r), PT_INSL); + if (pavg != PT_INSL && pavg != PT_RSSS) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0) { diff --git a/src/simulation/elements/VSNS.cpp b/src/simulation/elements/VSNS.cpp index 2b54de686..d60a53469 100644 --- a/src/simulation/elements/VSNS.cpp +++ b/src/simulation/elements/VSNS.cpp @@ -65,7 +65,8 @@ static int update(UPDATE_FUNC_ARGS) if (!r) continue; int rt = TYP(r); - if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL) + auto pavg = sim->parts_avg(i, ID(r), PT_INSL); + if (pavg != PT_INSL && pavg != PT_RSSS) { if ((sim->elements[rt].Properties &PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0) { diff --git a/src/simulation/elements/meson.build b/src/simulation/elements/meson.build index 05cc5792f..4f1dc9c64 100644 --- a/src/simulation/elements/meson.build +++ b/src/simulation/elements/meson.build @@ -191,6 +191,8 @@ simulation_elem_names = [ 'VSNS', 'ROCK', 'LITH', + 'RSST', + 'RSSS' ] simulation_elem_src = []