/// </summary>
private void OnUseInHand(Entity<GasAnalyzerComponent> entity, ref UseInHandEvent args)
{
+ // Not checking for Handled because ActivatableUISystem already marks it as such.
+
if (!entity.Comp.Enabled)
- {
ActivateAnalyzer(entity, args.User);
- }
else
- {
DisableAnalyzer(entity, args.User);
- }
+
args.Handled = true;
}
using Content.Shared.Item;
using Content.Shared.Whitelist;
using Robust.Server.Audio;
-using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Prototypes;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly List<string> _possibleGiftsSafe = new();
private readonly List<string> _possibleGiftsUnsafe = new();
if (component.Wrapper is not null)
Spawn(component.Wrapper, coords);
- args.Handled = true;
_audio.PlayPvs(component.Sound, args.User);
- Del(uid);
+
+ // 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(uid, Transform(uid));
+ QueueDel(uid);
+
_hands.PickupOrDrop(args.User, handsEnt);
+ args.Handled = true;
}
private void OnGiftMapInit(EntityUid uid, RandomGiftComponent component, MapInitEvent args)
private void OnUseInHand(EntityUid uid, MousetrapComponent component, UseInHandEvent args)
{
+ if (args.Handled)
+ return;
+
component.IsActive = !component.IsActive;
_popupSystem.PopupEntity(component.IsActive
? Loc.GetString("mousetrap-on-activate")
args.User);
UpdateVisuals(uid);
+
+ args.Handled = true;
}
private void OnStepTriggerAttempt(EntityUid uid, MousetrapComponent component, ref StepTriggerAttemptEvent args)
private void OnUseInHand(EntityUid uid, PAIComponent component, UseInHandEvent args)
{
+ // Not checking for Handled because ToggleableGhostRoleSystem already marks it as such.
+
if (!TryComp<MindContainerComponent>(uid, out var mind) || !mind.HasMind)
component.LastUser = args.User;
}
using Content.Shared.Database;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction.Events;
-using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
-using Robust.Shared.Player;
using Robust.Shared.Random;
using static Content.Shared.Storage.EntitySpawnCollection;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly PricingSystem _pricing = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
}
+ // The entity is often deleted, so play the sound at its position rather than parenting
if (component.Sound != null)
- {
- // The entity is often deleted, so play the sound at its position rather than parenting
- var coordinates = Transform(uid).Coordinates;
- _audio.PlayPvs(component.Sound, coordinates);
- }
+ _audio.PlayPvs(component.Sound, coords);
component.Uses--;
// Delete entity only if component was successfully used
if (component.Uses <= 0)
{
- args.Handled = true;
- EntityManager.DeleteEntity(uid);
+ // 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(uid, Transform(uid));
+ QueueDel(uid);
}
if (entityToPlaceInHands != null)
- {
_hands.PickupOrDrop(args.User, entityToPlaceInHands.Value);
- }
+
+ args.Handled = true;
}
}
}
[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()
{
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;
}
}
private void OnUseInHand(EntityUid uid, HandTeleporterComponent component, UseInHandEvent args)
{
+ if (args.Handled)
+ return;
+
if (Deleted(component.FirstPortal))
component.FirstPortal = null;
_doafter.TryStartDoAfter(doafterArgs);
}
+
+ args.Handled = true;
}
private void OnMagazineUse(EntityUid uid, MagazineAmmoProviderComponent component, UseInHandEvent args)
{
+ // not checking for args.Handled or marking as such because we only relay the event to the magazine entity
+
var magEnt = GetMagazineEntity(uid);
if (magEnt == null)
public void OnUseInHand(EntityUid uid, WhistleComponent component, UseInHandEvent args)
{
- if (!_timing.IsFirstTimePredicted)
+ if (args.Handled || !_timing.IsFirstTimePredicted)
return;
- TryMakeLoudWhistle(uid, args.User, component);
- args.Handled = true;
+ args.Handled = TryMakeLoudWhistle(uid, args.User, component);
}
public bool TryMakeLoudWhistle(EntityUid uid, EntityUid owner, WhistleComponent? component = null)