Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(engine): don't convert teleport op to walk/run #1391

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/engine/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ class World {
private processInfo(): void {
// TODO: benchmark this?
for (const player of this.players) {
player.convertMovementDir();
player.reorient();

const grid = this.playerGrid;
Expand All @@ -1112,7 +1111,6 @@ class World {
}

for (const npc of this.npcs) {
npc.convertMovementDir();
npc.reorient();
this.npcRenderer.computeInfo(npc);
}
Expand Down
34 changes: 0 additions & 34 deletions src/engine/entity/PathingEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,40 +309,6 @@ export default abstract class PathingEntity extends Entity {
}
}

convertMovementDir() {
// temp variables to convert movement operations
let walkDir = this.walkDir;
let runDir = this.runDir;
let tele = this.tele;

// convert p_teleport() into walk or run
const distanceMoved = CoordGrid.distanceTo(this, {
x: this.lastTickX,
z: this.lastTickZ,
width: this.width,
length: this.length
});
if (tele && !this.jump && distanceMoved <= 2) {
if (distanceMoved === 2) {
// run
walkDir = CoordGrid.face(this.lastTickX, this.lastTickZ, this.x, this.z);
const walkX = CoordGrid.moveX(this.lastTickX, walkDir);
const walkZ = CoordGrid.moveZ(this.lastTickZ, walkDir);
runDir = CoordGrid.face(walkX, walkZ, this.x, this.z);
} else {
// walk
walkDir = CoordGrid.face(this.lastTickX, this.lastTickZ, this.x, this.z);
runDir = -1;
}

tele = false;
}

this.walkDir = walkDir;
this.runDir = runDir;
this.tele = tele;
}

/**
* Face and orient to a specified fine coord.
* Enable `client` to update connected clients about the new focus, enabling the face_coord mask.
Expand Down