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

Fix AddComponent in C[Entity]EquippedEntity Classes #73

Open
allsey87 opened this issue May 1, 2018 · 0 comments
Open

Fix AddComponent in C[Entity]EquippedEntity Classes #73

allsey87 opened this issue May 1, 2018 · 0 comments

Comments

@allsey87
Copy link
Collaborator

allsey87 commented May 1, 2018

During checking my code, I noticed that the constructor initialisation path for many of the CEntityEquippedEntity entities is somewhat broken. The method AddComponent will add components to the composable entity correctly, however, the update components specialisation in the class (which uses an anchor and an offset often defined in a struct inside the class) would have no effect on these components. To this end, I propose applying the following pattern to the affected classes:

class CEntityEquippedEntity {
public:
   virtual void Init(TConfigurationNode& t_tree) {
      /* initialization code to init the entity, find its anchor, offset etc */
      AddComponent(pc_entity, s_anchor, c_offset);
   }

   /* new public version of AddComponent */
   (virtual) void AddComponent(CEntity* pc_entity, SAnchor& s_anchor,  CVector3& c_offset) {
      m_vecInstances.push_back(new SInstance(*pc_entity, s_anchor, c_offset));
      AddComponent(pc_entity);
   }

private:
   /* override the inherited AddComponent and make it private so only we
      can call this function (I think this should work) */
   virtual void AddComponent(CEntity* pc_entity) {
      CComposableEntity::AddComponent(pc_entity);
   }

};

I would say that this issue isn't urgent, but I think it should be fixed at some point in the future.

@allsey87 allsey87 changed the title Todo: Fix AddComponent in C[Entity]EquippedEntity Classes Fix AddComponent in C[Entity]EquippedEntity Classes May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant