diff --git a/Content.Shared/SS220/CultYogg/Pod/CultYoggPodComponent.cs b/Content.Shared/SS220/CultYogg/Pod/CultYoggPodComponent.cs index fb9eb6dfa2b1..3acdee32208c 100644 --- a/Content.Shared/SS220/CultYogg/Pod/CultYoggPodComponent.cs +++ b/Content.Shared/SS220/CultYogg/Pod/CultYoggPodComponent.cs @@ -3,6 +3,7 @@ using Robust.Shared.Containers; using Robust.Shared.Serialization; using Content.Shared.Damage; +using Content.Shared.DoAfter; using Content.Shared.Whitelist; using Robust.Shared.GameStates; using Content.Shared.SS220.CultYogg.MiGo; @@ -18,6 +19,9 @@ public sealed partial class CultYoggPodComponent : Component [DataField] public TimeSpan HealingFreq = TimeSpan.FromSeconds(1); + [DataField] + public TimeSpan InsertDelay = TimeSpan.FromSeconds(6); + /// /// Whitelist of entities that are cultists /// diff --git a/Content.Shared/SS220/CultYogg/Pod/SharedCultYoggPodSystem.cs b/Content.Shared/SS220/CultYogg/Pod/SharedCultYoggPodSystem.cs index eebabe52e3e6..2bf5b7e7fbb0 100644 --- a/Content.Shared/SS220/CultYogg/Pod/SharedCultYoggPodSystem.cs +++ b/Content.Shared/SS220/CultYogg/Pod/SharedCultYoggPodSystem.cs @@ -1,12 +1,14 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt using Content.Shared.Damage; +using Content.Shared.DoAfter; using Content.Shared.DragDrop; using Content.Shared.Mobs.Components; using Content.Shared.Popups; using Content.Shared.Verbs; using Content.Shared.Whitelist; using Robust.Shared.Containers; +using Robust.Shared.Serialization; namespace Content.Shared.SS220.CultYogg.Pod; @@ -15,6 +17,7 @@ public abstract class SharedCultYoggPodSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly EntityWhitelistSystem _entityWhitelist = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; public override void Initialize() { @@ -23,6 +26,13 @@ public override void Initialize() SubscribeLocalEvent(OnCompInit); SubscribeLocalEvent(OnPodCanDrop); SubscribeLocalEvent>(AddInsertVerb); + SubscribeLocalEvent(OnPodInsert); + } + + private void OnPodInsert(Entity ent, ref AfterPodInserted args) + { + var xform = Transform(args.User); + _container.Insert((args.User, xform), ent.Comp.MobContainer); } private void OnPodCanDrop(Entity ent, ref CanDropTargetEvent args) @@ -86,11 +96,24 @@ public bool TryInsert(EntityUid entToEnsert, Entity podEnt return false; } - var xform = Transform(entToEnsert); + var insertDoAfter = new DoAfterArgs( + EntityManager, + entToEnsert, + podEnt.Comp.InsertDelay, + new AfterPodInserted(), + podEnt) + { + Broadcast = false, + BreakOnDamage = true, + BreakOnMove = true, + NeedHand = false, - _container.Insert((entToEnsert, xform), podEnt.Comp.MobContainer); + BlockDuplicate = true, + CancelDuplicate = true, + DuplicateCondition = DuplicateConditions.SameEvent + }; - return true; + return _doAfter.TryStartDoAfter(insertDoAfter); } public bool TryEject(EntityUid entToEject, Entity podEnt) @@ -103,3 +126,9 @@ public bool TryEject(EntityUid entToEject, Entity podEnt) return true; } } + +[Serializable, NetSerializable] +public sealed partial class AfterPodInserted : DoAfterEvent +{ + public override DoAfterEvent Clone() => this; +}