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( export function updatePixel(
i, i,
j, j,
offset, offset,
color, color,
notify = true,
) { ) {
return { return {
type: 'UPDATE_PIXEL', type: 'UPDATE_PIXEL',
@ -370,6 +377,7 @@ export function updatePixel(
j, j,
offset, offset,
color, color,
notify,
}; };
} }

View File

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

View File

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

View File

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

View File

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

View File

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