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

Use composition instead of inheritance in ship-state #1239

Open
amir-arad opened this issue Oct 26, 2022 · 0 comments
Open

Use composition instead of inheritance in ship-state #1239

amir-arad opened this issue Oct 26, 2022 · 0 comments

Comments

@amir-arad
Copy link
Member

class ShipState inherits Spaceship and this causes some problems with the overlapping fields.
Adding a @tweakable annotation to this fields will result in an override in the tweak panel, and only the spaceObject state will become tweakable.
This also causes mistakes as to where is the correct place to keep the source of truth (it should always be the space state).
For example targetId in the space manager is degenerated, and the meaningful state is only in the ShipState object.

I suggest that the space object become a property of the ship state. and not a parent.
It should be a separate instance, a clone of the space object, that is updated every game loop. if it is replaces instead of updated, it might cause some UI to stop reacting to changes. check with the pilot widget to assert correct behavior.
I suggest trying the .assign() method to update the state.

@amir-arad amir-arad changed the title use somposition instead of inheritence in ship-state use Composition instead of inheritance in ship-state Oct 26, 2022
@amir-arad amir-arad changed the title use Composition instead of inheritance in ship-state Use composition instead of inheritance in ship-state Oct 26, 2022
@amir-arad amir-arad added good first issue Good for newcomers and removed good first issue Good for newcomers labels Oct 26, 2022
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