viktor-ferenczi / multigrid-projector

Multigrid Projector plugin for the Space Engineers game.
MIT License
24 stars 6 forks source link

Toolbar slot fix #71

Closed viktor-ferenczi closed 5 months ago

viktor-ferenczi commented 6 months ago

Problem

Multi-grid blueprints saved from vanilla SE have any toolbar slots with a block from another subgrid broken due to inconsistent EntityId mapping, unless the MGP plugin is used while producing the blueprint. In that case the EntityId values are correct.

On welding the same terminal block (with slots or the ones associated to slots) the second time from the same projection a new EntityId is assigned if the previous one still exists in the world. The workaround is to power-cycle the projector between welding attempts, but it still breaks in cases where there are already built blocks to be consistent with. This affects mostly missiles built from the repair projection of the whole ship, but can hit any player if welding is interrupted and had to be restarted for some blocks.

Solution

On loading the blueprint find all toolbar slots with assigned blocks and store those associations based on their subgrid index and block location. Build the mapping from the block to the toolbar slot.

After building a terminal block from projection find all terminal blocks (maybe including itself) which has the newly built block in a toolbar slot and fix those slots. Also fix the slots of any blocks with a toolbar right after building them.

Introduce a "Fix toolbars" button on the projector's terminal, so the toolbars can be fixed without having to rebuild the affected blocks.

viktor-ferenczi commented 5 months ago

The solution has been merged into the 0.7.0 release branch, so closing this PR in favor of that.