Remove IDropped (#7075)
This commit is contained in:
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
|
||||
|
||||
#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)
|
||||
{
|
||||
var dropMsg = new DroppedEvent(user, item);
|
||||
var dropMsg = new DroppedEvent(user);
|
||||
RaiseLocalEvent(item, dropMsg);
|
||||
if (dropMsg.Handled)
|
||||
{
|
||||
_adminLogSystem.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// 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