MCPcopy Create free account
hub / github.com/YGYOOO/WorldX / hasWalkableLine

Method hasWalkableLine

client/src/systems/MapManager.ts:143–168  ·  view source on GitHub ↗
(
    from: { gx: number; gy: number },
    to: { gx: number; gy: number },
  )

Source from the content-addressed store, hash-verified

141 }
142
143 hasWalkableLine(
144 from: { gx: number; gy: number },
145 to: { gx: number; gy: number },
146 ): boolean {
147 if (!this.isWalkable(from.gx, from.gy) || !this.isWalkable(to.gx, to.gy)) {
148 return false;
149 }
150
151 const start = this.gridToPixel(from.gx, from.gy);
152 const end = this.gridToPixel(to.gx, to.gy);
153 const distance = Math.hypot(end.x - start.x, end.y - start.y);
154 const stepSize = Math.max(4, this.tileSize / 3);
155 const steps = Math.max(1, Math.ceil(distance / stepSize));
156
157 for (let i = 0; i <= steps; i++) {
158 const t = i / steps;
159 const sampleX = start.x + (end.x - start.x) * t;
160 const sampleY = start.y + (end.y - start.y) * t;
161 const sample = this.pixelToGrid(sampleX, sampleY);
162 if (!this.isWalkable(sample.gx, sample.gy)) {
163 return false;
164 }
165 }
166
167 return true;
168 }
169
170 getRandomWalkablePointInLocation(
171 locationId: string,

Callers

nothing calls this directly

Calls 3

isWalkableMethod · 0.95
gridToPixelMethod · 0.95
pixelToGridMethod · 0.95

Tested by

no test coverage detected