feat: damage multiBlock Structures#231
Open
ahv15 wants to merge 5 commits into
Open
Conversation
skaldarnar
requested changes
Aug 6, 2021
skaldarnar
left a comment
Contributor
There was a problem hiding this comment.
I'm surprised this is not a default feature of MultiBlocks 👀 What does MB do with attacks to a multi-block structure?
Comment on lines
+44
to
+48
| if (entity.hasComponent(MultiBlockMainComponent.class)) { | ||
| blocks = entity.getComponent(MultiBlockMainComponent.class).getMultiBlockMembers(); | ||
| } else if (entity.hasComponent(MultiBlockMemberComponent.class)) { | ||
| blocks = blockEntityRegistry.getBlockEntityAt(entity.getComponent(MultiBlockMemberComponent.class).getMainBlockLocation()).getComponent(MultiBlockMainComponent.class).getMultiBlockMembers(); | ||
| } |
Contributor
There was a problem hiding this comment.
I'd do this in two separate steps:
- find the main multi-block, if any
- derive the
blocksfrom that main block
To make the code easier to comprehend I'd additionally move this to a method which returns an Optional<Collection<Vector3i>> with the multi-block member positions, if any multi-block is hit.
As it does not make any difference for us whether we iterate over an empty collection (and thus don't damage any other blocks) or check if the collection is present we may even get rid of the optional here and just return a collection that may or may not contain any entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whenever a block in a multiBlock structure is damaged all the others blocks in the multiBlock structure are also damaged.