UseInHandEvent cleanup (#35231)
This commit is contained in:
@@ -76,14 +76,13 @@ public sealed class GasAnalyzerSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnUseInHand(Entity<GasAnalyzerComponent> entity, ref UseInHandEvent args)
|
private void OnUseInHand(Entity<GasAnalyzerComponent> entity, ref UseInHandEvent args)
|
||||||
{
|
{
|
||||||
|
// Not checking for Handled because ActivatableUISystem already marks it as such.
|
||||||
|
|
||||||
if (!entity.Comp.Enabled)
|
if (!entity.Comp.Enabled)
|
||||||
{
|
|
||||||
ActivateAnalyzer(entity, args.User);
|
ActivateAnalyzer(entity, args.User);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
DisableAnalyzer(entity, args.User);
|
DisableAnalyzer(entity, args.User);
|
||||||
}
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using Content.Shared.Interaction.Events;
|
|||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Server.Audio;
|
using Robust.Server.Audio;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -26,6 +25,7 @@ public sealed class RandomGiftSystem : EntitySystem
|
|||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
private readonly List<string> _possibleGiftsSafe = new();
|
private readonly List<string> _possibleGiftsSafe = new();
|
||||||
private readonly List<string> _possibleGiftsUnsafe = new();
|
private readonly List<string> _possibleGiftsUnsafe = new();
|
||||||
@@ -63,11 +63,16 @@ public sealed class RandomGiftSystem : EntitySystem
|
|||||||
if (component.Wrapper is not null)
|
if (component.Wrapper is not null)
|
||||||
Spawn(component.Wrapper, coords);
|
Spawn(component.Wrapper, coords);
|
||||||
|
|
||||||
args.Handled = true;
|
|
||||||
_audio.PlayPvs(component.Sound, args.User);
|
_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);
|
_hands.PickupOrDrop(args.User, handsEnt);
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGiftMapInit(EntityUid uid, RandomGiftComponent component, MapInitEvent args)
|
private void OnGiftMapInit(EntityUid uid, RandomGiftComponent component, MapInitEvent args)
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public sealed class MousetrapSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, MousetrapComponent component, UseInHandEvent args)
|
private void OnUseInHand(EntityUid uid, MousetrapComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
component.IsActive = !component.IsActive;
|
component.IsActive = !component.IsActive;
|
||||||
_popupSystem.PopupEntity(component.IsActive
|
_popupSystem.PopupEntity(component.IsActive
|
||||||
? Loc.GetString("mousetrap-on-activate")
|
? Loc.GetString("mousetrap-on-activate")
|
||||||
@@ -35,6 +38,8 @@ public sealed class MousetrapSystem : EntitySystem
|
|||||||
args.User);
|
args.User);
|
||||||
|
|
||||||
UpdateVisuals(uid);
|
UpdateVisuals(uid);
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStepTriggerAttempt(EntityUid uid, MousetrapComponent component, ref StepTriggerAttemptEvent args)
|
private void OnStepTriggerAttempt(EntityUid uid, MousetrapComponent component, ref StepTriggerAttemptEvent args)
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ public sealed class PAISystem : SharedPAISystem
|
|||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, PAIComponent component, UseInHandEvent 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)
|
if (!TryComp<MindContainerComponent>(uid, out var mind) || !mind.HasMind)
|
||||||
component.LastUser = args.User;
|
component.LastUser = args.User;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ using Content.Server.Storage.Components;
|
|||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Robust.Shared.Audio;
|
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using static Content.Shared.Storage.EntitySpawnCollection;
|
using static Content.Shared.Storage.EntitySpawnCollection;
|
||||||
|
|
||||||
@@ -20,6 +18,7 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -80,26 +79,25 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
|
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.Sound != null)
|
|
||||||
{
|
|
||||||
// The entity is often deleted, so play the sound at its position rather than parenting
|
// The entity is often deleted, so play the sound at its position rather than parenting
|
||||||
var coordinates = Transform(uid).Coordinates;
|
if (component.Sound != null)
|
||||||
_audio.PlayPvs(component.Sound, coordinates);
|
_audio.PlayPvs(component.Sound, coords);
|
||||||
}
|
|
||||||
|
|
||||||
component.Uses--;
|
component.Uses--;
|
||||||
|
|
||||||
// Delete entity only if component was successfully used
|
// Delete entity only if component was successfully used
|
||||||
if (component.Uses <= 0)
|
if (component.Uses <= 0)
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
// Don't delete the entity in the event bus, so we queue it for deletion.
|
||||||
EntityManager.DeleteEntity(uid);
|
// 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)
|
if (entityToPlaceInHands != null)
|
||||||
{
|
|
||||||
_hands.PickupOrDrop(args.User, entityToPlaceInHands.Value);
|
_hands.PickupOrDrop(args.User, entityToPlaceInHands.Value);
|
||||||
}
|
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public sealed class SpawnTableOnUseSystem : EntitySystem
|
|||||||
[Dependency] private readonly EntityTableSystem _entityTable = default!;
|
[Dependency] private readonly EntityTableSystem _entityTable = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -25,17 +26,21 @@ public sealed class SpawnTableOnUseSystem : EntitySystem
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
|
||||||
|
|
||||||
var coords = Transform(ent).Coordinates;
|
var coords = Transform(ent).Coordinates;
|
||||||
var spawns = _entityTable.GetSpawns(ent.Comp.Table);
|
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)
|
foreach (var id in spawns)
|
||||||
{
|
{
|
||||||
var spawned = Spawn(id, coords);
|
var spawned = Spawn(id, coords);
|
||||||
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User):user} used {ToPrettyString(ent):spawner} which spawned {ToPrettyString(spawned)}");
|
_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public sealed class HandTeleporterSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, HandTeleporterComponent component, UseInHandEvent args)
|
private void OnUseInHand(EntityUid uid, HandTeleporterComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Deleted(component.FirstPortal))
|
if (Deleted(component.FirstPortal))
|
||||||
component.FirstPortal = null;
|
component.FirstPortal = null;
|
||||||
|
|
||||||
@@ -67,6 +70,8 @@ public sealed class HandTeleporterSystem : EntitySystem
|
|||||||
|
|
||||||
_doafter.TryStartDoAfter(doafterArgs);
|
_doafter.TryStartDoAfter(doafterArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
private void OnMagazineUse(EntityUid uid, MagazineAmmoProviderComponent component, UseInHandEvent args)
|
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);
|
var magEnt = GetMagazineEntity(uid);
|
||||||
|
|
||||||
if (magEnt == null)
|
if (magEnt == null)
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ public sealed class WhistleSystem : EntitySystem
|
|||||||
|
|
||||||
public void OnUseInHand(EntityUid uid, WhistleComponent component, UseInHandEvent args)
|
public void OnUseInHand(EntityUid uid, WhistleComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
if (!_timing.IsFirstTimePredicted)
|
if (args.Handled || !_timing.IsFirstTimePredicted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TryMakeLoudWhistle(uid, args.User, component);
|
args.Handled = TryMakeLoudWhistle(uid, args.User, component);
|
||||||
args.Handled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryMakeLoudWhistle(EntityUid uid, EntityUid owner, WhistleComponent? component = null)
|
public bool TryMakeLoudWhistle(EntityUid uid, EntityUid owner, WhistleComponent? component = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user