# NPC Simulation Tier State Machine — D-026 # bevy_ecs dynamic component add/remove makes tier transitions seamless. # Scope tags keep NPCs in Active tier. vars: { color-bg: "#2a3040" color-stroke: "#333340" color-text: "#c8d0e0" color-accent: "#c8d8f0" color-dim: "#1a1e24" } ungenerated: Tier 4\nUngenerated { style.fill: ${color-dim} style.stroke: ${color-stroke} style.font-color: ${color-text} style.stroke-dash: 5 } state_saved: Tier 3\nState-Saved\n~1-2KB frozen struct { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } background: Tier 2\nBackground\n500-2,000 NPCs { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } active: Tier 1\nActive\n30-80 NPCs · full sim { style.fill: ${color-bg} style.stroke: ${color-accent} style.font-color: ${color-text} style.bold: true } scope_tags: Scope Tags (prevent eviction) { shape: package style.fill: ${color-dim} style.stroke: ${color-accent} style.font-color: ${color-text} neighborhood: neighborhood { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } active_quest: active-quest { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } colleague: colleague { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } known_contact: known-contact { style.fill: ${color-bg} style.stroke: ${color-stroke} style.font-color: ${color-text} } } lru: LRU Priority Queue\n(interaction-timestamp) { shape: diamond style.fill: ${color-bg} style.stroke: ${color-accent} style.font-color: ${color-text} } ungenerated -> state_saved: "player approach\n(generated ahead)" { style.stroke: ${color-stroke} } state_saved -> background: "player return\n(~2-5ms reactivation)" { style.stroke: ${color-stroke} } background -> state_saved: "LRU eviction" { style.stroke: ${color-stroke} style.stroke-dash: 4 } background -> active: "player proximity\nor scope tag match" { style.stroke: ${color-accent} } active -> background: "LRU eviction\n(no scope tag)" { style.stroke: ${color-stroke} style.stroke-dash: 4 } scope_tags -> active: "prevents eviction" { style.stroke: ${color-accent} style.stroke-dash: 4 } lru -> active: "manages" { style.stroke: ${color-accent} } lru -> background: "manages" { style.stroke: ${color-stroke} }