Fix not following users getting "stuck" in groups
This commit is contained in:
parent
a481376633
commit
ab994183e5
@ -217,9 +217,22 @@ export class GameRoom {
|
|||||||
} else {
|
} else {
|
||||||
// If the user is part of a group:
|
// If the user is part of a group:
|
||||||
// should he leave the group?
|
// should he leave the group?
|
||||||
const distance = GameRoom.computeDistanceBetweenPositions(user.getPosition(), user.group.getPosition());
|
const leaveIfOutOfRadius = (user: User) => {
|
||||||
if (user.following.length === 0 && distance > this.groupRadius) {
|
if (user.group === undefined) {
|
||||||
this.leaveGroup(user);
|
return;
|
||||||
|
}
|
||||||
|
const usrPos = user.getPosition();
|
||||||
|
const grpPos = user.group.getPosition();
|
||||||
|
const distance = GameRoom.computeDistanceBetweenPositions(usrPos, grpPos);
|
||||||
|
if (distance > this.groupRadius) {
|
||||||
|
this.leaveGroup(user);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (user.following.length > 0) {
|
||||||
|
const users = user.group.getUsers().filter((u) => u.following.length === 0);
|
||||||
|
users.forEach((foreignUser) => leaveIfOutOfRadius(foreignUser));
|
||||||
|
} else {
|
||||||
|
leaveIfOutOfRadius(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user