-
Notifications
You must be signed in to change notification settings - Fork 436
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
Refactor map loading & saving #5572
base: master
Are you sure you want to change the base?
Conversation
shell yeah |
Also better handling for saving multiple entities individually
… into map-load-refactor
… into fix-component-composition
Avoid unnecessary component deserialization
… into map-load-refactor
… into map-load-refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never got around to reading entitydeserializer but I was sick when reviewing this.
{ | ||
public int Uid { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VV probably?
// Note that this does not actually map-initialize the gird entity, even if the map its being spawn on has already been initialized. | ||
// I don't know whether that is intentional or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Note that this does not actually map-initialize the gird entity, even if the map its being spawn on has already been initialized. | |
// I don't know whether that is intentional or not. | |
// Note that this does not actually map-initialize the grid entity, even if the map its being spawn on has already been initialized. | |
// I don't know whether that is intentional or not. |
Do not remember it's been spaghet since the IMapLoader days.
This PR reworks and tries to generalize entity serialization (i.e., map saving & loading). IMO the main shortcomings of the current system are that only files containing either a single root map or grid are properly supported and that there is no real support for null-space entities. We also need better multi-map support for full game saves. The current setup is also prone to introducing bugs due to the lack of distinction between whether a file is a "grid" or "map". This can lead people accidentally saving/loading maps as grids and vice versa, which has caused game breaking bugs that can remain undetected until a problematic file is loaded improperly.
This is a revival of a 1+ year old draft, and has had quite a few conflicts. I've tried to clean up any issues but I also wouldn't be too surprised if I missed something or accidentally reverted some serialization changes/bugfixes.
Requires space-wizards/space-station-14#34020 .
Overview of changes:
MapLoaderSystem
and associated classes & structs have been moved to shared to support single player games and serialization of client-side entities.EntitySerializer
andEntityDeserializer
classes.DataNode
MapLoadOptions
class has been replaced withMapLoadOptions
,SerializationOptions
, andDeserializationOptions
structsTryLoad()
andSave()
methods have been replaced with grid, map, generic entity variants. I.e,TrySaveGrid
,TrySaveMap
,TrySaveEntity
, andTrySaveGeneric()
.SwapRootNode()
.MapSerializationContext
.File format changes
Serialization auto-inclusion
Currently if an entity gets serialized, but has some component that references an EntityUid that is not being serialized, it will log an error and might lead to broken saves. The new default behaviour is that if the referenced entity is a non-map null-space entity, it will automatically include that entity in the save, otherwise it still logs an error.
This is intended to make it easier when saving a map/grid with entities that depends on null-space entities. The actual behaviour can be configured to also auto-include any referenced entity. So for example, saving a map that references a station or rule, which in turn references another map, would result in the file containing both maps.
Other Changes
when warnings are logged.
IServerEntityManagerInternal
has been removed. AFAICT it was just being used by entity serialization, and was internal anyways.MapChangedEvent
has been marked as obsolete, and should be replaced withMapCreatedEvent
and `MapRemovedEvent.ITileDefinitionManager.AssignAlias
and general tile alias functionality has been removed.TileAliasPrototype
still exist, but is only used during entity deserialization. This and related serialization changes fixes Tile Migration is not working #5565IEntitySystemManager
now exposes the systemIDependencyCollection
, mainly so that you can useInjectDependencies()
, which is used by the new serializer classes to resolve system dependencies.BeforeSaveEvent
has been replaced withBeforeSerializationEvent
, and there is a newAfterSerializationEvent
.