summaryrefslogtreecommitdiff
path: root/src/simulation/elements/CRAY.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-02-20 23:36:00 (GMT)
committer jacob1 <jfu614@gmail.com>2013-02-20 23:36:00 (GMT)
commit74387040a1b616de6f744e4137cff72880b580d8 (patch)
tree28dfecc66d1461beb49fd12a4ce2ff18f4a7df44 /src/simulation/elements/CRAY.cpp
parent6b909ede2a8ae5d8c39331070446c35df65f88b5 (diff)
downloadpowder-74387040a1b616de6f744e4137cff72880b580d8.zip
powder-74387040a1b616de6f744e4137cff72880b580d8.tar.gz
fix CRAY INST mode ignoring length, fix CRAY going ignoring walls, fix CRAY + GOL particles, allow CRAY to create sparks
Diffstat (limited to 'src/simulation/elements/CRAY.cpp')
-rw-r--r--src/simulation/elements/CRAY.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp
index 0638f73..f0c0c9f 100644
--- a/src/simulation/elements/CRAY.cpp
+++ b/src/simulation/elements/CRAY.cpp
@@ -50,8 +50,9 @@ Element_CRAY::Element_CRAY()
int Element_CRAY::update(UPDATE_FUNC_ARGS)
{
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1, partsRemaining = 255;
- if (parts[i].tmp)
+ if (parts[i].tmp) //how far it shoots
partsRemaining = parts[i].tmp;
+ // set ctype to things that touch it if it doesn't have one already
if(parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled) {
int r, rx, ry;
for (rx=-1; rx<2; rx++)
@@ -63,12 +64,12 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_CRAY && (r&0xFF)<PT_NUM)
+ if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)<PT_NUM)
{
parts[i].ctype = r&0xFF;
}
}
- } else if (parts[i].life==0) {
+ } else if (parts[i].life==0) { // only fire when life is 0, but nothing sets the life right now
unsigned int colored = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
@@ -77,7 +78,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) {
+ if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { //spark found, start creating
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
int nostop = (parts[r>>8].ctype==PT_INST)?1:0;
for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) {
@@ -85,24 +86,24 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
- if (!r) {
- int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype);
+ if (!sim->IsObsticle(x+nxi+nxx, y+nyi+nyy, parts[i].ctype) || (parts[i].ctype == PT_SPRK && sim->elements[r&0xFF].Properties & PROP_CONDUCTS) && !destroy) { // create, also set color if it has passed through FILT
+ int nr;
+ if (parts[i].ctype == PT_LIFE)
+ nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype|(parts[i].tmp2<<8));
+ else
+ nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype);
if (nr!=-1) {
parts[nr].dcolour = colored;
- if(!--partsRemaining)
- docontinue = 0;
}
- } else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT
+ } else if ((r&0xFF)==PT_FILT) { // get color if passed through FILT
colored = wavelengthToDecoColour(parts[r>>8].ctype);
- } else if ((r&0xFF)==PT_CRAY || nostop) {
- docontinue = 1;
} else if(destroy && ((r&0xFF) != PT_DMND)) {
sim->kill_part(r>>8);
- if(!--partsRemaining)
- docontinue = 0;
- } else {
+ } else if ((r&0xFF) != PT_CRAY && !nostop) {
docontinue = 0;
}
+ if(!--partsRemaining)
+ docontinue = 0;
}
}
}