mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 19:29:52 +02:00
PSTN: allow movement amount to be set by temperature. Requires major version increment.
This commit is contained in:
@@ -979,6 +979,8 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
case PT_PSTN:
|
||||
if (savedVersion < 87 && particles[newIndex].ctype)
|
||||
particles[newIndex].life = 1;
|
||||
if (savedVersion < 91)
|
||||
particles[newIndex].temp = 283.15;
|
||||
break;
|
||||
case PT_STKM:
|
||||
case PT_STKM2:
|
||||
@@ -1008,6 +1010,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
{
|
||||
particles[newIndex].flags |= FLAG_PHOTDECO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old
|
||||
newIndex++;
|
||||
|
@@ -26,7 +26,7 @@ Element_PSTN::Element_PSTN()
|
||||
|
||||
Weight = 100;
|
||||
|
||||
Temperature = R_TEMP+0.0f +273.15f;
|
||||
Temperature = 283.15f;
|
||||
HeatConduct = 0;
|
||||
Description = "Piston, extends and pushes particles.";
|
||||
|
||||
@@ -95,31 +95,36 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
||||
bool movedPiston = false;
|
||||
bool foundEnd = false;
|
||||
int pistonEndX, pistonEndY;
|
||||
int pistonCount = 0;
|
||||
int pistonCount = -1;// number of PSTN particles minus 1
|
||||
int newSpace = 0;
|
||||
int armCount = 0;
|
||||
directionX = rx;
|
||||
directionY = ry;
|
||||
for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) {
|
||||
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
|
||||
if (!(x+nxx<XRES && y+nyy<YRES && x+nxx >= 0 && y+nyy >= 0)) {
|
||||
break;
|
||||
}
|
||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||
r = pmap[y+nyy][x+nxx];
|
||||
if((r&0xFF)==PT_PSTN) {
|
||||
if(parts[r>>8].life)
|
||||
armCount++;
|
||||
else if (armCount)
|
||||
{
|
||||
pistonEndX = x+nxi+nxx;
|
||||
pistonEndY = y+nyi+nyy;
|
||||
pistonEndX = x+nxx;
|
||||
pistonEndY = y+nyy;
|
||||
foundEnd = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
pistonCount++;
|
||||
{
|
||||
if (parts[r>>8].temp>283.15)
|
||||
pistonCount += (int)((parts[r>>8].temp-268.15)/10);// how many tens of degrees above 0 C, rounded to nearest 10
|
||||
else
|
||||
pistonCount++;
|
||||
}
|
||||
} else {
|
||||
pistonEndX = x+nxi+nxx;
|
||||
pistonEndY = y+nyi+nyy;
|
||||
pistonEndX = x+nxx;
|
||||
pistonEndY = y+nyy;
|
||||
foundEnd = true;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user