Remove IDropped (#7075)
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Content.Server.Atmos.Components
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(SharedGasAnalyzerComponent))]
|
[ComponentReference(typeof(SharedGasAnalyzerComponent))]
|
||||||
public sealed class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped
|
public sealed class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entities = default!;
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
@@ -256,13 +256,5 @@ namespace Content.Server.Atmos.Components
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropped.Dropped(DroppedEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
if (_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor))
|
|
||||||
{
|
|
||||||
CloseInterface(actor.PlayerSession);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Content.Server.Atmos.Components
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
public sealed class GasTankComponent : Component, IExamine, IGasMixtureHolder, IDropped
|
public sealed class GasTankComponent : Component, IExamine, IGasMixtureHolder
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||||
@@ -31,8 +31,6 @@ namespace Content.Server.Atmos.Components
|
|||||||
|
|
||||||
private int _integrity = 3;
|
private int _integrity = 3;
|
||||||
|
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
||||||
|
|
||||||
[ViewVariables] private BoundUserInterface? _userInterface;
|
[ViewVariables] private BoundUserInterface? _userInterface;
|
||||||
|
|
||||||
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
|
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
|
||||||
@@ -289,10 +287,5 @@ namespace Content.Server.Atmos.Components
|
|||||||
if (_integrity < 3)
|
if (_integrity < 3)
|
||||||
_integrity++;
|
_integrity++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropped.Dropped(DroppedEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
DisconnectFromInternals(eventArgs.User);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -21,6 +22,12 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
SubscribeLocalEvent<GasTankComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUIVerb);
|
SubscribeLocalEvent<GasTankComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUIVerb);
|
||||||
SubscribeLocalEvent<GasTankComponent, GetActionsEvent>(OnGetActions);
|
SubscribeLocalEvent<GasTankComponent, GetActionsEvent>(OnGetActions);
|
||||||
SubscribeLocalEvent<GasTankComponent, ToggleActionEvent>(OnActionToggle);
|
SubscribeLocalEvent<GasTankComponent, ToggleActionEvent>(OnActionToggle);
|
||||||
|
SubscribeLocalEvent<GasTankComponent, DroppedEvent>(OnDropped);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDropped(EntityUid uid, GasTankComponent component, DroppedEvent args)
|
||||||
|
{
|
||||||
|
component.DisconnectFromInternals(args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetActions(EntityUid uid, GasTankComponent component, GetActionsEvent args)
|
private void OnGetActions(EntityUid uid, GasTankComponent component, GetActionsEvent args)
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public sealed class CrayonSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args)
|
private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args)
|
||||||
{
|
{
|
||||||
if (TryComp<ActorComponent>(args.UserUid, out var actor))
|
if (TryComp<ActorComponent>(args.User, out var actor))
|
||||||
component.UserInterface?.Close(actor.PlayerSession);
|
component.UserInterface?.Close(actor.PlayerSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
using Content.Server.Chemistry.Components;
|
using Content.Server.Chemistry.Components;
|
||||||
using Content.Server.Chemistry.EntitySystems;
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
using Content.Server.Fluids.EntitySystems;
|
using Content.Server.Fluids.EntitySystems;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.CharacterAppearance.Systems;
|
|
||||||
using Content.Shared.Extinguisher;
|
using Content.Shared.Extinguisher;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
namespace Content.Server.Extinguisher;
|
namespace Content.Server.Extinguisher;
|
||||||
@@ -28,7 +23,6 @@ public sealed class FireExtinguisherSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<FireExtinguisherComponent, ComponentInit>(OnFireExtinguisherInit);
|
SubscribeLocalEvent<FireExtinguisherComponent, ComponentInit>(OnFireExtinguisherInit);
|
||||||
SubscribeLocalEvent<FireExtinguisherComponent, DroppedEvent>(OnDropped);
|
|
||||||
SubscribeLocalEvent<FireExtinguisherComponent, UseInHandEvent>(OnUseInHand);
|
SubscribeLocalEvent<FireExtinguisherComponent, UseInHandEvent>(OnUseInHand);
|
||||||
SubscribeLocalEvent<FireExtinguisherComponent, AfterInteractEvent>(OnAfterInteract);
|
SubscribeLocalEvent<FireExtinguisherComponent, AfterInteractEvent>(OnAfterInteract);
|
||||||
SubscribeLocalEvent<FireExtinguisherComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
|
SubscribeLocalEvent<FireExtinguisherComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
|
||||||
@@ -43,12 +37,6 @@ public sealed class FireExtinguisherSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDropped(EntityUid uid, FireExtinguisherComponent component, DroppedEvent args)
|
|
||||||
{
|
|
||||||
// idk why this has to be done??????????
|
|
||||||
UpdateAppearance(uid, component);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, FireExtinguisherComponent component, UseInHandEvent args)
|
private void OnUseInHand(EntityUid uid, FireExtinguisherComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Content.Server.UserInterface;
|
|||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Strip.Components;
|
using Content.Shared.Strip.Components;
|
||||||
@@ -247,6 +248,8 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
if (invSystem.TryGetSlotEntity(Owner, slot, out var item) && invSystem.TryUnequip(user, Owner, slot))
|
if (invSystem.TryGetSlotEntity(Owner, slot, out var item) && invSystem.TryUnequip(user, Owner, slot))
|
||||||
{
|
{
|
||||||
|
// Raise a dropped event, so that things like gas tank internals properly deactivate when stripping
|
||||||
|
_entities.EventBus.RaiseLocalEvent(item.Value, new DroppedEvent(user));
|
||||||
userHands.PutInHandOrDrop(item.Value);
|
userHands.PutInHandOrDrop(item.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -635,12 +636,15 @@ namespace Content.Shared.Hands.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Puts an item any hand, prefering the active hand, or puts it on the floor under the player.
|
/// Puts an item any hand, preferring the active hand, or puts it on the floor under the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PutInHandOrDrop(EntityUid entity, bool checkActionBlocker = true)
|
public void PutInHandOrDrop(EntityUid entity, bool checkActionBlocker = true)
|
||||||
{
|
{
|
||||||
if (!PutInHand(entity, checkActionBlocker))
|
if (PutInHand(entity, checkActionBlocker))
|
||||||
_entMan.GetComponent<TransformComponent>(entity).Coordinates = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
return;
|
||||||
|
|
||||||
|
_entMan.GetComponent<TransformComponent>(entity).AttachParentToContainerOrGrid(_entMan);
|
||||||
|
_entMan.EventBus.RaiseLocalEvent(entity, new DroppedEvent(Owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PutInHandOrDrop(SharedItemComponent item, bool checkActionBlocker = true)
|
public void PutInHandOrDrop(SharedItemComponent item, bool checkActionBlocker = true)
|
||||||
@@ -648,7 +652,6 @@ namespace Content.Shared.Hands.Components
|
|||||||
PutInHandOrDrop(item.Owner, checkActionBlocker);
|
PutInHandOrDrop(item.Owner, checkActionBlocker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to pick up an entity into the active hand. If it cannot, tries to pick up the entity into each other hand.
|
/// Tries to pick up an entity into the active hand. If it cannot, tries to pick up the entity into each other hand.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
20
Content.Shared/Interaction/Events/DroppedEvent.cs
Normal file
20
Content.Shared/Interaction/Events/DroppedEvent.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Shared.Interaction.Events;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when an entity is dropped from a users hands, or directly removed from a users inventory, but not when moved between hands & inventory.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
public sealed class DroppedEvent : HandledEntityEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Entity that dropped the item.
|
||||||
|
/// </summary>
|
||||||
|
public EntityUid User { get; }
|
||||||
|
|
||||||
|
public DroppedEvent(EntityUid user)
|
||||||
|
{
|
||||||
|
User = user;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Analyzers;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
|
|
||||||
namespace Content.Shared.Interaction
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This interface gives components behavior when they're dropped by a mob.
|
|
||||||
/// </summary>
|
|
||||||
[RequiresExplicitImplementation]
|
|
||||||
public interface IDropped
|
|
||||||
{
|
|
||||||
[Obsolete("Use DroppedMessage instead")]
|
|
||||||
void Dropped(DroppedEventArgs eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class DroppedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public DroppedEventArgs(EntityUid user)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityUid User { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised when an entity is dropped
|
|
||||||
/// </summary>
|
|
||||||
[PublicAPI]
|
|
||||||
public sealed class DroppedEvent : HandledEntityEventArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Entity that dropped the item.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid UserUid { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Item that was dropped.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid DroppedUid { get; }
|
|
||||||
|
|
||||||
public DroppedEvent(EntityUid user, EntityUid dropped)
|
|
||||||
{
|
|
||||||
UserUid = user;
|
|
||||||
DroppedUid = dropped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -836,46 +836,15 @@ namespace Content.Shared.Interaction
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Drop
|
|
||||||
/// <summary>
|
|
||||||
/// Activates the Dropped behavior of an object
|
|
||||||
/// Verifies that the user is capable of doing the drop interaction first
|
|
||||||
/// </summary>
|
|
||||||
public bool TryDroppedInteraction(EntityUid user, EntityUid item)
|
|
||||||
{
|
|
||||||
if (!_actionBlockerSystem.CanDrop(user)) return false;
|
|
||||||
|
|
||||||
DroppedInteraction(user, item);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calls Dropped on all components that implement the IDropped interface
|
|
||||||
/// on an entity that has been dropped.
|
|
||||||
/// </summary>
|
|
||||||
public void DroppedInteraction(EntityUid user, EntityUid item)
|
public void DroppedInteraction(EntityUid user, EntityUid item)
|
||||||
{
|
{
|
||||||
var dropMsg = new DroppedEvent(user, item);
|
var dropMsg = new DroppedEvent(user);
|
||||||
RaiseLocalEvent(item, dropMsg);
|
RaiseLocalEvent(item, dropMsg);
|
||||||
if (dropMsg.Handled)
|
if (dropMsg.Handled)
|
||||||
{
|
|
||||||
_adminLogSystem.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
|
_adminLogSystem.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform(item).LocalRotation = Angle.Zero;
|
Transform(item).LocalRotation = Angle.Zero;
|
||||||
|
|
||||||
var comps = AllComps<IDropped>(item).ToList();
|
|
||||||
|
|
||||||
// Call Land on all components that implement the interface
|
|
||||||
foreach (var comp in comps)
|
|
||||||
{
|
|
||||||
comp.Dropped(new DroppedEventArgs(user));
|
|
||||||
}
|
|
||||||
_adminLogSystem.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If a target is in range, but not in the same container as the user, it may be inside of a backpack. This
|
/// If a target is in range, but not in the same container as the user, it may be inside of a backpack. This
|
||||||
|
|||||||
Reference in New Issue
Block a user