novi trgovc
This commit is contained in:
@@ -202,11 +202,14 @@ class SaveSystem {
|
||||
this.scene.statsSystem.thirst = saveData.stats.thirst;
|
||||
}
|
||||
|
||||
// 3. Load NPCs
|
||||
// 3. Load NPCs
|
||||
// Pobriši trenutne
|
||||
this.scene.npcs.forEach(npc => npc.destroy());
|
||||
this.scene.npcs = [];
|
||||
|
||||
let hasMerchant = false;
|
||||
|
||||
// Ustvari shranjene
|
||||
if (saveData.npcs) {
|
||||
saveData.npcs.forEach(npcData => {
|
||||
@@ -219,9 +222,23 @@ class SaveSystem {
|
||||
npcData.type
|
||||
);
|
||||
this.scene.npcs.push(npc);
|
||||
if (npcData.type === 'merchant') hasMerchant = true;
|
||||
});
|
||||
}
|
||||
|
||||
// Force Spawn Merchant if missing
|
||||
if (!hasMerchant) {
|
||||
// Spawn near current player position so user can find him
|
||||
const px = saveData.player ? saveData.player.x : 50;
|
||||
const py = saveData.player ? saveData.player.y : 50;
|
||||
const mX = Math.max(0, Math.min(99, Math.floor(px) + 3));
|
||||
const mY = Math.max(0, Math.min(99, Math.floor(py) + 3));
|
||||
|
||||
const merchant = new NPC(this.scene, mX, mY, this.scene.terrainOffsetX, this.scene.terrainOffsetY, 'merchant');
|
||||
this.scene.npcs.push(merchant);
|
||||
console.log("🏪 FORCE SPAWNED MERCHANT at", mX, mY);
|
||||
}
|
||||
|
||||
// 4. Camera
|
||||
if (saveData.camera) {
|
||||
this.scene.cameras.main.setZoom(saveData.camera.zoom);
|
||||
|
||||
Reference in New Issue
Block a user