@@ -18,6 +18,8 @@ public sealed partial class SalvageSystem
|
|||||||
|
|
||||||
private EntityQuery<SalvageMobRestrictionsComponent> _salvMobQuery;
|
private EntityQuery<SalvageMobRestrictionsComponent> _salvMobQuery;
|
||||||
|
|
||||||
|
private List<(Entity<TransformComponent> Entity, EntityUid MapUid)> _detachEnts = new();
|
||||||
|
|
||||||
private void InitializeMagnet()
|
private void InitializeMagnet()
|
||||||
{
|
{
|
||||||
_salvMobQuery = GetEntityQuery<SalvageMobRestrictionsComponent>();
|
_salvMobQuery = GetEntityQuery<SalvageMobRestrictionsComponent>();
|
||||||
@@ -134,13 +136,16 @@ public sealed partial class SalvageSystem
|
|||||||
|
|
||||||
// Uhh yeah don't delete mobs or whatever
|
// Uhh yeah don't delete mobs or whatever
|
||||||
var mobQuery = AllEntityQuery<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
|
var mobQuery = AllEntityQuery<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
|
||||||
|
_detachEnts.Clear();
|
||||||
|
|
||||||
while (mobQuery.MoveNext(out var mobUid, out _, out _, out var xform))
|
while (mobQuery.MoveNext(out var mobUid, out _, out _, out var xform))
|
||||||
{
|
{
|
||||||
if (xform.GridUid == null || !data.Comp.ActiveEntities.Contains(xform.GridUid.Value) || xform.MapUid == null)
|
if (xform.GridUid == null || !data.Comp.ActiveEntities.Contains(xform.GridUid.Value) || xform.MapUid == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_transform.SetParent(mobUid, xform.MapUid.Value);
|
// Can't parent directly to map as it runs grid traversal.
|
||||||
|
_detachEnts.Add(((mobUid, xform), xform.MapUid.Value));
|
||||||
|
_transform.DetachParentToNull(mobUid, xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go and cleanup the active ents.
|
// Go and cleanup the active ents.
|
||||||
@@ -149,6 +154,11 @@ public sealed partial class SalvageSystem
|
|||||||
Del(ent);
|
Del(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var entity in _detachEnts)
|
||||||
|
{
|
||||||
|
_transform.SetParent(entity.Entity.Owner, entity.Entity.Comp, entity.MapUid);
|
||||||
|
}
|
||||||
|
|
||||||
data.Comp.ActiveEntities = null;
|
data.Comp.ActiveEntities = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user