don't draw pixelNofitication on own pixels

This commit is contained in:
HF 2022-01-04 13:27:29 +01:00
parent c2cbca1387
commit 9d46ec2e1c
6 changed files with 18 additions and 4 deletions

View File

@ -358,11 +358,18 @@ export function receiveCoolDown(
};
}
/*
* draw pixel on canvas
* @param i, j, offset Chunk and offset in chunk
* @param color integer Color Index
* @param notify Bool if pixel notification appears (false when my own pixel)
*/
export function updatePixel(
i,
j,
offset,
color,
notify = true,
) {
return {
type: 'UPDATE_PIXEL',
@ -370,6 +377,7 @@ export function updatePixel(
j,
offset,
color,
notify,
};
}

View File

@ -55,6 +55,7 @@ export type Action =
j: number,
offset: number,
color: ColorIndex,
notify: boolean,
}
| { type: 'RECEIVE_ONLINE', online: number }
| { type: 'RECEIVE_CHAT_MESSAGE',

View File

@ -320,6 +320,7 @@ class SocketServer {
}
client = it.next();
}
console.log(online);
socketEvents.broadcastOnlineCounter(online);
}

View File

@ -101,9 +101,10 @@ export default (store) => (next) => (action) => {
j,
offset,
color,
notify,
} = action;
const renderer = getRenderer();
renderer.renderPixel(i, j, offset, color);
renderer.renderPixel(i, j, offset, color, notify);
break;
}

View File

@ -236,6 +236,7 @@ class Renderer {
j: number,
offset: number,
color,
notify,
) {
const state = this.store.getState();
const {
@ -263,7 +264,9 @@ class Renderer {
context.fillStyle = palette.colors[color];
context.fillRect(px, py, scaleM, scaleM);
pixelNotify.addPixel(x, y);
if (notify) {
pixelNotify.addPixel(x, y);
}
this.forceNextSubrender = true;
}

View File

@ -114,7 +114,7 @@ function revertPredictionsAt(
while (p < clientPredictions.length) {
const [i, j, offset, color] = clientPredictions[p];
store.dispatch(updatePixel(i, j, offset, color));
store.dispatch(updatePixel(i, j, offset, color, false));
p += 1;
}
@ -129,7 +129,7 @@ export function tryPlacePixel(
color,
curColor,
) {
store.dispatch(updatePixel(i, j, offset, color));
store.dispatch(updatePixel(i, j, offset, color, false));
clientPredictions.push([i, j, offset, curColor, color]);
if (pixelQueue.length) {