✨ implement unified tile system (Issue #14)
- Tree seedlings: plant tree_seed on grass via farming tool; two-stage growth (sprout → sapling → young tree, ~1 min/stage); matures into a harvestable FOREST resource tile - Tile recovery: Nisse chops start a 5-min DARK_GRASS→GRASS timer; terrain canvas updated live via WorldSystem.refreshTerrainTile() - New TreeSeedlingSystem manages sprites, growth ticking, maturation - BootScene generates seedling_0/1/2 textures procedurally - FarmingSystem adds tree_seed to tool cycle (F key) - Stockpile panel shows tree_seed (default: 5); panel height adjusted - StateManager v5: treeSeedlings + tileRecovery in WorldState - WorldSystem uses CanvasTexture for live single-pixel updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
src/types.ts
28
src/types.ts
@@ -20,7 +20,10 @@ export const IMPASSABLE = new Set<number>([
|
||||
TileType.WALL,
|
||||
])
|
||||
|
||||
export type ItemId = 'wood' | 'stone' | 'wheat_seed' | 'carrot_seed' | 'wheat' | 'carrot'
|
||||
/** Tiles on which tree seedlings may be planted. */
|
||||
export const PLANTABLE_TILES = new Set<TileType>([TileType.GRASS, TileType.DARK_GRASS])
|
||||
|
||||
export type ItemId = 'wood' | 'stone' | 'wheat_seed' | 'carrot_seed' | 'wheat' | 'carrot' | 'tree_seed'
|
||||
|
||||
export type BuildingType = 'floor' | 'wall' | 'chest' | 'bed' | 'stockpile_zone'
|
||||
|
||||
@@ -90,6 +93,18 @@ export interface PlayerState {
|
||||
inventory: Partial<Record<ItemId, number>>
|
||||
}
|
||||
|
||||
export interface TreeSeedlingState {
|
||||
id: string
|
||||
tileX: number
|
||||
tileY: number
|
||||
/** Growth stage: 0 = sprout, 1 = sapling, 2 = mature (converts to resource). */
|
||||
stage: number
|
||||
/** Time remaining until next stage advance, in milliseconds. */
|
||||
stageTimerMs: number
|
||||
/** The tile type that was under the seedling when planted (GRASS or DARK_GRASS). */
|
||||
underlyingTile: TileType
|
||||
}
|
||||
|
||||
export interface WorldState {
|
||||
seed: number
|
||||
tiles: number[]
|
||||
@@ -98,6 +113,13 @@ export interface WorldState {
|
||||
crops: Record<string, CropState>
|
||||
villagers: Record<string, VillagerState>
|
||||
stockpile: Partial<Record<ItemId, number>>
|
||||
/** Planted tree seedlings, keyed by ID. */
|
||||
treeSeedlings: Record<string, TreeSeedlingState>
|
||||
/**
|
||||
* Recovery timers for DARK_GRASS tiles, keyed by "tileX,tileY".
|
||||
* Value is remaining milliseconds until the tile reverts to GRASS.
|
||||
*/
|
||||
tileRecovery: Record<string, number>
|
||||
}
|
||||
|
||||
export interface GameStateData {
|
||||
@@ -123,3 +145,7 @@ export type GameAction =
|
||||
| { type: 'VILLAGER_HARVEST_CROP'; villagerId: string; cropId: string }
|
||||
| { type: 'VILLAGER_DEPOSIT'; villagerId: string }
|
||||
| { type: 'UPDATE_PRIORITIES'; villagerId: string; priorities: JobPriorities }
|
||||
| { type: 'PLANT_TREE_SEED'; seedling: TreeSeedlingState }
|
||||
| { type: 'REMOVE_TREE_SEEDLING'; seedlingId: string }
|
||||
| { type: 'SPAWN_RESOURCE'; resource: ResourceNodeState }
|
||||
| { type: 'TILE_RECOVERY_START'; tileX: number; tileY: number }
|
||||
|
||||
Reference in New Issue
Block a user