Actor reflection and spawning by name #45

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:16:02 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

The editor and files create actors, parts and behaviors by name.

Decided

  • PRIMAL_ACTOR()/PRIMAL_PART()/PRIMAL_BEHAVIOR(); their PRIMAL_GENERATED_BODY() goes first in the class (it ends with private:) and writes is_a()/class_name().
  • A class the generator can't see (a template, a local class) says PRIMAL_ACTOR_CLASS(Self, Base) and isn't registered.
  • spawn_by_name(), add_part_by_type(), add_behavior_by_type(); ActorRef/PartRef fields stored as entities.

Read first

Steps

  • 1. Extend the generator and its golden tests.
  • 2. Write by-name spawning with tests from a test game library.

Done when

  • Tests pass on both OSes; 0 warnings; tidy 0.

Claude can help with

  • Generator changes and golden files.

Learn

  • Why the generated body has to come first.
## Why The editor and files create actors, parts and behaviors by name. ## Decided - `PRIMAL_ACTOR()`/`PRIMAL_PART()`/`PRIMAL_BEHAVIOR()`; their `PRIMAL_GENERATED_BODY()` goes first in the class (it ends with `private:`) and writes `is_a()`/`class_name()`. - A class the generator can't see (a template, a local class) says `PRIMAL_ACTOR_CLASS(Self, Base)` and isn't registered. - `spawn_by_name()`, `add_part_by_type()`, `add_behavior_by_type()`; `ActorRef`/`PartRef` fields stored as entities. ## Read first - [Actors](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Actors), section 20. ## Steps - [ ] 1. Extend the generator and its golden tests. - [ ] 2. Write by-name spawning with tests from a test game library. ## Done when - [ ] Tests pass on both OSes; 0 warnings; tidy 0. ## Claude can help with - Generator changes and golden files. ## Learn - Why the generated body has to come first.
Sign in to join this conversation.
No assignees
No project
Blocks
#46 Outliner, details, gizmos, undo and redo
UnflavoredMeson/Primal_Plus_Plus
#56 Loading the game library in the editor
UnflavoredMeson/Primal_Plus_Plus
Depends on
#43 Actor runtime: actors, parts, behaviors
UnflavoredMeson/Primal_Plus_Plus
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#45
No description provided.