Add liquid resist (RSST) and solid resist (RSSS).

This commit is contained in:
Saveliy Skresanov 2023-09-30 20:05:29 +07:00
parent 146fb4b549
commit 93cbb065dd
19 changed files with 185 additions and 17 deletions

View File

@ -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;
}
/*

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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.

View File

@ -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)

View File

@ -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)
{

View File

@ -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)
{

View File

@ -191,6 +191,8 @@ simulation_elem_names = [
'VSNS',
'ROCK',
'LITH',
'RSST',
'RSSS'
]
simulation_elem_src = []