diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index b380d0cc4..4406f580e 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -194,7 +194,7 @@ void SimulationData::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) { @@ -233,6 +233,8 @@ void SimulationData::init_can_move() can_move[PT_THDR][PT_THDR] = 2; can_move[PT_EMBR][PT_EMBR] = 2; can_move[PT_TRON][PT_SWCH] = 3; + can_move[PT_ELEC][PT_RSST] = 2; + can_move[PT_ELEC][PT_RSSS] = 2; } const CustomGOLData *SimulationData::GetCustomGOLByRule(int rule) const diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index 1ac8e046b..88c695c72 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -59,7 +59,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 ((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 44a15d327..2674e22ed 100644 --- a/src/simulation/elements/DTEC.cpp +++ b/src/simulation/elements/DTEC.cpp @@ -68,7 +68,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 ((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 f759983c9..3d90f719d 100644 --- a/src/simulation/elements/ELEC.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -117,6 +117,15 @@ static int update(UPDATE_FUNC_ARGS) parts[ID(r)].tmp2 += 5; parts[ID(r)].life = 1000; break; + case PT_RSST: //Destroy 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/GLOW.cpp b/src/simulation/elements/GLOW.cpp index f9e986c41..ef8bb6a1c 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -66,6 +66,12 @@ static int update(UPDATE_FUNC_ARGS) parts[ID(r)].life = 10; return 1; } + else if (TYP(r) == PT_GEL) //GLOW + GEL = RSST + { + sim->kill_part(i); + sim->part_change_type(ID(r),x+rx,y+ry,PT_RSST); + return 1; + } } } } diff --git a/src/simulation/elements/GRVT.cpp b/src/simulation/elements/GRVT.cpp index 55fc9608a..b6dd2a9c1 100644 --- a/src/simulation/elements/GRVT.cpp +++ b/src/simulation/elements/GRVT.cpp @@ -59,6 +59,16 @@ static int update(UPDATE_FUNC_ARGS) if (parts[i].tmp <= -100) parts[i].tmp = -100; + int under = pmap[y][x]; + int utype = TYP(under); + + //Randomly kill GRVT inside RSSS + if((utype == PT_RSSS) && sim->rng.chance(1, 5)) + { + 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 7a647d2c9..286381aca 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 a5f933fe0..3f75f9a5c 100644 --- a/src/simulation/elements/LSNS.cpp +++ b/src/simulation/elements/LSNS.cpp @@ -69,7 +69,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 ((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 1feb16ea4..f7d2fd351 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -164,6 +164,31 @@ 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) + { + int ct_under, tmp_under; + + ct_under = parts[ID(r)].ctype; + tmp_under = parts[ID(r)].tmp; + + //If there's a correct ctype set, liquefy into it + if(ct_under > 0 && ct_under < PT_NUM) + { + sim->create_part(ID(r), x, y, ct_under); + + //If there's a correct tmp set, use it for ctype + if(tmp_under > 0 && ct_under < PT_NUM) + parts[ID(r)].ctype = tmp_under; + } + else + sim->part_change_type(ID(r), x, y, PT_RSST); //Default to RSST if no ctype + + sim->kill_part(i); + + return 1; + } + break; default: break; } diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index d0c13cb78..ef3a33934 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -108,6 +108,29 @@ 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, make it solid + { + int ct_under, tmp_under; + + ct_under = parts[ID(r)].ctype; + tmp_under = parts[ID(r)].tmp; + + //If there's a correct ctype set, solidify RSST into it + if(ct_under > 0 && ct_under < PT_NUM) + { + sim->create_part(ID(r), x, y, ct_under); + + //If there's a correct tmp set, use it for ctype + if(tmp_under > 0 && ct_under < PT_NUM) + parts[ID(r)].ctype = tmp_under; + } + else + sim->part_change_type(ID(r), x, y, PT_RSSS); //Default to RSSS if no ctype + + 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 3575c2331..e8b287a82 100644 --- a/src/simulation/elements/PROT.cpp +++ b/src/simulation/elements/PROT.cpp @@ -103,6 +103,13 @@ 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_RSSS: //Destroy RSSS + { + sim->kill_part(uID); + sim->kill_part(i); + return 1; + } + 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 221efbef8..7d45bb751 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -61,7 +61,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 ((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/PTNM.cpp b/src/simulation/elements/PTNM.cpp index 1593b124f..cd7c7cab9 100644 --- a/src/simulation/elements/PTNM.cpp +++ b/src/simulation/elements/PTNM.cpp @@ -236,6 +236,10 @@ static int update(UPDATE_FUNC_ARGS) case PT_SMKE: // SMKE -> CO2 sim->part_change_type(ID(r), x + rx, y + ry, PT_CO2); break; + + case PT_RSST: // RSST -> BIZR + sim->part_change_type(ID(r), x + rx, y + ry, PT_BIZR); + break; } } } diff --git a/src/simulation/elements/RSSS.cpp b/src/simulation/elements/RSSS.cpp new file mode 100644 index 000000000..7ca3fd424 --- /dev/null +++ b/src/simulation/elements/RSSS.cpp @@ -0,0 +1,56 @@ +#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 = 130; + Description = "Solidified resist. Blocks pressure and insulates electricity. Liquefies on contact with neutrons."; + + 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) +{ + //Block air like TTAN + 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..2f0c5eb90 --- /dev/null +++ b/src/simulation/elements/RSST.cpp @@ -0,0 +1,87 @@ +#include "simulation/ElementCommon.h" + +int update(UPDATE_FUNC_ARGS); + +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 = 33; + + DefaultProperties.temp = R_TEMP + 20.0f + 273.15f; + HeatConduct = 55; + Description = "Resist. Solidifies on contact with photons, is destroyed by electrons and spark."; + + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &update; +} + +int update(UPDATE_FUNC_ARGS) +{ + for(int rx = -1; rx < 2; rx++) + { + for(int ry = -1; ry < 2; ry++) + { + auto r = pmap[y+ry][x+rx]; + + if (!r) + continue; + + // RSST + GUNP = FIRW + if(TYP(r) == PT_GUNP) + { + sim->part_change_type(i, x, y, PT_FIRW); + sim->kill_part(ID(r)); + return 1; + } + + // RSST + BCOL = FSEP + if(TYP(r) == PT_BCOL) + { + sim->part_change_type(i, x, y, PT_FSEP); + parts[i].life = 50; + sim->kill_part(ID(r)); + return 1; + } + + // Set RSST ctype from nearby clone + if((TYP(r) == PT_CLNE) || (TYP(r) == PT_PCLN)) + { + if(parts[ID(r)].ctype != PT_RSST) + parts[i].ctype = parts[ID(r)].ctype; + } + } + } + + return 0; +} diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index bd75919ab..bedcf0a8b 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -74,6 +74,12 @@ static int update(UPDATE_FUNC_ARGS) parts[i].life = 54; else if (ct == PT_SWCH) parts[i].life = 14; + else if (ct == PT_RSST) //RSST disappears at the end of its spark cycle + { + sim->kill_part(i); + return 1; + } + if (sim->part_change_type(i,x,y,ct)) return 1; return 0; @@ -92,7 +98,8 @@ static int update(UPDATE_FUNC_ARGS) if (parts[i].life==1) { 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; @@ -200,7 +207,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; @@ -213,7 +220,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) { @@ -246,14 +253,14 @@ 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) { if (sender == PT_NSCN || sender == PT_PSCN || sender == PT_INST) Element_PPIP_flood_trigger(sim, x+rx, y+ry, sender); } 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) @@ -272,7 +279,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 (!((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. @@ -358,6 +365,14 @@ static int update(UPDATE_FUNC_ARGS) sim->FloodINST(x+rx,y+ry);//spark the wire } } + else if (receiver==PT_RSST) { + if (parts[ID(r)].life==0 && parts[i].life<4) + { + sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); + parts[ID(r)].life = 5; + parts[ID(r)].ctype = receiver; + } + } else if (parts[ID(r)].life==0 && parts[i].life<4) { parts[ID(r)].life = 4; parts[ID(r)].ctype = receiver; 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 3bb981d32..86227c926 100644 --- a/src/simulation/elements/TSNS.cpp +++ b/src/simulation/elements/TSNS.cpp @@ -69,7 +69,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 ((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 7c5a95de8..759f7a2e1 100644 --- a/src/simulation/elements/VSNS.cpp +++ b/src/simulation/elements/VSNS.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 ((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 = []