あ
This commit is contained in:
parent
8f9f5b5100
commit
f1c3af2b89
49 changed files with 989 additions and 310 deletions
|
|
@ -7,9 +7,13 @@
|
|||
|
||||
Object.defineProperties(World.prototype, Object.getOwnPropertyDescriptors({
|
||||
beginFramePerformanceBudgets() {
|
||||
const count = Math.max(1, (this.tarinai || []).length || 1);
|
||||
const mobile = Boolean(global.TarinaiInputMode?.snapshot?.().touchFirst || (global.innerWidth || 9999) <= 760);
|
||||
const aiCap = mobile ? 8 : 12;
|
||||
const envCap = mobile ? 4 : 6;
|
||||
this.workBudget = {
|
||||
ai: Math.max(1, Math.ceil(((this.tarinai || []).length || 1) / 2)),
|
||||
env: Math.max(1, Math.ceil(((this.tarinai || []).length || 1) / 3)),
|
||||
ai: Math.max(1, Math.min(aiCap, Math.ceil(count / 2))),
|
||||
env: Math.max(1, Math.min(envCap, Math.ceil(count / 3))),
|
||||
aiUsed: 0,
|
||||
envUsed: 0,
|
||||
};
|
||||
|
|
@ -286,8 +290,46 @@
|
|||
return false;
|
||||
},
|
||||
|
||||
normalizeColonyLimit(value = 0) {
|
||||
const n = Math.floor(Number(value) || 0);
|
||||
return Number.isFinite(n) && n > 0 ? n : 0;
|
||||
},
|
||||
|
||||
activeTarinaiCount() {
|
||||
let count = 0;
|
||||
for (const t of this.tarinai || []) if (t && !t.dead) count += 1;
|
||||
return count;
|
||||
},
|
||||
|
||||
activeObjectCount() {
|
||||
let count = 0;
|
||||
for (const item of this.items || []) if (item && !item.dead) count += 1;
|
||||
return count;
|
||||
},
|
||||
|
||||
canAddTarinai(count = 1) {
|
||||
const limit = this.normalizeColonyLimit(this.tarinaiPopulationLimit);
|
||||
return limit <= 0 || this.activeTarinaiCount() + Math.max(0, Math.floor(Number(count) || 0)) <= limit;
|
||||
},
|
||||
|
||||
canAddObjects(count = 1) {
|
||||
const limit = this.normalizeColonyLimit(this.objectLimit);
|
||||
return limit <= 0 || this.activeObjectCount() + Math.max(0, Math.floor(Number(count) || 0)) <= limit;
|
||||
},
|
||||
|
||||
setTarinaiPopulationLimit(value = 0) {
|
||||
this.tarinaiPopulationLimit = this.normalizeColonyLimit(value);
|
||||
return this.tarinaiPopulationLimit;
|
||||
},
|
||||
|
||||
setObjectLimit(value = 0) {
|
||||
this.objectLimit = this.normalizeColonyLimit(value);
|
||||
return this.objectLimit;
|
||||
},
|
||||
|
||||
addItem(item, reason = "add-item", opts = {}) {
|
||||
if (!item) return null;
|
||||
if (!this.canAddObjects(1)) return null;
|
||||
if (item.type === "grass" && !this.canAddGrass?.(1)) return null;
|
||||
item.world = this;
|
||||
this.items.push(item);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue