lundi 13 janvier 2020

What design pattern is good for applying attributes to a class that changes its behavior?

I am trying to find the best way to structure my project. What I would like to do is have a "Structure", which is made of multiple "part". These parts also will have separate attributes, for example it could be spinning, hovering, vibrating, jumping, shaking, growing, accelerating.

So for example, I might have a "structure" called human that is made of 6 "parts". I am going to set each part to one of the available options, so in this case, 2 parts are going to be arms, 2 parts are going to be legs, one part is a torso, and one part is a head. Now, I want to be able to apply the attribute spinning to one of the parts, the arm. So now I should have a human with a spinning arm.

Additionally, I would like other people to be able to create their own cusom attributes, structures, and parts.

I would like to get an idea on how I should structure my code, and apply an attribute to a part. Additionally, what design pattern would be good for this?

Aucun commentaire:

Enregistrer un commentaire