Add entity blocking and a wandering NPC

Occupied tiles now block movement through World::blocked, the one predicate
the sim and the pathfinder share. Entities carry an EntityKind so the sim
knows which ones to think for; Sim::think gives each NPC a random king move
one window in four. Intents execute in id order so contested tiles resolve
deterministically.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 10:51:44 +02:00
co-authored by Claude Opus 5
parent 1d14076468
commit 7ea351f8e5
4 changed files with 123 additions and 16 deletions
+12 -2
View File
@@ -1,15 +1,25 @@
/// Who decides an entity's actions. The sim only schedules intents for `Npc`s; a
/// `Player`'s intents come from outside (input) through `Sim::set_action`.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum EntityKind {
Player,
Npc,
}
pub struct Entity {
pub id: u32,
pub type_id: u16, // 0 = player
pub kind: EntityKind,
pub type_id: u16, // sprite index into the entity tileset
pub pos: (i16, i16),
pub hp: u16,
pub hp_max: u16,
}
impl Entity {
pub fn new(id: u32, type_id: u16, pos: (i16, i16), hp: u16) -> Self {
pub fn new(id: u32, kind: EntityKind, type_id: u16, pos: (i16, i16), hp: u16) -> Self {
Self {
id,
kind,
type_id,
pos,
hp,