代码拉取完成,页面将自动刷新
同步操作将从 Powder-Toy-Sync/The-Powder-Toy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_CRAY PT_CRAY 167
Element_CRAY::Element_CRAY()
{
Identifier = "DEFAULT_PT_CRAY";
Name = "CRAY";
Colour = PIXPACK(0xBBFF00);
MenuVisible = 1;
MenuSection = SC_ELEC;
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 = 1;
Weight = 100;
DefaultProperties.life = -1;
HeatConduct = 0;
Description = "Particle Ray Emitter. Creates a beam of particles set by its ctype, with a range set by tmp.";
Properties = TYPE_SOLID;
Properties2 = PROP_DRAWONCTYPE | PROP_DEBUG_USE_TMP2;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_CRAY::update;
}
//#TPT-Directive ElementHeader Element_CRAY static int update(UPDATE_FUNC_ARGS)
int Element_CRAY::update(UPDATE_FUNC_ARGS)
{
int nxx, nyy, docontinue, nxi, nyi;
// set ctype to things that touch it if it doesn't have one already
if (parts[i].ctype<=0 || !sim->elements[TYP(parts[i].ctype)].Enabled)
{
for (int rx = -1; rx <= 1; rx++)
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK)
{
int r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
int rt = TYP(r);
if (rt!=PT_CRAY && rt!=PT_PSCN && rt!=PT_INST && rt!=PT_METL && rt!=PT_SPRK && rt!=ELEM_MULTIPP && rt!=PT_INDC && rt<PT_NUM)
{
parts[i].ctype = TYP(r);
parts[i].temp = parts[ID(r)].temp;
}
}
}
else
{
int new_part_life = parts[i].life;
int new_part_ctype = parts[i].ctype;
size_t offset1 = (TYP(new_part_ctype) == ELEM_MULTIPP) ? offsetof(Particle, ctype) : offsetof(Particle, life);
for (int rx =-1; rx <= 1; rx++)
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
int r = pmap[y+ry][x+rx];
if (!r)
continue;
if (CHECK_EL_SPRKL3(r)) { //spark found, start creating
unsigned int colored = 0;
Particle &part = parts[ID(r)];
bool destroy = part.ctype==PT_PSCN;
bool nostop = part.ctype==PT_INST;
bool createSpark = part.ctype==PT_INWR;
int partsRemaining = 255;
if (parts[i].tmp) //how far it shoots
partsRemaining = parts[i].tmp;
int spacesRemaining = parts[i].tmp2;
for (docontinue = 1, nxi = rx*-1, nyi = ry*-1, nxx = spacesRemaining*nxi, nyy = spacesRemaining*nyi; docontinue; nyy+=nyi, nxx+=nxi)
{
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
if (!sim->IsWallBlocking(x+nxi+nxx, y+nyi+nyy, TYP(new_part_ctype)) && (!sim->pmap[y+nyi+nyy][x+nxi+nxx] || createSpark)) { // create, also set color if it has passed through FILT
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, TYP(new_part_ctype), ID(new_part_ctype));
if (nr!=-1) {
if (colored)
parts[nr].dcolour = colored;
parts[nr].temp = parts[i].temp;
if (new_part_life >= 0)
*((int*)(((char*)&parts[nr]) + offset1)) = new_part_life;
if(!--partsRemaining)
docontinue = 0;
}
} else if (TYP(r)==PT_FILT) { // get color if passed through FILT
if (part.dcolour == 0xFF000000)
colored = 0xFF000000;
else if (part.tmp==0)
{
colored = wavelengthToDecoColour(Element_FILT::getWavelengths(&part));
}
else if (colored==0xFF000000)
colored = 0;
part.life = 4;
} else if (TYP(r) == PT_CRAY || nostop) {
docontinue = 1;
} else if(destroy && r && !(sim->elements[TYP(r)].Properties2 & PROP_NODESTRUCT)) {
sim->kill_part(ID(r));
if(!--partsRemaining)
docontinue = 0;
}
else
docontinue = 0;
if(!partsRemaining)
docontinue = 0;
}
}
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_CRAY static unsigned int wavelengthToDecoColour(int wavelength)
unsigned int Element_CRAY::wavelengthToDecoColour(int wavelength)
{
int colr = 0, colg = 0, colb = 0, x;
for (x=0; x<12; x++) {
colr += (wavelength >> (x+18)) & 1;
colb += (wavelength >> x) & 1;
}
for (x=0; x<12; x++)
colg += (wavelength >> (x+9)) & 1;
x = 624/(colr+colg+colb+1);
colr *= x;
colg *= x;
colb *= x;
if(colr > 255) colr = 255;
else if(colr < 0) colr = 0;
if(colg > 255) colg = 255;
else if(colg < 0) colg = 0;
if(colb > 255) colb = 255;
else if(colb < 0) colb = 0;
return (255<<24) | (colr<<16) | (colg<<8) | colb;
}
Element_CRAY::~Element_CRAY() {}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。