mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-27 01:44:31 +02:00
Allow creating heat pipes by replacing BRCK with HEAC before color generation
Uses same flood-fill function as PPIP. Only runs before pipe is initialized, to prevent breaking older saves that may have HEAC next to pipe.
This commit is contained in:
@@ -170,6 +170,7 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
|
||||
int lastneighbor = -1;
|
||||
int neighborcount = 0;
|
||||
int count = 0;
|
||||
bool heatPipe = false;
|
||||
// make automatic pipe pattern
|
||||
for (auto rx = -1; rx <= 1; rx++)
|
||||
{
|
||||
@@ -181,6 +182,11 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
|
||||
auto r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r) == PT_HEAC)
|
||||
{
|
||||
heatPipe = true;
|
||||
continue;
|
||||
}
|
||||
if (TYP(r) != PT_PIPE && TYP(r) != PT_PPIP)
|
||||
continue;
|
||||
unsigned int next = nextColor(parts[i].tmp);
|
||||
@@ -213,6 +219,8 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (neighborcount == 1)
|
||||
parts[lastneighbor].tmp |= 0x100;
|
||||
if (heatPipe)
|
||||
Element_PPIP_flood_trigger(sim, x, y, PT_HEAC);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -72,6 +72,9 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
|
||||
Particle * parts = sim->parts;
|
||||
int (*pmap)[XRES] = sim->pmap;
|
||||
int t = TYP(pmap[y][x]);
|
||||
if (t != PT_PIPE && t != PT_PPIP)
|
||||
return;
|
||||
|
||||
// Separate flags for on and off in case PPIP is sparked by PSCN and NSCN on the same frame
|
||||
// - then PSCN can override NSCN and behaviour is not dependent on particle order
|
||||
@@ -79,8 +82,9 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
if (sparkedBy==PT_PSCN) prop = PPIP_TMPFLAG_TRIGGER_ON << 3;
|
||||
else if (sparkedBy==PT_NSCN) prop = PPIP_TMPFLAG_TRIGGER_OFF << 3;
|
||||
else if (sparkedBy==PT_INST) prop = PPIP_TMPFLAG_TRIGGER_REVERSE << 3;
|
||||
else if (sparkedBy == PT_HEAC) prop = PFLAG_CAN_CONDUCT; // Special case for HEAC near pipe
|
||||
|
||||
if (prop==0 || TYP(pmap[y][x])!=PT_PPIP || (parts[ID(pmap[y][x])].tmp & prop))
|
||||
if (prop == 0 || (t != PT_PPIP && sparkedBy != PT_HEAC) || (parts[ID(pmap[y][x])].tmp & prop))
|
||||
return;
|
||||
|
||||
coord_stack = new unsigned short[coord_stack_limit][2];
|
||||
@@ -97,7 +101,7 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// go left as far as possible
|
||||
while (x1>=CELL)
|
||||
{
|
||||
if (TYP(pmap[y][x1-1]) != PT_PPIP)
|
||||
if (TYP(pmap[y][x1-1]) != t)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -106,7 +110,7 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// go right as far as possible
|
||||
while (x2<XRES-CELL)
|
||||
{
|
||||
if (TYP(pmap[y][x2+1]) != PT_PPIP)
|
||||
if (TYP(pmap[y][x2+1]) != t)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -115,8 +119,8 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// fill span
|
||||
for (x=x1; x<=x2; x++)
|
||||
{
|
||||
if (!(parts[ID(pmap[y][x])].tmp & prop))
|
||||
Element_PPIP_ppip_changed = 1;
|
||||
if (!(parts[ID(pmap[y][x])].tmp & prop) && sparkedBy != PT_HEAC)
|
||||
Element_PPIP_ppip_changed = 1;
|
||||
parts[ID(pmap[y][x])].tmp |= prop;
|
||||
}
|
||||
|
||||
@@ -125,7 +129,7 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// Don't need to check x bounds here, because already limited to [CELL, XRES-CELL]
|
||||
if (y>=CELL+1)
|
||||
for (x=x1-1; x<=x2+1; x++)
|
||||
if (TYP(pmap[y-1][x]) == PT_PPIP && !(parts[ID(pmap[y-1][x])].tmp & prop))
|
||||
if (TYP(pmap[y-1][x]) == t && !(parts[ID(pmap[y-1][x])].tmp & prop))
|
||||
{
|
||||
coord_stack[coord_stack_size][0] = x;
|
||||
coord_stack[coord_stack_size][1] = y-1;
|
||||
@@ -138,7 +142,7 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
}
|
||||
if (y<YRES-CELL-1)
|
||||
for (x=x1-1; x<=x2+1; x++)
|
||||
if (TYP(pmap[y+1][x]) == PT_PPIP && !(parts[ID(pmap[y+1][x])].tmp & prop))
|
||||
if (TYP(pmap[y+1][x]) == t && !(parts[ID(pmap[y+1][x])].tmp & prop))
|
||||
{
|
||||
coord_stack[coord_stack_size][0] = x;
|
||||
coord_stack[coord_stack_size][1] = y+1;
|
||||
|
Reference in New Issue
Block a user