Skip to content

[P3] Worker overlay sprites keyed by worker name — rendering collides at 11+ workers #312

Description

@itsmiso-ai

Problem: render_worker_overlay() keys its per-worker rendering state by worker name (worker_overlay_nodes, _overlay_sprite_cache_frame, _overlay_sprite_cache_carrying), but worker names are not unique at the population cap. recruit_worker() cycles names with current % Constants.WORKER_NAMES.size(), and the pool has exactly 10 entries — so the 11th worker (cap 12, reachable with 5 huts) duplicates "Jun", the 12th duplicates "Mara", etc. When two workers share a name they also share a single TextureRect: the second worker overwrites the sprite's position/frame, so both workers render at one location and animation frames are wrong. #242/#247 addressed duplicate names only up to 10 workers ("prevent name collisions when recruiting multiple workers") and test_recruit_unique_names only exercises 4 recruits, so the residual collision at 11+ is untested and unfixed.

Evidence:

  • scripts/main.gd render_worker_overlay()worker_overlay_nodes.has(name) returns the existing node for a duplicate name; _overlay_sprite_cache_frame[name] / _overlay_sprite_cache_carrying[name] gate texture assignment per name
  • scripts/colony_sim.gd recruit_worker()var next_index: int = current % Constants.WORKER_NAMES.size() (cycles; 11th recruit gets index 0)
  • scripts/constants.gd:5 — WORKER_NAMES has 10 entries; WORKER_CAP_BONUSES = {"hut": 2} + BASE_WORKER_CAP = 2 -> cap 12 with 5 huts
  • tests/test_recruit_worker.gd test_recruit_unique_names — asserts uniqueness only for range(4) recruits (cap 4)
  • Commit 9b6553b (Expand WORKER_NAMES pool and add badge colors for all workers #242) — pool expansion to 10 was the intended fix for Expand WORKER_NAMES or add unique name generation #227; it does not cover the 11th+ worker

Acceptance:

  • Overlay rendering is keyed by a stable per-worker identity (e.g., array index or a unique worker id), not name
  • A sim/UI test with 12 workers (5 huts) shows every worker rendering at its own position with its own animation frame, including two workers named the same

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions