stable
This commit is contained in:
parent
0f1cb2fe6c
commit
129c07183a
51 changed files with 5711 additions and 1122 deletions
|
|
@ -37,6 +37,31 @@ function stopFailedBuildPlan(t, world, type = "", reason = "") {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
function forceBuiltStructureVisualRefresh(world, structure, reason = "structure-built") {
|
||||
if (!world) return;
|
||||
world.drawListDirty = true;
|
||||
if (world._renderStack) world._renderStack.signature = "";
|
||||
if (world._visibleRenderStack) {
|
||||
world._visibleRenderStack.backItems = [];
|
||||
world._visibleRenderStack.layered = [];
|
||||
world._visibleRenderStack.carriedPlushies = [];
|
||||
world._visibleRenderStack.lodgedPins = [];
|
||||
}
|
||||
world.markItemBucketsDirty?.(reason);
|
||||
world.markSpatialDirty?.(reason);
|
||||
world.ensureItemBuckets?.(reason);
|
||||
world.ensureSpatial?.(reason);
|
||||
if (structure) {
|
||||
structure.world = world;
|
||||
structure._builtVisibleAt = Number(world.time || 0) || 0;
|
||||
}
|
||||
if (typeof globalThis.render === "function") {
|
||||
globalThis.render();
|
||||
globalThis.requestAnimationFrame?.(() => globalThis.render?.());
|
||||
}
|
||||
}
|
||||
|
||||
function findStructureBuildSpot(t, world, type) {
|
||||
const baseX = Number.isFinite(t?.x) ? t.x : 0;
|
||||
const baseY = Number.isFinite(t?.y) ? t.y : 0;
|
||||
|
|
@ -114,9 +139,12 @@ function continueBuildPlan(t, world, dt) {
|
|||
structure.x = t.x;
|
||||
structure.y = t.y - Math.max(28, (t.radius || 24) * 1.28);
|
||||
}
|
||||
world.addItem?.(structure, `build:${plan.type}`) || world.items.push(structure);
|
||||
world.drawListDirty = true;
|
||||
const addedStructure = world.addItem?.(structure, `build:${plan.type}`) || (world.items.push(structure), structure);
|
||||
if (!addedStructure) {
|
||||
return stopFailedBuildPlan(t, world, plan.type, "作る場所が見つからない");
|
||||
}
|
||||
structure.use?.(t, world);
|
||||
forceBuiltStructureVisualRefresh(world, structure, `build:${plan.type}:visual-refresh`);
|
||||
t.setActionState?.("idle", { target: structure, reason: `${label}\u3092\u4f5c\u3063\u305f`, sleeping: false });
|
||||
applyNeedSatisfaction(t, { fulfill: plan.type === "plushie" ? 50 : 36, safety: plan.type === "plushie" ? 4 : 8 }, plan.type);
|
||||
t.buildPlan = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue