Migrating position notification into the User class
This commit is contained in:
+12
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user