Skip to content
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

Add AfterSaveEvent #5414

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Robust.Server/GameObjects/EntitySystems/MapLoaderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,9 @@ public MappingDataNode GetSaveData(EntityUid uid)
_logLoader.Debug($"Wrote entity section for {entities.Count} entities in {_stopwatch.Elapsed}");
_context.Clear();

var ve = new AfterSaveEvent(uid, Transform(uid).MapUid);
RaiseLocalEvent(ve);

return data;
}

Expand Down
24 changes: 23 additions & 1 deletion Robust.Shared/Map/Events/MapSerializationEvents.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Robust.Shared.GameObjects;

namespace Robust.Shared.Map.Events;
Expand Down Expand Up @@ -49,3 +49,25 @@ public BeforeSaveEvent(EntityUid entity, EntityUid? map)
Map = map;
}
}

/// <summary>
/// This event is broadcast just after the map loader reads the entity section.
/// </summary>
public sealed class AfterSaveEvent
{
/// <summary>
/// The entity that was saved. usually a map or grid.
/// </summary>
public EntityUid Entity;

/// <summary>
/// The map that the <see cref="Entity"/> is on.
/// </summary>
public EntityUid? Map;

public AfterSaveEvent(EntityUid entity, EntityUid? map)
{
Entity = entity;
Map = map;
}
}
Loading