bugfix again
This commit is contained in:
parent
f5d72c01e5
commit
83e969a6ac
3 changed files with 10 additions and 4 deletions
|
@ -27,8 +27,10 @@ class Player {
|
|||
|
||||
this.r = 1;
|
||||
|
||||
this.isYou = false;
|
||||
|
||||
this.serverProps = [
|
||||
'type', 'camera','pos','vel','rot','dir','ticks','health','you','isPlayer','headCount','isMenu','r'
|
||||
'type', 'camera','pos','vel','rot','dir','ticks','health','you','isPlayer','headCount','isMenu','r','isYou'
|
||||
];
|
||||
|
||||
this.legalProps = [
|
||||
|
|
3
game.js
3
game.js
|
@ -21,6 +21,7 @@ class Game extends GameBasic {
|
|||
if (!client.active) continue;
|
||||
|
||||
let wsEnt = client.ent;
|
||||
wsEnt.isYou = true;
|
||||
if (!wsEnt) continue;
|
||||
|
||||
let filtered;
|
||||
|
@ -40,6 +41,8 @@ class Game extends GameBasic {
|
|||
});
|
||||
|
||||
client.send(JSON.stringify(filtered));
|
||||
|
||||
wsEnt.isYou = false;
|
||||
}
|
||||
|
||||
for (let entity of entities) {
|
||||
|
|
|
@ -126,8 +126,6 @@ class Game extends GameBasic {
|
|||
this.ws.close();
|
||||
this.ws = new WebSocket(origin);
|
||||
this.ws.addEventListener('message', function (e) { that.recv(e) });
|
||||
this.player = new Player(false, true);
|
||||
this.entities.push(this.player);
|
||||
} else if (player.isMenu) {
|
||||
player.r = Math.floor(Math.abs(player.rot / 1.2) % emojis.length);
|
||||
player.isMenu = false;
|
||||
|
@ -180,7 +178,10 @@ class Game extends GameBasic {
|
|||
|
||||
let matchingPlayer = entList.filter(x => x.you == you)
|
||||
|
||||
if (matchingPlayer.length == 0) matchingPlayer = entList.filter(x => x.type == 'Player');
|
||||
|
||||
if (matchingPlayer.length == 0) {
|
||||
matchingPlayer = entList.filter(x => x.isYou);
|
||||
}
|
||||
|
||||
this.player = Object.assign(this.player || new Player(false, false), matchingPlayer[0]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue