count newly user set pixels that void steps upon too
This commit is contained in:
parent
94c26f0ee2
commit
e6ebc08e26
|
@ -26,6 +26,7 @@ class Void extends WebSocketEvents {
|
||||||
msTimeout: number;
|
msTimeout: number;
|
||||||
pixelStack: Array;
|
pixelStack: Array;
|
||||||
area: Object;
|
area: Object;
|
||||||
|
userArea: Object;
|
||||||
curRadius: number;
|
curRadius: number;
|
||||||
curAngle: number;
|
curAngle: number;
|
||||||
curAngleDelta: number;
|
curAngleDelta: number;
|
||||||
|
@ -42,12 +43,13 @@ class Void extends WebSocketEvents {
|
||||||
const area = TARGET_RADIUS ** 2 * Math.PI;
|
const area = TARGET_RADIUS ** 2 * Math.PI;
|
||||||
const online = webSockets.onlineCounter;
|
const online = webSockets.onlineCounter;
|
||||||
// require an average of 0.25 px / min / user
|
// require an average of 0.25 px / min / user
|
||||||
const requiredSpeed = Math.floor(online / 6);
|
const requiredSpeed = Math.floor(online / 10);
|
||||||
const ppm = Math.ceil(area / EVENT_DURATION_MIN + requiredSpeed);
|
const ppm = Math.ceil(area / EVENT_DURATION_MIN + requiredSpeed);
|
||||||
// timeout between pixels
|
// timeout between pixels
|
||||||
this.msTimeout = 60 * 1000 / ppm;
|
this.msTimeout = 60 * 1000 / ppm;
|
||||||
// area where we log placed pixels
|
// area where we log placed pixels
|
||||||
this.area = new Uint8Array(TILE_SIZE * 3 * TILE_SIZE * 3);
|
this.area = new Uint8Array(TILE_SIZE * 3 * TILE_SIZE * 3);
|
||||||
|
this.userArea = new Uint8Array(TILE_SIZE * 3 * TILE_SIZE * 3);
|
||||||
// array of pixels that we place before continue building (instant-defense)
|
// array of pixels that we place before continue building (instant-defense)
|
||||||
this.pixelStack = [];
|
this.pixelStack = [];
|
||||||
this.curRadius = 0;
|
this.curRadius = 0;
|
||||||
|
@ -87,6 +89,15 @@ class Void extends WebSocketEvents {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check if pixel is set by user during event
|
||||||
|
*/
|
||||||
|
isUserSet(x, y) {
|
||||||
|
const off = x + y * TILE_SIZE * 3;
|
||||||
|
const clr = this.userArea[off];
|
||||||
|
return clr || false;
|
||||||
|
}
|
||||||
|
|
||||||
static coordsToOffset(x, y) {
|
static coordsToOffset(x, y) {
|
||||||
const ox = x % TILE_SIZE;
|
const ox = x % TILE_SIZE;
|
||||||
const oy = y % TILE_SIZE;
|
const oy = y % TILE_SIZE;
|
||||||
|
@ -139,6 +150,11 @@ class Void extends WebSocketEvents {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.sendPixel(x, y, clr);
|
this.sendPixel(x, y, clr);
|
||||||
|
if (this.isUserSet(x, y)) {
|
||||||
|
// if drawing on a user set pixel, wait longer
|
||||||
|
setTimeout(this.voidLoop, this.msTimeout * 4);
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +191,8 @@ class Void extends WebSocketEvents {
|
||||||
const y = vOff + Math.floor(off / TILE_SIZE);
|
const y = vOff + Math.floor(off / TILE_SIZE);
|
||||||
if (this.isSet(x, y, true)) {
|
if (this.isSet(x, y, true)) {
|
||||||
this.pixelStack.push([x, y]);
|
this.pixelStack.push([x, y]);
|
||||||
|
} else {
|
||||||
|
this.userArea[x + y * TILE_SIZE * 3] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ class Event {
|
||||||
});
|
});
|
||||||
chatProvider.broadcastChatMessage(
|
chatProvider.broadcastChatMessage(
|
||||||
'event',
|
'event',
|
||||||
`Alert! Void is rising in 2min near #d,${xNear},${yNear},30`,
|
`Alert! Threat is rising in 2min near #d,${xNear},${yNear},30`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (eventState !== 7) {
|
if (eventState !== 7) {
|
||||||
|
@ -232,7 +232,7 @@ class Event {
|
||||||
this.eventState = 9;
|
this.eventState = 9;
|
||||||
chatProvider.broadcastChatMessage(
|
chatProvider.broadcastChatMessage(
|
||||||
'event',
|
'event',
|
||||||
'Alert! Threat rising!',
|
'Alert! Danger!',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (eventState !== 9) {
|
if (eventState !== 9) {
|
||||||
|
@ -273,7 +273,7 @@ class Event {
|
||||||
if (now > this.chatTimeout) {
|
if (now > this.chatTimeout) {
|
||||||
chatProvider.broadcastChatMessage(
|
chatProvider.broadcastChatMessage(
|
||||||
'event',
|
'event',
|
||||||
`Void reached ${percent}% of its max size`,
|
`Clown Void reached ${percent}% of its max size`,
|
||||||
);
|
);
|
||||||
this.chatTimeout = now + 40000;
|
this.chatTimeout = now + 40000;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user