Skip to content

feat: damage multiBlock Structures#231

Open
ahv15 wants to merge 5 commits into
Terasology:developfrom
ahv15:multiblock-system
Open

feat: damage multiBlock Structures#231
ahv15 wants to merge 5 commits into
Terasology:developfrom
ahv15:multiblock-system

Conversation

@ahv15

@ahv15 ahv15 commented Aug 3, 2021

Copy link
Copy Markdown
Member

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

@ahv15 ahv15 requested review from jdrueckert and skaldarnar August 3, 2021 09:50

@skaldarnar skaldarnar left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

3 participants