Skip to content

ECS idiomatic way of compontents interaction #8141

Answered by nicopap
jacek-kurlit asked this question in Q&A
Discussion options

You must be logged in to vote

A few things. I think you are overthinking this, I think you wrote pretty fluent bevy ECS-style code!

There is a few recommendations:

  • Why store a Transform in the Tank component? The single responsibility principle would require to read & write from the Transform component rather than copy it in Tank. In any case, whenever you need the Transform of a tank in a system, you can always query it. And you can always pass it as argument to a method of Tank if needed.
  • Why not write a system dedicated to moving tanks? handle_player_input can only handle... player input! Maybe abstract the "intent" into its own component and work on that when moving the tank. For example:
fn update_player_intent(

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@jacek-kurlit
Comment options

Comment options

You must be logged in to vote
3 replies
@jacek-kurlit
Comment options

@nicopap
Comment options

nicopap Mar 21, 2023
Collaborator

@jacek-kurlit
Comment options

Answer selected by jacek-kurlit
Comment options

You must be logged in to vote
1 reply
@jacek-kurlit
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants