A step onto an occupied tile is now an attack: the geometry rule is checked against terrain only and the target tile decides between move and bump. Entities carry an attack stat; at zero hp they are removed. The sim reports Attacked/Died through an event queue the game drains after every movement window — the seam for sound, log, camera effects and spawns. Click-to-move treats an occupied goal as a target but detours around entities in the way; the player's death ends the game. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
33 lines
797 B
Rust
Executable File
33 lines
797 B
Rust
Executable File
/// 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 kind: EntityKind,
|
|
pub type_id: u16, // sprite index into the entity tileset
|
|
pub pos: (i16, i16),
|
|
pub hp: u16,
|
|
pub hp_max: u16,
|
|
/// Damage dealt per bump.
|
|
pub attack: u16,
|
|
}
|
|
|
|
impl Entity {
|
|
pub fn new(id: u32, kind: EntityKind, type_id: u16, pos: (i16, i16), hp: u16, attack: u16) -> Self {
|
|
Self {
|
|
id,
|
|
kind,
|
|
type_id,
|
|
pos,
|
|
hp,
|
|
hp_max: hp,
|
|
attack,
|
|
}
|
|
}
|
|
}
|