Entity labels — multi-tag string set for collision and trigger grouping #296

Closed
opened 2026-03-15 00:30:13 +00:00 by john · 1 comment
Owner

Summary

Add a set of string labels to entities for collision grouping, behavior trigger targeting, and general-purpose tagging.

Proposed API

entity.labels                    # frozenset of strings (read-only view)
entity.add_label("solid")
entity.remove_label("solid")
entity.has_label("solid")        # bool

# Bulk set
entity.labels = {"solid", "npc", "enemy"}

# Constructor support
e = mcrfpy.Entity(grid_pos=(5,5), texture=tex, labels={"solid", "npc"})

C++ backing

// UIEntity.h
std::unordered_set<std::string> labels;

Usage contexts

  • Pathfinding collision: "treat entities with label X as impassable" (see pathfinding collision issue)
  • Behavior triggers: "call step() when entity with label Y enters FOV" (see trigger system issue)
  • Game logic: general-purpose tagging, replaces ad-hoc name matching

Example

class Guard(mcrfpy.Entity):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.labels = {"solid", "npc", "enemy"}
        self.target_label = "player"  # trigger: watch for "player"-labeled entities

player = mcrfpy.Entity(grid_pos=(5,5), texture=tex)
player.labels = {"solid", "player"}

Files likely affected

  • src/UIEntity.h/cpp — add labels member, Python property/methods
  • src/UIEntityPyMethods.h — add add_label, remove_label, has_label methods
## Summary Add a set of string labels to entities for collision grouping, behavior trigger targeting, and general-purpose tagging. ## Proposed API ```python entity.labels # frozenset of strings (read-only view) entity.add_label("solid") entity.remove_label("solid") entity.has_label("solid") # bool # Bulk set entity.labels = {"solid", "npc", "enemy"} # Constructor support e = mcrfpy.Entity(grid_pos=(5,5), texture=tex, labels={"solid", "npc"}) ``` ## C++ backing ```cpp // UIEntity.h std::unordered_set<std::string> labels; ``` ## Usage contexts - **Pathfinding collision**: "treat entities with label X as impassable" (see pathfinding collision issue) - **Behavior triggers**: "call step() when entity with label Y enters FOV" (see trigger system issue) - **Game logic**: general-purpose tagging, replaces ad-hoc name matching ## Example ```python class Guard(mcrfpy.Entity): def __init__(self, **kwargs): super().__init__(**kwargs) self.labels = {"solid", "npc", "enemy"} self.target_label = "player" # trigger: watch for "player"-labeled entities player = mcrfpy.Entity(grid_pos=(5,5), texture=tex) player.labels = {"solid", "player"} ``` ## Files likely affected - `src/UIEntity.h/cpp` — add `labels` member, Python property/methods - `src/UIEntityPyMethods.h` — add `add_label`, `remove_label`, `has_label` methods
Author
Owner

Roadmap context

Part of the Grid & Entity Overhaul Roadmap (docs/GRID_ENTITY_OVERHAUL_ROADMAP.md), Phase 2 (Entity Data Model Extensions).

Labels are used by two later features:

  • #302 Pathfinding collision: collide="solid" treats entities with that label as impassable
  • #301 grid.step() TARGET triggers: entity.target_label = "player" fires step() when a "player"-labeled entity enters FOV
## Roadmap context Part of the Grid & Entity Overhaul Roadmap (`docs/GRID_ENTITY_OVERHAUL_ROADMAP.md`), **Phase 2** (Entity Data Model Extensions). Labels are used by two later features: - #302 Pathfinding collision: `collide="solid"` treats entities with that label as impassable - #301 grid.step() TARGET triggers: `entity.target_label = "player"` fires `step()` when a "player"-labeled entity enters FOV
john closed this issue 2026-03-16 11:21:02 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
john/McRogueFace#296
No description provided.