from __future__ import annotations import itertools from dataclasses import dataclass _id_counter = itertools.count(1) def generate_entity_id(prefix: str = "entity") -> str: return f"{prefix}-{next(_id_counter)}" @dataclass class EntityPosition: """x/y/z are continuous (not tile-locked); z stays layer-like (whole numbers by convention). Which tile a continuous position falls in is always floor(x), floor(y) - see Map.get_tile. """ map_id: str x: float y: float z: float class Entity: """Base primitive for all non-tile things in the world.""" def __init__( self, entity_id: str | None = None, name: str = "", def_id: str | None = None, position: EntityPosition | None = None, ): self.entity_id = entity_id or generate_entity_id() self.name = name self.def_id = def_id self.position = position self.inventory = None # Inventory | None — assignable to any Entity def update(self, dt: float) -> None: pass