added isActivatable() method to implement through interface

This commit is contained in:
Hanusiak Piotr 2022-01-31 13:00:14 +01:00
parent 2322f5f76d
commit 989897cb01
8 changed files with 32 additions and 247 deletions

View file

@ -1,6 +1,7 @@
export interface ActivatableInterface {
readonly activationRadius: number;
isActivatable: () => boolean;
activate: () => void;
getPosition: () => { x: number, y: number };
}

View file

@ -70,7 +70,7 @@ export class ActivatablesManager {
let closestObject: ActivatableInterface | undefined = undefined;
for (const [object, distance] of this.activatableObjectsDistances.entries()) {
if (object.activationRadius > distance && shortestDistance > distance) {
if (object.isActivatable() && object.activationRadius > distance && shortestDistance > distance) {
shortestDistance = distance;
closestObject = object;
}