Skip to content

Commit

Permalink
cult pod insert doafter add
Browse files Browse the repository at this point in the history
  • Loading branch information
canvaswalker committed Jan 14, 2025
1 parent 7be50d7 commit 509a23c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Content.Shared/SS220/CultYogg/Pod/CultYoggPodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +19,9 @@ public sealed partial class CultYoggPodComponent : Component
[DataField]
public TimeSpan HealingFreq = TimeSpan.FromSeconds(1);

[DataField]
public TimeSpan InsertDelay = TimeSpan.FromSeconds(6);

/// <summary>
/// Whitelist of entities that are cultists
/// </summary>
Expand Down
35 changes: 32 additions & 3 deletions Content.Shared/SS220/CultYogg/Pod/SharedCultYoggPodSystem.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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()
{
Expand All @@ -23,6 +26,13 @@ public override void Initialize()
SubscribeLocalEvent<CultYoggPodComponent, ComponentInit>(OnCompInit);
SubscribeLocalEvent<CultYoggPodComponent, CanDropTargetEvent>(OnPodCanDrop);
SubscribeLocalEvent<CultYoggPodComponent, GetVerbsEvent<AlternativeVerb>>(AddInsertVerb);
SubscribeLocalEvent<CultYoggPodComponent, AfterPodInserted>(OnPodInsert);
}

private void OnPodInsert(Entity<CultYoggPodComponent> ent, ref AfterPodInserted args)
{
var xform = Transform(args.User);
_container.Insert((args.User, xform), ent.Comp.MobContainer);
}

private void OnPodCanDrop(Entity<CultYoggPodComponent> ent, ref CanDropTargetEvent args)
Expand Down Expand Up @@ -86,11 +96,24 @@ public bool TryInsert(EntityUid entToEnsert, Entity<CultYoggPodComponent> 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<CultYoggPodComponent> podEnt)
Expand All @@ -103,3 +126,9 @@ public bool TryEject(EntityUid entToEject, Entity<CultYoggPodComponent> podEnt)
return true;
}
}

[Serializable, NetSerializable]
public sealed partial class AfterPodInserted : DoAfterEvent
{
public override DoAfterEvent Clone() => this;
}

0 comments on commit 509a23c

Please sign in to comment.