Remove instant cryobed insertion (#34619)
* added optional delay to DragInsertContainerComponent * comments * Change EntryDelay on DragInsertContainerComponent to use TimeSpan + cleanup * changed drag insert container comp to match naming conventions
This commit is contained in:
@@ -17,4 +17,16 @@ public sealed partial class DragInsertContainerComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool UseVerbs = true;
|
public bool UseVerbs = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The delay in seconds before a drag will be completed.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public TimeSpan EntryDelay = TimeSpan.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If entry delay isn't zero, this sets whether an entity dragging itself into the container should be delayed.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool DelaySelfEntry = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,28 @@ using Content.Shared.ActionBlocker;
|
|||||||
using Content.Shared.Administration.Logs;
|
using Content.Shared.Administration.Logs;
|
||||||
using Content.Shared.Climbing.Systems;
|
using Content.Shared.Climbing.Systems;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Containers;
|
namespace Content.Shared.Containers;
|
||||||
|
|
||||||
public sealed class DragInsertContainerSystem : EntitySystem
|
public sealed partial class DragInsertContainerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ISharedAdminLogManager _adminLog = default!;
|
[Dependency] private readonly ISharedAdminLogManager _adminLog = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||||
[Dependency] private readonly ClimbSystem _climb = default!;
|
[Dependency] private readonly ClimbSystem _climb = default!;
|
||||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<DragInsertContainerComponent, DragDropTargetEvent>(OnDragDropOn, before: new []{ typeof(ClimbSystem)});
|
SubscribeLocalEvent<DragInsertContainerComponent, DragDropTargetEvent>(OnDragDropOn, before: new []{ typeof(ClimbSystem)});
|
||||||
|
SubscribeLocalEvent<DragInsertContainerComponent, DragInsertContainerDoAfterEvent>(OnDragFinished);
|
||||||
SubscribeLocalEvent<DragInsertContainerComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
SubscribeLocalEvent<DragInsertContainerComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
||||||
SubscribeLocalEvent<DragInsertContainerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerb);
|
SubscribeLocalEvent<DragInsertContainerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerb);
|
||||||
}
|
}
|
||||||
@@ -33,7 +37,34 @@ public sealed class DragInsertContainerSystem : EntitySystem
|
|||||||
if (!_container.TryGetContainer(ent, comp.ContainerId, out var container))
|
if (!_container.TryGetContainer(ent, comp.ContainerId, out var container))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (comp.EntryDelay <= TimeSpan.Zero ||
|
||||||
|
!comp.DelaySelfEntry && args.User == args.Dragged)
|
||||||
|
{
|
||||||
|
//instant insertion
|
||||||
args.Handled = Insert(args.Dragged, args.User, ent, container);
|
args.Handled = Insert(args.Dragged, args.User, ent, container);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//delayed insertion
|
||||||
|
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, comp.EntryDelay, new DragInsertContainerDoAfterEvent(), ent, args.Dragged, ent)
|
||||||
|
{
|
||||||
|
BreakOnDamage = true,
|
||||||
|
BreakOnMove = true,
|
||||||
|
NeedHand = false,
|
||||||
|
};
|
||||||
|
_doAfter.TryStartDoAfter(doAfterArgs);
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDragFinished(Entity<DragInsertContainerComponent> ent, ref DragInsertContainerDoAfterEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled || args.Cancelled || args.Args.Target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_container.TryGetContainer(ent, ent.Comp.ContainerId, out var container))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Insert(args.Args.Target.Value, args.User, ent, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCanDragDropOn(Entity<DragInsertContainerComponent> ent, ref CanDropTargetEvent args)
|
private void OnCanDragDropOn(Entity<DragInsertContainerComponent> ent, ref CanDropTargetEvent args)
|
||||||
@@ -117,4 +148,9 @@ public sealed class DragInsertContainerSystem : EntitySystem
|
|||||||
_adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user):player} inserted {ToPrettyString(target):player} into container {ToPrettyString(containerEntity)}");
|
_adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user):player} inserted {ToPrettyString(target):player} into container {ToPrettyString(containerEntity)}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed partial class DragInsertContainerDoAfterEvent : SimpleDoAfterEvent
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
canCollide: false
|
canCollide: false
|
||||||
- type: DragInsertContainer
|
- type: DragInsertContainer
|
||||||
containerId: storage
|
containerId: storage
|
||||||
|
entryDelay: 2
|
||||||
- type: ExitContainerOnMove
|
- type: ExitContainerOnMove
|
||||||
containerId: storage
|
containerId: storage
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
|
|||||||
Reference in New Issue
Block a user