sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
368 stars 54 forks source link

store and restore by cell component #99

Closed krojew closed 1 month ago

krojew commented 1 month ago

actor component version of https://github.com/sinbad/SPUD/pull/96 for improved versatility

sinbad commented 1 month ago

Thanks, will take a look! However if you want to include your own copyright at the top of the files, please also add the MIT license text so it's clear you're allowing the code to be included.

krojew commented 1 month ago

Sorry, that was autogenerated.

krojew commented 1 month ago

@sinbad anything else to change?

sinbad commented 1 month ago

Sorry, I don't code over the weekend, will look at it today.

sinbad commented 1 month ago

Thanks!

Deams51 commented 1 month ago

@krojew Would you be able to give details on how this component is supposed to be used? I'm not sure I've understood it properly.

I've run a quick test here by adding the comp to a spud actor, it does save/load with the world partition cell, but it also gets destroyed if a manual save is executed due to OnPreUnloadCell being called. I am also unsure how stable cell names are between builds, aren't cells regenerated on each cook thus potentially invalidating the cell name used by this component?

krojew commented 1 month ago

It should store the actor withing a cell, destroy it when the cell gets unloaded, and restore on cell loading. It shouldn't destroy anything on manual save - that's something I didn't notice. Can you make a fix for that?

I am also unsure how stable cell names are between builds, aren't cells regenerated on each cook thus potentially invalidating the cell name used by this component?

I think they should be stable. Do you have any more info on this?

Deams51 commented 1 month ago

Asked Epic, cell names are stable between cooks. They can however change in some cases such as changing the cell size, and probably other WP settings. So it shouldn't be an issue but should be expected if using this component. Maybe worth adding as a comment to the class.

Regarding the potential issue, it might just be due to a local setup. Could you share how an actor should be setup to use this component? Should it implement the ISpudObject interface? The SpudGuid? Any specific overrides?

krojew commented 1 month ago

The actor should be set up the same way as other runtime-spawned actors, so it needs the guid.

krojew commented 1 month ago

@Deams51 I might have a fix for the destruction on save tomorrow, but it's quite difficult to test, so no guarantees.