Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component module refactor #34

Closed
5 tasks done
brenocq opened this issue Aug 13, 2022 · 0 comments
Closed
5 tasks done

Component module refactor #34

brenocq opened this issue Aug 13, 2022 · 0 comments
Labels
component Component Module

Comments

@brenocq
Copy link
Owner

brenocq commented Aug 13, 2022

Some changes to make the component module easier to use:

  • Instead of returning EntityId, should return Entity.
  • Implicit conversion Entity <-> EntityId
  • Name component set()
  • Mesh component set()
  • Material component set()

Expected usage:

namespace rsc = atta::resource;
namespace cmp = atta::component;

// Create material resource
rsc::Material::CreateInfo info = {.color = {1,0,0}};
rsc::Material* rmat = rsc::create<rsc::Material>("CubeMaterial", info);

// Create cube
cmp::Entity cube = cmp::createEntity();
cube.add<cmp::Name>()->set("Cube");
cube.add<cmp::Mesh>()->set("meshes/cube.obj");
cube.add<cmp::Transform>();
cube.add<cmp::Material>()->set(rmat);

// Create cube2 by copying
cmp::Entity cube2 = cmp::copyEntity(cube);
cube2.get<cmp::Transform>()->position = {1,0,0};
cube2.get<cmp::Material>()->getResource()->color = {0,1,0};

// Delete cube
cmp::deleteEntity(cube);
@brenocq brenocq moved this from Todo to Done in Atta Aug 13, 2022
@brenocq brenocq closed this as completed Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component Component Module
Projects
Status: Done
Development

No branches or pull requests

1 participant