Skip to content

Register component clone and copy into type registry#309

Merged
waynemwashuma merged 2 commits into
wimaengine:devfrom
waynemwashuma:register-clone-and-copy
Mar 29, 2026
Merged

Register component clone and copy into type registry#309
waynemwashuma merged 2 commits into
wimaengine:devfrom
waynemwashuma:register-clone-and-copy

Conversation

@waynemwashuma
Copy link
Copy Markdown
Collaborator

@waynemwashuma waynemwashuma commented Mar 29, 2026

Objective

Integrate copy / clone semantics into the type registry system.

  • Registers duplication methods for all ECS components in their respective modules
  • Enables reflection-based systems to invoke component-specific duplication logic
  • This is building upon Add Typeinfo method registration #307

Solution

Although copy / clone methods were introduced on components, they were not discoverable through the type registry. This adds a way to use the type registry to clone/copy components in reflection based systems without needing to know the underlying type.

Changes made

Added method registrations for  ``copy and clone across all registered component types.

Why this approach

  • Enables generic systems to invoke copy/clone without hardcoding types
  • Aligns duplication with existing metadata-driven workflows

Showcase

Before

// Registry cannot perform cloning generically

const info = registry.get(Position2D)

// No way to invoke type-specific copy logic
// Requires manual handling per type

After

const info = registry.get(Position2D)

// Invoke registered method (pseudo-API)
const copy = info.call('copy', source)

Migration guide

No migration required.

Checklist

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@waynemwashuma waynemwashuma self-assigned this Mar 29, 2026
@waynemwashuma waynemwashuma added the type:enhancement New feature or request label Mar 29, 2026
@github-actions github-actions Bot added mod:render mod:window mod:physics mod:transform mod:movable mod:audio mod:tween This PR/issue affects the `tween` package mod:hierarchy mod:color This affects the color package mod:animation This PR/issue affects the animation system mod:time This PR/issue affect the time package mod:geometry This PR/issue affects geometry package mod:scene This affects the scene package mod:type mod:emitter This PR/issue affects emitter package labels Mar 29, 2026
@waynemwashuma waynemwashuma changed the title Register clone and copy into type registry Register component clone and copy into type registry Mar 29, 2026
@waynemwashuma waynemwashuma force-pushed the register-clone-and-copy branch from 614d7dc to b199eec Compare March 29, 2026 11:26
@github-actions github-actions Bot removed mod:scene This affects the scene package mod:type mod:emitter This PR/issue affects emitter package labels Mar 29, 2026
@waynemwashuma waynemwashuma merged commit 1dad857 into wimaengine:dev Mar 29, 2026
7 checks passed
@waynemwashuma waynemwashuma deleted the register-clone-and-copy branch March 29, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:animation This PR/issue affects the animation system mod:audio mod:color This affects the color package mod:geometry This PR/issue affects geometry package mod:hierarchy mod:movable mod:physics mod:render mod:time This PR/issue affect the time package mod:transform mod:tween This PR/issue affects the `tween` package mod:window type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant