y
This commit is contained in:
parent
61718e2981
commit
f657b6a4a4
94 changed files with 3970 additions and 1241 deletions
|
|
@ -106,7 +106,7 @@ function foodPriorityScore(tarinai, item, distance = 0) {
|
|||
|
||||
function hasBetterFoodThanZunchiNearby(tarinai, world, maxDist = 180) {
|
||||
if (!tarinai || !world) return false;
|
||||
const source = world.nearbyItems?.(tarinai.x, tarinai.y, maxDist, true) || world.items || [];
|
||||
const source = world.nearbyFood?.(tarinai.x, tarinai.y, maxDist, true) || world.nearbyItems?.(tarinai.x, tarinai.y, maxDist, true) || world.items || [];
|
||||
for (const it of source) {
|
||||
if (!it || it.dead) continue;
|
||||
const type = effectiveFoodTypeForItem(it);
|
||||
|
|
@ -176,7 +176,13 @@ function findNearestItemWithRole(world, tarinai, role, maxDist = 520) {
|
|||
// crowded world \u3067\u6bce\u56de world.items \u5168\u4f53\u3092\u8db3\u3059\u7d4c\u8def\u3092\u907f\u3051\u308b\u3002
|
||||
if (foodLikeRole) {
|
||||
if (world?.itemsOfType) {
|
||||
for (const type of foodRoleSearchTypes(role)) for (const it of world.itemsOfType(type) || []) addCandidate(it);
|
||||
for (const type of foodRoleSearchTypes(role)) {
|
||||
// Grass is static and already represented by nearbyFood. Re-adding the
|
||||
// entire global grass bucket here made every food-target search O(all
|
||||
// grass), which was especially costly around 100 grass plants.
|
||||
if (type === "grass" && world?.nearbyFood) continue;
|
||||
for (const it of world.itemsOfType(type) || []) addCandidate(it);
|
||||
}
|
||||
} else if (Array.isArray(world?.items)) {
|
||||
for (const it of world.items) addCandidate(it);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue