Skip to content

Keep mod storage saved in prefabs when MES adds its own - #469

Open
Blaylock1988 wants to merge 1 commit into
MeridiusIX:masterfrom
GV-Server-Mods:fix/mod-storage-existing-component
Open

Blaylock1988 wants to merge 1 commit into
MeridiusIX:masterfrom
GV-Server-Mods:fix/mod-storage-existing-component

Conversation

@Blaylock1988

Copy link
Copy Markdown
Contributor

Problem

When MES adds its own storage to a prefab grid or block (NpcData, NPC thruster and gyro settings, container types), it looks for an existing component with TypeId MyModStorageComponentBase. Once storage has been through a save and load, the game saves it as MyModStorageComponent, which is how it appears in a prefab made from a loaded grid. MES misses it and adds a second component. On spawn the second one replaces the first, so the prefab's other mod storage on that grid or block is lost.

foreach (var component in entity.ComponentContainer.Components) {
if (component.TypeId != "MyModStorageComponentBase") {
continue;
}

Change

ApplyCustomBlockStorage and ApplyCustomEntityStorage also accept MyModStorageComponent. As we discussed, GetContainerStorage stays as it is, and NpcData left in a prefab is not cleared.

Testing

Single player, together with #468. I added a key that MES registers but only reads on planets (MesTemporaryPlanetKey) to a rover prefab's grid storage. Rovers spawned before the change were saved without it; after the change they keep it, next to their NpcData.

This branch has not been deployed

No deployments
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.

1 participant