🐛 Fix resize, Nisse idle bug + rename Villager → Nisse #4
@@ -1,5 +1,6 @@
|
|||||||
import Phaser from 'phaser'
|
import Phaser from 'phaser'
|
||||||
import { TILE_SIZE, VILLAGER_SPEED, VILLAGER_SPAWN_INTERVAL, VILLAGER_WORK_TIMES, VILLAGER_NAMES } from '../config'
|
import { TILE_SIZE, VILLAGER_SPEED, VILLAGER_SPAWN_INTERVAL, VILLAGER_WORK_TIMES, VILLAGER_NAMES } from '../config'
|
||||||
|
import { TileType } from '../types'
|
||||||
import type { VillagerState, VillagerJob, JobType, AIState, ItemId } from '../types'
|
import type { VillagerState, VillagerJob, JobType, AIState, ItemId } from '../types'
|
||||||
import { stateManager } from '../StateManager'
|
import { stateManager } from '../StateManager'
|
||||||
import { findPath } from '../utils/pathfinding'
|
import { findPath } from '../utils/pathfinding'
|
||||||
@@ -200,13 +201,19 @@ export class VillagerSystem {
|
|||||||
const state = stateManager.getState()
|
const state = stateManager.getState()
|
||||||
|
|
||||||
if (job.type === 'chop') {
|
if (job.type === 'chop') {
|
||||||
if (state.world.resources[job.targetId]) {
|
const res = state.world.resources[job.targetId]
|
||||||
|
if (res) {
|
||||||
this.adapter.send({ type: 'VILLAGER_HARVEST_RESOURCE', villagerId: v.id, resourceId: job.targetId })
|
this.adapter.send({ type: 'VILLAGER_HARVEST_RESOURCE', villagerId: v.id, resourceId: job.targetId })
|
||||||
|
// Clear the FOREST tile so the area becomes passable for future pathfinding
|
||||||
|
this.adapter.send({ type: 'CHANGE_TILE', tileX: res.tileX, tileY: res.tileY, tile: TileType.DARK_GRASS })
|
||||||
this.resourceSystem.removeResource(job.targetId)
|
this.resourceSystem.removeResource(job.targetId)
|
||||||
}
|
}
|
||||||
} else if (job.type === 'mine') {
|
} else if (job.type === 'mine') {
|
||||||
if (state.world.resources[job.targetId]) {
|
const res = state.world.resources[job.targetId]
|
||||||
|
if (res) {
|
||||||
this.adapter.send({ type: 'VILLAGER_HARVEST_RESOURCE', villagerId: v.id, resourceId: job.targetId })
|
this.adapter.send({ type: 'VILLAGER_HARVEST_RESOURCE', villagerId: v.id, resourceId: job.targetId })
|
||||||
|
// Clear the ROCK tile so the area becomes passable for future pathfinding
|
||||||
|
this.adapter.send({ type: 'CHANGE_TILE', tileX: res.tileX, tileY: res.tileY, tile: TileType.GRASS })
|
||||||
this.resourceSystem.removeResource(job.targetId)
|
this.resourceSystem.removeResource(job.targetId)
|
||||||
}
|
}
|
||||||
} else if (job.type === 'farm') {
|
} else if (job.type === 'farm') {
|
||||||
|
|||||||
Reference in New Issue
Block a user