don't draw pixelNofitication on own pixels
This commit is contained in:
parent
c2cbca1387
commit
9d46ec2e1c
|
@ -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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -320,6 +320,7 @@ class SocketServer {
|
||||||
}
|
}
|
||||||
client = it.next();
|
client = it.next();
|
||||||
}
|
}
|
||||||
|
console.log(online);
|
||||||
socketEvents.broadcastOnlineCounter(online);
|
socketEvents.broadcastOnlineCounter(online);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user