Merge pull request #1192 from Cube14yt/main

Create fission.js
This commit is contained in:
slweeb 2025-08-04 19:33:46 -04:00 committed by GitHub
commit 275031d976
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 68 additions and 0 deletions

68
mods/fission.js Normal file
View File

@ -0,0 +1,68 @@
elements.neutron.onCollide = function(pixel1, pixel2) {
if (pixel2.element === "uranium" && Math.random() <= 0.25) {
pixel2.react = true;
}
}
elements.uranium.tick = function(pixel) {
pixel.cd ??= 0;
pixel.hp ??= 8;
pixel.energy ??= 0;
// Cooldown
if (pixel.cd > 0) {
pixel.cd--;
return;
}
if (pixel.react) {
let released = 0;
// spawn neutrons
for (let j = 0; j < squareCoordsShuffle.length && released < 3; j++) {
let c = squareCoordsShuffle[j];
let nx = pixel.x + c[0];
let ny = pixel.y + c[1];
if (isEmpty(nx, ny)) {
createPixel("neutron", nx, ny);
released++;
let neutron = getPixel(nx, ny);
if (neutron && neutron.element === "neutron") {
neutron.by = -1;
}
}
}
// accumulate energy + consume HP
pixel.energy += released;
pixel.hp--;
// depletion condition
if (pixel.hp <= 0 || pixel.energy >= 20) {
changePixel(pixel, "lead_powder");
}
// reset flags
pixel.cd = 5;
pixel.react = false;
}
}
elements.lead_powder = {
color: ["#6c6c6a","#838381"],
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"M2|M1 AND SW:uranium%25|M2"
],
tempHigh: 327.5,
stateHigh: "molten_lead",
category: "solids",
density: 11343,
conduct: 0.41,
superconductAt: -265.95
}