bugfix again

This commit is contained in:
biglyderv 2024-10-02 04:22:32 -04:00
parent f5d72c01e5
commit 83e969a6ac
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954
3 changed files with 10 additions and 4 deletions

View file

@ -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 = [

View file

@ -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) {

View file

@ -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]);