mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Moved dropped event to raise after dropped item is moved (#44372)
* init * .
This commit is contained in:
parent
3b95f3be96
commit
de842aace4
3 changed files with 21 additions and 17 deletions
|
|
@ -15,6 +15,7 @@ using Robust.Client.Player;
|
|||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
|
@ -92,9 +93,11 @@ namespace Content.Client.Hands.Systems
|
|||
public override void DoDrop(Entity<HandsComponent?> ent,
|
||||
string handId,
|
||||
bool doDropInteraction = true,
|
||||
bool log = true)
|
||||
bool log = true,
|
||||
EntityCoordinates? targetDropLocation = null
|
||||
)
|
||||
{
|
||||
base.DoDrop(ent, handId, doDropInteraction, log);
|
||||
base.DoDrop(ent, handId, doDropInteraction, log, targetDropLocation);
|
||||
|
||||
if (TryGetHeldItem(ent, handId, out var held) && TryComp(held, out SpriteComponent? sprite))
|
||||
sprite.RenderOrder = EntityManager.CurrentTick.Value;
|
||||
|
|
|
|||
|
|
@ -154,17 +154,7 @@ public abstract partial class SharedHandsSystem
|
|||
|
||||
// drop the item with heavy calculations from their hands and place it at the calculated interaction range position
|
||||
// The DoDrop is handle if there's no drop target
|
||||
DoDrop(ent, handId, doDropInteraction: doDropInteraction);
|
||||
|
||||
// if there's no drop location stop here
|
||||
if (targetDropLocation == null)
|
||||
return true;
|
||||
|
||||
// otherwise, also move dropped item and rotate it properly according to grid/map
|
||||
var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity.Value);
|
||||
var origin = new MapCoordinates(itemPos, itemXform.MapID);
|
||||
var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value);
|
||||
TransformSystem.SetWorldPositionRotation(entity.Value, GetFinalDropCoordinates(ent, origin, target, entity.Value), itemRot);
|
||||
DoDrop(ent, handId, doDropInteraction: doDropInteraction, targetDropLocation: targetDropLocation);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +225,9 @@ public abstract partial class SharedHandsSystem
|
|||
public virtual void DoDrop(Entity<HandsComponent?> ent,
|
||||
string handId,
|
||||
bool doDropInteraction = true,
|
||||
bool log = true)
|
||||
bool log = true,
|
||||
EntityCoordinates? targetDropLocation = null
|
||||
)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp, false))
|
||||
return;
|
||||
|
|
@ -255,6 +247,15 @@ public abstract partial class SharedHandsSystem
|
|||
return;
|
||||
}
|
||||
|
||||
if (targetDropLocation != null)
|
||||
{
|
||||
var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity.Value);
|
||||
// otherwise, also move dropped item and rotate it properly according to grid/map
|
||||
var origin = new MapCoordinates(itemPos, Transform(entity.Value).MapID);
|
||||
var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value);
|
||||
TransformSystem.SetWorldPositionRotation(entity.Value, GetFinalDropCoordinates(ent, origin, target, entity.Value), itemRot);
|
||||
}
|
||||
|
||||
Dirty(ent);
|
||||
|
||||
if (doDropInteraction)
|
||||
|
|
|
|||
|
|
@ -1266,9 +1266,6 @@ namespace Content.Shared.Interaction
|
|||
if (IsDeleted(user) || IsDeleted(item))
|
||||
return;
|
||||
|
||||
var dropMsg = new DroppedEvent(user);
|
||||
RaiseLocalEvent(item, dropMsg, true);
|
||||
|
||||
// If the dropper is rotated then use their targetrelativerotation as the drop rotation
|
||||
var rotation = Angle.Zero;
|
||||
|
||||
|
|
@ -1278,6 +1275,9 @@ namespace Content.Shared.Interaction
|
|||
}
|
||||
|
||||
Transform(item).LocalRotation = rotation;
|
||||
|
||||
var dropMsg = new DroppedEvent(user);
|
||||
RaiseLocalEvent(item, dropMsg, true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue