Skip to content

Commit

Permalink
RPEL's ctype sets the element it repels
Browse files Browse the repository at this point in the history
  • Loading branch information
SopaXorzTaker authored and jacob1 committed Jul 17, 2016
1 parent 85bdeae commit 17398dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/simulation/Simulation.cpp
Expand Up @@ -2847,6 +2847,8 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
{
//If an element has the PROP_DRAWONCTYPE property, and the element being drawn to it does not have PROP_NOCTYPEDRAW (Also some special cases), set the element's ctype
int drawOn = pmap[y][x]&0xFF;
if (drawOn == t)
return -1;
if (((elements[drawOn].Properties & PROP_DRAWONCTYPE) ||
(drawOn == PT_STOR && !(elements[t].Properties & TYPE_SOLID)) ||
(drawOn == PT_PCLN && t != PT_PSCN && t != PT_NSCN) ||
Expand All @@ -2862,7 +2864,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
parts[pmap[y][x]>>8].tmp = v;
}
}
else if ((drawOn == PT_DTEC || (drawOn == PT_PSTN && t != PT_FRME) || drawOn == PT_DRAY) && drawOn != t)
else if (drawOn == PT_DTEC || (drawOn == PT_PSTN && t != PT_FRME) || drawOn == PT_DRAY)
{
parts[pmap[y][x]>>8].ctype = t;
if (t == PT_LIFE && v >= 0 && v < NGOL)
Expand All @@ -2873,7 +2875,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
parts[pmap[y][x]>>8].ctype |= v<<8;
}
}
else if (drawOn == PT_CRAY && drawOn != t)
else if (drawOn == PT_CRAY)
{
parts[pmap[y][x]>>8].ctype = t;
if (t == PT_LIFE && v >= 0 && v < NGOL)
Expand Down
10 changes: 6 additions & 4 deletions src/simulation/elements/RPEL.cpp
Expand Up @@ -30,7 +30,7 @@ Element_RPEL::Element_RPEL()
HeatConduct = 0;
Description = "Repels or attracts particles based on its temperature.";

Properties = TYPE_SOLID;
Properties = TYPE_SOLID | PROP_DRAWONCTYPE;

LowPressure = IPL;
LowPressureTransition = NT;
Expand Down Expand Up @@ -58,9 +58,11 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS)
if (!r)
r = sim->photons[y+ry][x+rx];

if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){
parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);
if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)) {
if (!parts[i].ctype || parts[i].ctype == parts[r>>8].type) {
parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);
}
}
}
}
Expand Down

0 comments on commit 17398dd

Please sign in to comment.