Migrating position notification into the User class
This commit is contained in:
parent
892d1555b8
commit
23cea1c835
7 changed files with 59 additions and 52 deletions
|
@ -3,6 +3,7 @@ import { PointInterface } from "./Websocket/PointInterface";
|
|||
import {Zone} from "_Model/Zone";
|
||||
import {Movable} from "_Model/Movable";
|
||||
import {PositionInterface} from "_Model/PositionInterface";
|
||||
import {PositionNotifier} from "_Model/PositionNotifier";
|
||||
|
||||
export class User implements Movable {
|
||||
public listenedZones: Set<Zone>;
|
||||
|
@ -10,14 +11,22 @@ export class User implements Movable {
|
|||
|
||||
public constructor(
|
||||
public id: number,
|
||||
public position: PointInterface,
|
||||
private position: PointInterface,
|
||||
public silent: boolean,
|
||||
|
||||
private positionNotifier: PositionNotifier
|
||||
) {
|
||||
this.listenedZones = new Set<Zone>();
|
||||
|
||||
this.positionNotifier.enter(this);
|
||||
}
|
||||
|
||||
public getPosition(): PositionInterface {
|
||||
public getPosition(): PointInterface {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public setPosition(position: PointInterface): void {
|
||||
const oldPosition = this.position;
|
||||
this.position = position;
|
||||
this.positionNotifier.updatePosition(this, position, oldPosition);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue