UseInHandEvent cleanup (#35231)
This commit is contained in:
@@ -12,6 +12,7 @@ public sealed class SpawnTableOnUseSystem : EntitySystem
|
||||
[Dependency] private readonly EntityTableSystem _entityTable = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -25,17 +26,21 @@ public sealed class SpawnTableOnUseSystem : EntitySystem
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
var coords = Transform(ent).Coordinates;
|
||||
var spawns = _entityTable.GetSpawns(ent.Comp.Table);
|
||||
|
||||
// Don't delete the entity in the event bus, so we queue it for deletion.
|
||||
// We need the free hand for the new item, so we send it to nullspace.
|
||||
_transform.DetachEntity(ent, Transform(ent));
|
||||
QueueDel(ent);
|
||||
|
||||
foreach (var id in spawns)
|
||||
{
|
||||
var spawned = Spawn(id, coords);
|
||||
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User):user} used {ToPrettyString(ent):spawner} which spawned {ToPrettyString(spawned)}");
|
||||
_hands.TryPickupAnyHand(args.User, spawned);
|
||||
_hands.PickupOrDrop(args.User, spawned);
|
||||
}
|
||||
|
||||
Del(ent);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user