mirror of
https://github.com/DoomKitty87/seafoam.git
synced 2024-12-27 23:47:24 +01:00
added ore routes
This commit is contained in:
parent
352861f945
commit
94a7313470
3 changed files with 200 additions and 4 deletions
1
web-app/seafoam/src-tauri/assets/coal.json
Normal file
1
web-app/seafoam/src-tauri/assets/coal.json
Normal file
File diff suppressed because one or more lines are too long
1
web-app/seafoam/src-tauri/assets/iron.json
Normal file
1
web-app/seafoam/src-tauri/assets/iron.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -17,6 +17,7 @@
|
|||
</div>
|
||||
<div class="menubutton" onclick="resetMenu()"><h2 class="buttontext">GENERATE</h2></div>
|
||||
<div class="menubutton" onclick="routeMenu()""><h2 class="buttontext">OLD ROUTES</h2></div>
|
||||
<div class="menubutton" onclick="oreMenu()""><h2 class="buttontext">ORE ROUTES</h2></div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="menucontainer" id="menua">
|
||||
|
@ -122,7 +123,13 @@
|
|||
<div class="settingbox">
|
||||
<h2 class="settingdesc">Set allowed out of bounds range from the 8x8 chunk area (only use if you know what that means).</h2>
|
||||
<form>
|
||||
<input class="oobform" type="number" value="0">
|
||||
<input class="oobform" type="number" id="oobform" value="0">
|
||||
</form>
|
||||
</div>
|
||||
<div class="settingbox">
|
||||
<h2 class="settingdesc">Set minimum teleport pad separation (3 for dillo, 5 for manual).</h2>
|
||||
<form>
|
||||
<input class="oobform" type="number" id="minpad" value="3">
|
||||
</form>
|
||||
</div>
|
||||
<div class="settingbox">
|
||||
|
@ -187,10 +194,166 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menucontainer" id="menuc">
|
||||
<div class="menuscreen" id="menuc1">
|
||||
<div class="lefttextcontainer">
|
||||
<div class="infobox">
|
||||
<h1 class="infotitle">ORE ROUTES</h1>
|
||||
<h3 class="infodesc">Set preferences then click generate.</h3>
|
||||
</div>
|
||||
<div class="settingbox">
|
||||
<form>
|
||||
<input class="priorityform" id="coal" type="radio" value="coal" name="oretype" checked>
|
||||
<label class="priorityform" for="coal">Coal</label>
|
||||
<br>
|
||||
<input class="priorityform" id="iron" type="radio" value="iron" name="oretype">
|
||||
<label class="priorityform" for="iron">Iron</label>
|
||||
<br>
|
||||
<input class="mfbox" type="checkbox" id="mfore">
|
||||
<label class="mfbox" for="mfore">Magma Fields Only (Ruby/Topaz)</label>
|
||||
<br><br>
|
||||
<input class="oobform" type="number" id="wps" value="100">
|
||||
<label class="anglesettings" for="wps">Waypoint count</label>
|
||||
<br><br>
|
||||
<input class="oobform" type="number" id="minpaddist" value="7">
|
||||
<label class="anglesettings" for="minpaddist">Minimum vein distance (to prevent overlap)</label>
|
||||
<br><br>
|
||||
<input class="oobform" type="number" id="originx" value="512">
|
||||
<input class="oobform" type="number" id="originy" value="150">
|
||||
<input class="oobform" type="number" id="originz" value="512">
|
||||
<br>
|
||||
<h3 class="settingdesc">Desired origin point (x, y, z). Route will start as close as possible to origin.</label>
|
||||
</form>
|
||||
</div>
|
||||
<div class="routeresults">
|
||||
<div class="routebox">
|
||||
<p id="oreout" class="routeoutput"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nextbutton">
|
||||
<h2 class="nextbuttontext" onclick="genOre()">GENERATE</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
async function generateRoute(sector, allowedOOB, priority, waypointCount, angleEnable, angle22, angle33, mfOnly, checkingLOS, ignoreDens) {
|
||||
async function oreRoute(oreType, waypointCount, mfOnly, minDist, originX, originY, originZ) {
|
||||
originX -= 202;
|
||||
originZ -= 202;
|
||||
originY = parseInt(originY);
|
||||
console.log(originX, originY, originZ);
|
||||
const readTextFile = window.__TAURI__.fs.readTextFile;
|
||||
const resolveResource = window.__TAURI__.path.resolveResource;
|
||||
const orePath = await resolveResource('assets/' + oreType + '.json');
|
||||
const oreFile = await readTextFile(orePath);
|
||||
const oreData = JSON.parse(oreFile);
|
||||
//Determine starting block somehow
|
||||
const oreArray = [];
|
||||
for (let x = 0; x < 640; x++) {
|
||||
oreArray[x] = [];
|
||||
oreArray[x].length = 256;
|
||||
for (let y = 0; y < 256; y++) {
|
||||
oreArray[x][y] = [];
|
||||
oreArray[x][y].length = 640;
|
||||
for (let z = 0; z < 640; z++) {
|
||||
oreArray[x][y][z] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(oreData.length);
|
||||
for (let i = 0; i < oreData.length; i++) {
|
||||
oreArray[oreData[i][0] - 202][oreData[i][1]][oreData[i][2] - 202] = 1;
|
||||
}
|
||||
console.log("Done loading ore.");
|
||||
var foundStart = false;
|
||||
const path = [];
|
||||
const usedPositions = [];
|
||||
/*
|
||||
while (!foundStart) {
|
||||
var x = Math.floor(Math.random() * 640);
|
||||
var y = Math.floor(Math.random() * 256);
|
||||
var z = Math.floor(Math.random() * 640);
|
||||
if (oreArray[x][y][z] == 1) foundStart = true;
|
||||
else continue;
|
||||
path.push(x, y, z);
|
||||
usedPositions.push(x, y, z);
|
||||
}
|
||||
*/
|
||||
var startX = 25;
|
||||
var startY = 25;
|
||||
var startZ = 25;
|
||||
while (!foundStart) {
|
||||
for (let x = -startX; x < startX; x++) {
|
||||
for (let y = -startY; y < startY; y++) {
|
||||
for (let z = -startZ; z < startZ; z++) {
|
||||
if (mfOnly && y >= 64) continue;
|
||||
if (originX + x < 0 || originX + x > 639 || originY + y < 0 || originY + y > 255 || originZ + z < 0 || originZ + z > 639) continue;
|
||||
if (oreArray[originX + x][originY + y][originZ + z] != 1) continue;
|
||||
path.push(originX + x, originY + y, originZ + z);
|
||||
usedPositions.push(originX + x, originY + y, originZ + z);
|
||||
foundStart = true;
|
||||
break;
|
||||
}
|
||||
if (foundStart) break;
|
||||
}
|
||||
if (foundStart) break;
|
||||
}
|
||||
startX++;
|
||||
startY++;
|
||||
startZ++;
|
||||
}
|
||||
while (path.length / 3 != waypointCount) {
|
||||
//console.log(path.length / 3);
|
||||
var foundNext = false;
|
||||
var xRad = minDist;
|
||||
var yRad = minDist;
|
||||
var zRad = minDist;
|
||||
while (!foundNext) {
|
||||
for (let x = -xRad; x < xRad; x++) {
|
||||
for (let y = -yRad; y < yRad; y++) {
|
||||
for (let z = -zRad; z < zRad; z++) {
|
||||
if (x == 0 && y == 0 && z == 0) continue;
|
||||
if (Math.abs(x) < minDist && Math.abs(y) < minDist && Math.abs(z) < minDist) continue;
|
||||
if (mfOnly && path[path.length - 2] + y >= 64) continue;
|
||||
if (path[path.length - 3] + x < 0 || path[path.length - 3] + x > 639 || path[path.length - 2] + y < 0 || path[path.length - 2] + y > 255 || path[path.length - 1] + z < 0 || path[path.length - 1] + z > 639) continue;
|
||||
if (oreArray[path[path.length - 3] + x][path[path.length - 2] + y][path[path.length - 1] + z] != 1) continue;
|
||||
var cntue = false;
|
||||
for (let i = 0; i < usedPositions.length / 3; i++) {
|
||||
if (Math.abs(usedPositions[i * 3] - (path[path.length - 3] + x)) < minDist && Math.abs(usedPositions[i * 3 + 1] - (path[path.length - 2] + y)) < minDist && Math.abs(usedPositions[i * 3 + 2] - (path[path.length - 1] + z)) < minDist) {
|
||||
cntue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cntue) continue;
|
||||
var newx = path[path.length - 3] + x;
|
||||
var newy = path[path.length - 2] + y;
|
||||
var newz = path[path.length - 1] + z;
|
||||
path.push(newx, newy, newz);
|
||||
usedPositions.push(path[path.length - 3]);
|
||||
usedPositions.push(path[path.length - 2]);
|
||||
usedPositions.push(path[path.length - 1]);
|
||||
foundNext = true;
|
||||
break;
|
||||
}
|
||||
if (foundNext) break;
|
||||
}
|
||||
if (foundNext) break;
|
||||
}
|
||||
xRad++;
|
||||
yRad++;
|
||||
zRad++;
|
||||
}
|
||||
}
|
||||
var pathOutput = "[";
|
||||
for (var i = 0; i < path.length / 3; i++) {
|
||||
pathOutput += "{\"x\":" + (path[i * 3] + 202) + ",\"y\":" + path[i * 3 + 1] + ",\"z\":" + (path[i * 3 + 2] + 202) + ",\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"" + (i + 1) + "\"}}";
|
||||
if (i != path.length / 3 - 1) pathOutput += ",";
|
||||
}
|
||||
pathOutput += "]";
|
||||
document.getElementById("oreout").innerHTML = pathOutput;
|
||||
}
|
||||
async function generateRoute(sector, allowedOOB, priority, waypointCount, angleEnable, angle22, angle33, mfOnly, checkingLOS, ignoreDens, minPadDist) {
|
||||
const angle3 = Math.min(angle33, 360 - angle33);
|
||||
const angle2 = Math.min(angle22, 360 - angle22);
|
||||
allowedOOB = parseInt(allowedOOB);
|
||||
|
@ -364,7 +527,7 @@
|
|||
weightChart[j] = Infinity;
|
||||
break;
|
||||
}
|
||||
if (Math.abs(padCoords[j * 3] - padCoords[usedPads[k] * 3]) < 3 && Math.abs(padCoords[j * 3 + 1] - padCoords[usedPads[k] * 3 + 1]) < 3 && Math.abs(padCoords[j * 3 + 2] - padCoords[usedPads[k] * 3 + 2]) < 3) {
|
||||
if (Math.abs(padCoords[j * 3] - padCoords[usedPads[k] * 3]) < minPadDist && Math.abs(padCoords[j * 3 + 1] - padCoords[usedPads[k] * 3 + 1]) < minPadDist && Math.abs(padCoords[j * 3 + 2] - padCoords[usedPads[k] * 3 + 2]) < minPadDist) {
|
||||
weightChart[j] = Infinity;
|
||||
break;
|
||||
}
|
||||
|
@ -480,6 +643,7 @@
|
|||
var mfOnly = false;
|
||||
var checkingLOS = true;
|
||||
var noDens = false;
|
||||
var minPadDist = 3;
|
||||
|
||||
var waypointNumber = 150;
|
||||
|
||||
|
@ -493,6 +657,7 @@
|
|||
document.getElementById("menua1").style.opacity = 1;
|
||||
document.getElementById("menua1").style.display = "flex";
|
||||
document.getElementById("menub").style.height = 0;
|
||||
document.getElementById("menuc").style.height = 0;
|
||||
|
||||
function selectSquare(index) {
|
||||
if (activeSquareIndex != -1) {
|
||||
|
@ -506,7 +671,15 @@
|
|||
function getRoute() {
|
||||
var output = generateRoute(activeSquareIndex, allowedOOB, priority, waypointNumber, angleEnable, angle22, angle33, mfOnly, checkingLOS, noDens);
|
||||
}
|
||||
function genOre() {
|
||||
var oreType;
|
||||
if (document.getElementById("coal").checked) oreType = "coal";
|
||||
else oreType = "iron";
|
||||
oreRoute(oreType, document.getElementById("wps").value, document.getElementById("mfore").checked, document.getElementById("minpaddist").value, document.getElementById("originx").value, document.getElementById("originy").value, document.getElementById("originz").value);
|
||||
}
|
||||
async function resetMenu() {
|
||||
document.getElementById("menuc").style.height = 0;
|
||||
document.getElementById("menuc" + (currentStep)).style.display = "none";
|
||||
document.getElementById("menub").style.height = 0;
|
||||
document.getElementById("menub1").style.opacity = 0;
|
||||
document.getElementById("menua" + (currentStep)).style.opacity = 0;
|
||||
|
@ -538,6 +711,8 @@
|
|||
if (step == 4) getRoute();
|
||||
}
|
||||
async function routeMenu() {
|
||||
document.getElementById("menuc").style.height = 0;
|
||||
document.getElementById("menuc" + (currentStep)).style.display = "none";
|
||||
document.getElementsByClassName("progressbar")[0].style.opacity = 0;
|
||||
document.getElementById("menua" + (currentStep)).style.opacity = 0;
|
||||
document.getElementsByClassName("progressitem")[currentStep - 1].setAttribute("data-active", "false");
|
||||
|
@ -552,6 +727,24 @@
|
|||
document.getElementById("menub1").style.display = "flex";
|
||||
document.getElementById("menub1").style.opacity = 1;
|
||||
}
|
||||
async function oreMenu() {
|
||||
document.getElementById("menub").style.height = 0;
|
||||
document.getElementById("menub1").style.opacity = 0;
|
||||
document.getElementsByClassName("progressbar")[0].style.opacity = 0;
|
||||
document.getElementById("menua" + (currentStep)).style.opacity = 0;
|
||||
document.getElementsByClassName("progressitem")[currentStep - 1].setAttribute("data-active", "false");
|
||||
document.getElementsByClassName("dot")[currentStep - 1].setAttribute("data-active", "false");
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
document.getElementById("menua" + (currentStep)).style.display = "none";
|
||||
document.getElementById("menua").style.height = 0;
|
||||
document.getElementById("menub1").style.display = "none";
|
||||
currentStep = 1;
|
||||
if (activeSquareIndex != -1) document.getElementById(activeSquareIndex).style.backgroundColor = "#0e141b";
|
||||
activeSquareIndex = -1;
|
||||
document.getElementById("menuc").style.height = "100%";
|
||||
document.getElementById("menuc1").style.display = "flex";
|
||||
document.getElementById("menuc1").style.opacity = 1;
|
||||
}
|
||||
function moveStep() {
|
||||
if (currentStep == 1 && activeSquareIndex == -1) return;
|
||||
if (currentStep == 1) {
|
||||
|
@ -561,7 +754,7 @@
|
|||
if (currentStep == 2) waypointNumber = document.getElementById("wpform").value;
|
||||
if (currentStep == 3) {
|
||||
if (document.getElementById("tp").checked) priority = "tp"; else priority = "dens";
|
||||
allowedOOB = document.getElementsByClassName("oobform")[0].value;
|
||||
allowedOOB = document.getElementById("oobform").value;
|
||||
if (document.getElementById("anglecheck").checked) {
|
||||
angleEnable = true;
|
||||
angle22 = document.getElementById("angle22").value;
|
||||
|
@ -569,6 +762,7 @@
|
|||
} else angleEnable = false;
|
||||
if (document.getElementById("los").checked) checkingLOS = true;
|
||||
else checkingLOS = false;
|
||||
minPadDist = document.getElementById("minpad").value;
|
||||
document.getElementById("routeout").innerHTML = "Route loading...";
|
||||
document.getElementById("routestats").innerHTML = "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue