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

feat: damage multiBlock Structures #231

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ahv15
Copy link
Member

@ahv15 ahv15 commented Aug 3, 2021

Whenever a block in a multiBlock structure is damaged all the others blocks in the multiBlock structure are also damaged.

Copy link
Contributor

@skaldarnar skaldarnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do this in two separate steps:

  1. find the main multi-block, if any
  2. derive the blocks from 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.

@ahv15 ahv15 requested a review from skaldarnar August 7, 2021 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants