-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
feat: PositionComponent now has a built-in Decorator #1846
Conversation
Hmm, why have it set up as a linked list? Seems like quite a normal usecase that you'd want to remove, add or swap a decorator in the middle of the chain? Couldn't it just be a normal list, will it really be that much less performant? |
For the linked list it's pretty straightforward to define methods to add/remove/replace elements in the middle, if needed. So we're not sacrificing any functionality there. At the same time, the most common use-case is when there are no additional decorators, so the linked list with a single In addition, a linked list makes it much easier to call the decorators recursively (each decorator wraps the output of subsequent decorators). |
Makes sense, could these methods be added in this PR? Or should that be done separately? |
I'd prefer not to overburden the PR with functionality that is not needed for it. These methods can be added later as the need arises. |
Lgtm, but aren't there docs missing? |
True, i'll add some |
Description
This PR adds the
decorator
property toPositionComponent
, and makes decorators chain-able. That is, decorators function as linked lists, and a new decorator can be appended to the end of such list, and later removed.The
PositionComponent
starts with the default decorator: theTransform2DDecorator
, which encapsulates the functionality which previously resided within thePositionComponent.renderTree
. This allows to:.decorator.addLast()/.removeLast()
;Transform2DDecorator
with another one -- for example supporting skew, or isometric coordinates, or 3d rotations.HasDecorator
mixin can no longer be applied to aPositionComponent
because it already has the decorator "built in".The decorators
Shadow3DDecorator
andRotate3DDecorator
, when added to the PositionComponent, will now apply after the coordinate transform of thePositionComponent
, as desired. This means that, for example, the shadow's base and rotation pivot point can be specified using the local coordinates of the component.Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
main
.Related Issues
Closes #1829