tarinai/js/world.js
2026-06-24 13:48:22 +09:00

82 lines
2.5 KiB
JavaScript

"use strict";
class World { constructor() {
this.w = 1000;
this.h = 720;
this.viewportW = 1000;
this.viewportH = 720;
this.time = 0;
this.day = 1;
this.paused = false;
this.speed = 1;
this.tool = "observe";
this.toolSize = "medium";
this.toolSizes = {};
this.tarinai = [];
this.frozenTarinai = [];
this.items = [];
this.ants = [];
this.effects = [];
this.logs = [];
this.events = window.TarinaiEvents || null;
this.eventCounters = {};
this.countsTimer = 0;
this.compactTimer = 0;
this.drawSortTimer = 0;
this.drawListDirty = true;
this.antUpdatePhase = 0;
this.selected = null;
this.deadCount = 0;
this.liveIdNext = 1;
this.liveIdFree = [];
this.liveIdSerial = 0;
this.liveTarinai = new Map();
this.lastBirthAt = -999;
this.maxGeneration = 1;
this.family = {};
this.familyVersion = 0;
this.familyTreeDirty = true;
this.familyTreeDirtyReason = "init";
this.relationNotices = {};
this.resolvedFightIds = {};
this.pointer = { x: 0, y: 0, inside: false, motion: 0, movedAt: 0 };
this.lastPhase = "";
this.weather = "sunny";
this.fieldType = "garden";
this.fieldZoom = 1;
this.cameraX = 0;
this.cameraY = 0;
this.shakeTimer = 0;
this.shakeDuration = 0;
this.shakeStrength = 0;
this.nextWeatherChange = rand(CONFIG.weatherChangeMin, CONFIG.weatherChangeMax);
this.spatial = new SpatialGrid(96);
this.spatialItemScratch = [];
this.spatialTarinaiScratch = [];
this.spatialAntScratch = [];
this.spatialObstacleScratch = [];
this.spatialFoodScratch = [];
this.spatialHazardScratch = [];
this.spatialVersion = 0;
this.spatialDirty = true;
this.terrainDirty = true;
this.terrainVersion = 1;
this.terrainDirtyReason = "init";
this.terrainLastDirtyAt = 0;
this.lastTerrainSignature = "";
this.drawList = [];
this.itemCounts = {};
this.effectCounts = {};
this.colonyMood = { id: "relaxed", label: "\u306e\u3093\u3073\u308a", description: "\u4f55\u3082\u7121\u3057", effects: { personality: {} } };
this.lastColonyMoodDay = 0;
this.foodSpoilagePenalty = 0;
this.foodSpoilageEvents = 0;
this.updateItemCounts();
this.updateEffectCounts();
this.markTerrainDirty?.("reset");
this.rebuildSpatial(true);
}
}
if (typeof window !== "undefined") window.World = World;
if (typeof globalThis !== "undefined") globalThis.World = World;