y
This commit is contained in:
parent
61718e2981
commit
f657b6a4a4
94 changed files with 3970 additions and 1241 deletions
|
|
@ -347,7 +347,10 @@
|
|||
Object.defineProperties(World.prototype, Object.getOwnPropertyDescriptors({
|
||||
nearest(entity, types, maxDist = Infinity) {
|
||||
let best = null, bestD = maxDist;
|
||||
const candidates = Number.isFinite(maxDist) ? this.nearbyItems(entity.x, entity.y, maxDist) : this.items;
|
||||
const includeGrass = Array.isArray(types) && types.includes("grass");
|
||||
const candidates = Number.isFinite(maxDist)
|
||||
? (includeGrass ? this.nearbyItems(entity.x, entity.y, maxDist) : (this.nearbyNonGrassItems?.(entity.x, entity.y, maxDist) || this.nearbyItems(entity.x, entity.y, maxDist)))
|
||||
: this.items;
|
||||
for (const it of candidates) {
|
||||
if (it.dead || !types.includes(it.type)) continue;
|
||||
if (entity?.shouldAvoidTarget && entity.shouldAvoidTarget(it)) continue;
|
||||
|
|
@ -574,7 +577,7 @@
|
|||
const qr = Math.ceil(inflatedRadius / q);
|
||||
const cacheLimit = Math.min(72, Math.max(limit + 6, Math.ceil(limit * 1.35)));
|
||||
const cacheKey = cacheable
|
||||
? `${this.spatialVersion || 0}:${this.spatialDirtyMarksTotal || 0}:${qx},${qy},${qr},${cacheLimit},${maxRects}`
|
||||
? `${this.routingObstacleVersion || 0}:${qx},${qy},${qr},${cacheLimit},${maxRects}`
|
||||
: "";
|
||||
if (cacheable) {
|
||||
if (!this._solidObstacleRectQueryCache) this._solidObstacleRectQueryCache = new Map();
|
||||
|
|
@ -775,9 +778,10 @@
|
|||
const slop = Number.isFinite(opts.slop) ? opts.slop : 0.8;
|
||||
const defaultMaxPush = r.oriented && insidePenetration > 0 ? Math.max(18, hitRadius * 2.8) : Math.max(10, hitRadius * 0.92);
|
||||
const maxPush = Math.max(1, Number.isFinite(opts.maxPush) ? opts.maxPush : defaultMaxPush);
|
||||
const push = r.oriented && insidePenetration > 0
|
||||
const rawPush = r.oriented && insidePenetration > 0
|
||||
? Math.min(insidePenetration + hitRadius + slop, maxPush)
|
||||
: Math.min(hitRadius - d + slop, maxPush);
|
||||
const push = rawPush;
|
||||
t.x += nx * push;
|
||||
t.y += ny * push;
|
||||
t.lastSolidObstacleCollisionSource = r.item || null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue