Skip to content

Commit 431e6b5

Browse files
committed
Fixing broken import and following issues
1 parent 656da23 commit 431e6b5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/game-engine/world/actor/actor.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { world } from '@engine/game-server';
1313
import { WorldInstance } from '@engine/world/instances';
1414
import { Player } from '@engine/world/actor/player/player';
1515
import { ActionCancelType, ActionPipeline } from '@engine/world/action';
16-
import { LocationObject } from '@runejs/cache-parser';
16+
import { LandscapeObject } from '@runejs/filestore';
17+
1718

1819
/**
1920
* Handles an actor within the game world.
@@ -84,20 +85,20 @@ export abstract class Actor {
8485
* The promise will be rejected if the actor's walking queue changes or their movement is otherwise canceled.
8586
* @param gameObject The game object to wait for the actor to reach.
8687
*/
87-
public async waitForPathing(gameObject: LocationObject): Promise<void>;
88+
public async waitForPathing(gameObject: LandscapeObject): Promise<void>;
8889

8990
/**
9091
* Waits for the actor to reach the specified game object before resolving it's promise.
9192
* The promise will be rejected if the actor's walking queue changes or their movement is otherwise canceled.
9293
* @param target The position or game object that the actor needs to reach for the promise to resolve.
9394
*/
94-
public async waitForPathing(target: Position | LocationObject): Promise<void>;
95-
public async waitForPathing(target: Position | LocationObject): Promise<void> {
95+
public async waitForPathing(target: Position | LandscapeObject): Promise<void>;
96+
public async waitForPathing(target: Position | LandscapeObject): Promise<void> {
9697
if(this.position.withinInteractionDistance(target)) {
9798
return;
9899
}
99100

100-
await new Promise((resolve, reject) => {
101+
await new Promise<void>((resolve, reject) => {
101102
this.metadata.walkingTo = target instanceof Position ? target : new Position(target.x, target.y, target.level);
102103

103104
const inter = setInterval(() => {
@@ -130,6 +131,10 @@ export abstract class Actor {
130131
}
131132

132133
public async moveBehind(target: Actor): Promise<boolean> {
134+
if(this.position.level !== target.position.level) {
135+
return false;
136+
}
137+
133138
const distance = Math.floor(this.position.distanceBetween(target.position));
134139
if(distance > 16) {
135140
this.clearFaceActor();
@@ -152,6 +157,10 @@ export abstract class Actor {
152157
}
153158

154159
public async moveTo(target: Actor): Promise<boolean> {
160+
if(this.position.level !== target.position.level) {
161+
return false;
162+
}
163+
155164
const distance = Math.floor(this.position.distanceBetween(target.position));
156165
if(distance > 16) {
157166
this.clearFaceActor();
@@ -171,7 +180,11 @@ export abstract class Actor {
171180
this.metadata['following'] = target;
172181

173182
this.moveBehind(target);
174-
const subscription = target.walkingQueue.movementEvent.subscribe(async () => this.moveBehind(target));
183+
const subscription = target.walkingQueue.movementEvent.subscribe(async () => {
184+
if(!this.moveBehind(target)) {
185+
this.actionsCancelled.next(null);
186+
}
187+
});
175188

176189
this.actionsCancelled.pipe(
177190
filter(type => type !== 'pathing-movement'),

0 commit comments

Comments
 (0)