remove code
This commit is contained in:
parent
7b99f2650c
commit
025b8c74c2
|
|
@ -290,144 +290,6 @@ if(enabledMods.includes(libraryMod)) {
|
|||
excludeRandom: true,
|
||||
desc: "<span style='color:#FF00FF' onClick=colorToolFilterPrompt()>Click here to configure the element filter (applies to all color tools).</span>",
|
||||
}
|
||||
|
||||
//do cooldown for mouse size > 1
|
||||
function mouse1Action(e,mouseX=undefined,mouseY=undefined,startPos) {
|
||||
if (currentElement == "erase") { mouse2Action(e,mouseX,mouseY); return; }
|
||||
else if (currentElement == "pick") { mouseMiddleAction(e,mouseX,mouseY); return; }
|
||||
// If x and y are undefined, get the mouse position
|
||||
if (mouseX == undefined && mouseY == undefined) {
|
||||
var canvas = document.getElementById("game");
|
||||
var ctx = canvas.getContext("2d");
|
||||
lastPos = mousePos;
|
||||
mousePos = getMousePos(canvas, e);
|
||||
var mouseX = mousePos.x;
|
||||
var mouseY = mousePos.y;
|
||||
}
|
||||
if (currentElement == "lookup") {
|
||||
if (!isEmpty(mouseX,mouseY,true)) {
|
||||
showInfo(pixelMap[mouseX][mouseY].element);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var cooldowned = false;
|
||||
if (elements[currentElement].cooldown) {
|
||||
if (pixelTicks-lastPlace < elements[currentElement].cooldown) {
|
||||
return;
|
||||
}
|
||||
cooldowned = true;
|
||||
}
|
||||
lastPlace = pixelTicks;
|
||||
startPos = startPos || lastPos
|
||||
if (!(isMobile || (cooldowned && startPos.x===lastPos.x && startPos.y===lastPos.y) || elements[currentElement].tool || elements[currentElement].category==="tools")) {
|
||||
var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY);
|
||||
}
|
||||
else { var coords = mouseRange(mouseX,mouseY); }
|
||||
var element = elements[currentElement];
|
||||
var mixList = [];
|
||||
// For each x,y in coords
|
||||
for (var i = 0; i < coords.length; i++) {
|
||||
var x = coords[i][0];
|
||||
var y = coords[i][1];
|
||||
|
||||
// If element name is heat or cool
|
||||
if (currentElement === "heat" || currentElement === "cool") {
|
||||
if (!isEmpty(x,y,false)) {
|
||||
if (outOfBounds(x,y)) {
|
||||
continue;
|
||||
}
|
||||
var pixel = pixelMap[x][y];
|
||||
if (shiftDown) {pixel.temp += element.temp+(Math.random()*element.temp*1.5)*20;}
|
||||
else {pixel.temp += element.temp+(Math.random()*element.temp*1.5);}
|
||||
pixelTempCheck(pixel);
|
||||
}
|
||||
}
|
||||
else if (currentElement === "mix") {
|
||||
if (!isEmpty(x,y,true)) {
|
||||
var pixel = pixelMap[x][y];
|
||||
if ((pixel.element != "fire" && pixel.element != "smoke") || shiftDown) {
|
||||
mixList.push(pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentElement === "shock") {
|
||||
if (!isEmpty(x,y,true)) {
|
||||
// One loop that repeats 5 times if shiftDown else 1 time
|
||||
for (var j = 0; j < (shiftDown ? 5 : 1); j++) {
|
||||
var pixel = pixelMap[x][y];
|
||||
var con = elements[pixel.element].conduct;
|
||||
if (con == undefined) {continue}
|
||||
if (Math.random() < con) { // If random number is less than conductivity
|
||||
if (!pixel.charge && !pixel.chargeCD) {
|
||||
pixel.charge = 1;
|
||||
if (elements[pixel.element].colorOn) {
|
||||
pixel.color = pixelColorPick(pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (elements[pixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation)
|
||||
pixel.temp += 0.25;
|
||||
pixelTempCheck(pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentElement === "random" && isEmpty(x, y)) {
|
||||
// create pixel with random element from "randomChoices" array
|
||||
currentPixels.push(new Pixel(x, y, randomChoices[Math.floor(Math.random() * randomChoices.length)]));
|
||||
}
|
||||
else if (elements[currentElement].tool) {
|
||||
// run the tool function on the pixel
|
||||
if (!isEmpty(x,y,true)) {
|
||||
var pixel = pixelMap[x][y];
|
||||
// if the current element has an ignore property and the pixel's element is in the ignore property, don't do anything
|
||||
if (elements[currentElement].ignore && elements[currentElement].ignore.indexOf(pixel.element) != -1) {
|
||||
continue;
|
||||
}
|
||||
elements[currentElement].tool(pixel);
|
||||
}
|
||||
}
|
||||
else if (mode === "replace") {
|
||||
if (outOfBounds(x,y)) {
|
||||
continue;
|
||||
}
|
||||
// Remove pixel at position from currentPixels
|
||||
var index = currentPixels.indexOf(pixelMap[x][y]);
|
||||
if (index > -1) {
|
||||
currentPixels.splice(index, 1);
|
||||
}
|
||||
if (currentElement == "random") {
|
||||
currentPixels.push(new Pixel(x, y, randomChoices[Math.floor(Math.random() * randomChoices.length)]));
|
||||
}
|
||||
else {
|
||||
currentPixels.push(new Pixel(x, y, currentElement));
|
||||
}
|
||||
if (elements[currentElement].customColor) {
|
||||
pixelMap[x][y].color = pixelColorPick(currentElement,currentColor);
|
||||
}
|
||||
}
|
||||
else if (isEmpty(x, y)) {
|
||||
currentPixels.push(new Pixel(x, y, currentElement));
|
||||
if (elements[currentElement].customColor) {
|
||||
pixelMap[x][y].color = pixelColorPick(currentElement,currentColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentElement == "mix") {
|
||||
// 1. repeat for each pixel in mixList
|
||||
// 2. choose 2 random pixels and swap their x and y
|
||||
// 3. remove pixel from mixList
|
||||
for (var i = 0; i < mixList.length; i++) {
|
||||
var pixel1 = mixList[Math.floor(Math.random()*mixList.length)];
|
||||
var pixel2 = mixList[Math.floor(Math.random()*mixList.length)];
|
||||
swapPixels(pixel1,pixel2);
|
||||
mixList.splice(mixList.indexOf(pixel1),1);
|
||||
mixList.splice(mixList.indexOf(pixel2),1);
|
||||
}
|
||||
}
|
||||
};
|
||||
//do cooldown for mouse size > 1
|
||||
|
||||
} else {
|
||||
enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod)
|
||||
alert(`The ${libraryMod} mod is required and has been automatically inserted (reload for this to take effect).`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue