Even more engine changes

This commit is contained in:
ElectroJr
2024-12-24 21:00:53 +13:00
parent a8cc0397c2
commit b555a6049e
7 changed files with 26 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using System.Numerics;
using Content.Shared.Administration.Managers;
using Content.Shared.Database;
@@ -62,8 +63,14 @@ public sealed class FollowerSystem : EntitySystem
private void OnBeforeSave(BeforeSerializationEvent ev)
{
// Some followers will not be map savable. This ensures that maps don't get saved with empty/invalid
// followers, but just stopping any following on the map being saved.
// Some followers will not be map savable. This ensures that maps don't get saved with some entities that have
// empty/invalid followers, by just stopping any following happening on the map being saved.
// I hate this so much.
// TODO WeakEntityReference
// We need some way to store entity references in a way that doesn't imply that the entity still exists.
// Then we wouldn't have to deal with this shit.
var maps = ev.Entities.Select(x => Transform(x).MapUid).ToHashSet();
var query = AllEntityQuery<FollowerComponent, TransformComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var follower, out var xform, out var meta))
@@ -71,7 +78,7 @@ public sealed class FollowerSystem : EntitySystem
if (meta.EntityPrototype == null || meta.EntityPrototype.MapSavable)
continue;
if (xform.MapUid != ev.Map)
if (!maps.Contains(xform.MapUid))
continue;
StopFollowingEntity(uid, follower.Following);