Skip to content

Commit

Permalink
Merge pull request #1171 from TGRCdev/revenant-unembed
Browse files Browse the repository at this point in the history
Revenants now unembed projectiles upon becoming uncorporeal
  • Loading branch information
Darkmajia authored Dec 30, 2024
2 parents 9370025 + 03f0569 commit 27c1f1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Content.Server/Revenant/EntitySystems/CorporealSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.GameTicking;
using Content.Shared.Eye;
using Content.Shared.Projectiles;
using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.EntitySystems;
using Robust.Server.GameObjects;
Expand All @@ -10,6 +11,7 @@ public sealed class CorporealSystem : SharedCorporealSystem
{
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly SharedProjectileSystem _projectile = default!;

public override void OnStartup(EntityUid uid, CorporealComponent component, ComponentStartup args)
{
Expand All @@ -27,6 +29,15 @@ public override void OnShutdown(EntityUid uid, CorporealComponent component, Com
{
base.OnShutdown(uid, component, args);

// Imp edit
// Remove all embedded projectiles from the revenant
var childEnumerator = Transform(uid).ChildEnumerator;
while (childEnumerator.MoveNext(out var child))
{
if (TryComp<EmbeddableProjectileComponent>(child, out var embeddable))
_projectile.RemoveEmbed(child, embeddable);
}

if (TryComp<VisibilityComponent>(uid, out var visibility) && _ticker.RunLevel != GameRunLevel.PostRound)
{
_visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Ghost, false);
Expand Down
16 changes: 8 additions & 8 deletions Content.Shared/Projectiles/SharedProjectileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@ private void AddPullOutVerb(EntityUid uid, EmbeddableProjectileComponent compone
});
}

private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent component, RemoveEmbeddedProjectileEvent args)
{
if (args.Cancelled)
return;

RemoveEmbed(uid, component, args.User);
}

public void RemoveEmbed(EntityUid uid, EmbeddableProjectileComponent component, EntityUid? remover = null)
{
component.AutoRemoveTime = null;
Expand Down Expand Up @@ -174,6 +166,14 @@ public void RemoveEmbed(EntityUid uid, EmbeddableProjectileComponent component,
_hands.TryPickupAnyHand(removerUid, uid);
}

private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent component, RemoveEmbeddedProjectileEvent args)
{
// Whacky prediction issues.
if (args.Cancelled || _netManager.IsClient)
return;

RemoveEmbed(uid, component, args.User);
}
private void OnEmbedThrowDoHit(EntityUid uid, EmbeddableProjectileComponent component, ThrowDoHitEvent args)
{
if (HasComp<PacifiedComponent>(args.Component.Thrower)
Expand Down

0 comments on commit 27c1f1b

Please sign in to comment.