Get mech template placement working again
This commit is contained in:
parent
76eb662bcd
commit
b7c6cc8936
@ -278,16 +278,6 @@ export function start(el) {
|
|||||||
|
|
||||||
// Pointer moves over a cell
|
// Pointer moves over a cell
|
||||||
if (targetCell) {
|
if (targetCell) {
|
||||||
//console.log(
|
|
||||||
// "targetCell.classList.contains('frontmost')", targetCell.classList.contains('frontmost'),
|
|
||||||
// "e.target.closest('.frontmost > *')", e.target.closest('.frontmost > *'),
|
|
||||||
// "frontmostStore.get(e.target.closest('.frontmost > *'))", frontmostStore.get(e.target.closest('.frontmost > *')),
|
|
||||||
// "frontmostStore.get(e.target.closest('.frontmost > *')).classList.contains('hover')", frontmostStore.get(e.target.closest('.frontmost > *')).classList.contains('hover')
|
|
||||||
//);
|
|
||||||
|
|
||||||
//if (
|
|
||||||
// !(targetCell.classList.contains('frontmost') && frontmostStore.get(e.target.closest('.frontmost > *')).classList.contains('hover')) && !targetCell.classList.contains('hover')
|
|
||||||
//) {
|
|
||||||
if ([
|
if ([
|
||||||
// that is not already highlighted
|
// that is not already highlighted
|
||||||
!targetCell.classList.contains('hover'),
|
!targetCell.classList.contains('hover'),
|
||||||
@ -297,6 +287,10 @@ export function start(el) {
|
|||||||
console.log('Target cell missing hover... CLEARING HOVERS AND ADDING TO TARGET CELL');
|
console.log('Target cell missing hover... CLEARING HOVERS AND ADDING TO TARGET CELL');
|
||||||
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
|
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
|
||||||
|
|
||||||
|
if (placing[0]?.getAttributeNS(null, 'class') === 'mech-template') {
|
||||||
|
targetCell.prepend(placing[0]);
|
||||||
|
}
|
||||||
|
|
||||||
[...frontmost.children].forEach(child => {
|
[...frontmost.children].forEach(child => {
|
||||||
const parent = frontmostStore.get(child);
|
const parent = frontmostStore.get(child);
|
||||||
parent.append(child);
|
parent.append(child);
|
||||||
@ -481,12 +475,13 @@ export function start(el) {
|
|||||||
|
|
||||||
if (isCounter(toPlace) || isMechTemplate(toPlace)) {
|
if (isCounter(toPlace) || isMechTemplate(toPlace)) {
|
||||||
frontmostStore.set(toPlace, targetCell);
|
frontmostStore.set(toPlace, targetCell);
|
||||||
frontmost.append(toPlace);
|
isMechTemplate(toPlace) ? frontmost.prepend(toPlace) : frontmost.append(toPlace);
|
||||||
if (isCounter(toPlace)) arrangeCounters(frontmost);
|
if (isCounter(toPlace)) arrangeCounters(frontmost);
|
||||||
removeEventListener("keydown", handleMechTemplateRotation);
|
removeEventListener("keydown", handleMechTemplateRotation);
|
||||||
} else if (toPlace && !occupant) {
|
} else if (toPlace && !occupant) {
|
||||||
frontmostStore.set(toPlace, targetCell);
|
frontmostStore.set(toPlace, targetCell);
|
||||||
frontmost.prepend(toPlace);
|
const mechTemplate = frontmost.querySelector('.mech-template');
|
||||||
|
mechTemplate ? mechTemplate.after(toPlace) : frontmost.prepend(toPlace);
|
||||||
placing.push(toPlace);
|
placing.push(toPlace);
|
||||||
getLockedSightLine(svg) ? updateSightLine(targetCell) : clearSightLine();
|
getLockedSightLine(svg) ? updateSightLine(targetCell) : clearSightLine();
|
||||||
} else if (toPlace && occupant) {
|
} else if (toPlace && occupant) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user