call activate() method on space key up
This commit is contained in:
parent
3af6461c01
commit
f42c7564b9
@ -1679,12 +1679,12 @@ ${escapedMessage}
|
||||
private handleCurrentPlayerHasMovedEvent(event: HasPlayerMovedEvent): void {
|
||||
//listen event to share position of user
|
||||
this.pushPlayerPosition(event);
|
||||
this.nearestActivatableObject = this.getNearestActivatableObject();
|
||||
this.nearestActivatableObject = this.findNearestActivatableObject();
|
||||
this.outlineItem(event);
|
||||
this.gameMap.setPosition(event.x, event.y);
|
||||
}
|
||||
|
||||
private getNearestActivatableObject(): ActivatableInterface | undefined {
|
||||
private findNearestActivatableObject(): ActivatableInterface | undefined {
|
||||
let shortestDistance: number = Infinity;
|
||||
let closestObject: ActivatableInterface | undefined = undefined;
|
||||
const currentPlayerPos = this.CurrentPlayer.getPosition();
|
||||
@ -2225,4 +2225,8 @@ ${escapedMessage}
|
||||
public getPathfindingManager(): PathfindingManager {
|
||||
return this.pathfindingManager;
|
||||
}
|
||||
|
||||
public getNearestActivatableObject(): ActivatableInterface | undefined {
|
||||
return this.nearestActivatableObject
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
||||
|
||||
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||
this.gameScene.activateOutlinedItem();
|
||||
this.gameScene.getNearestActivatableObject()?.activate();
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user