Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port borg downing fix #3117

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Content.Server/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Content.Shared._NF.Standing;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Standing;
Expand Down Expand Up @@ -26,6 +27,9 @@ private void FallOver(EntityUid uid, StandingStateComponent component, DropHandI
if (!TryComp(uid, out HandsComponent? handsComp))
return;

if (HasComp<PreventDropOnDownedComponent>(uid)) // Frontier: stop dropping items when falling over.
return; // Frontier

var worldRotation = _transformSystem.GetWorldRotation(uid).ToVec();
foreach (var hand in handsComp.Hands.Values)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,19 @@ public sealed partial class HandPlaceholderSystem : EntitySystem

public override void Initialize()
{
SubscribeLocalEvent<HandPlaceholderRemoveableComponent, GotUnequippedHandEvent>(OnUnequipHand);
SubscribeLocalEvent<HandPlaceholderRemoveableComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<HandPlaceholderRemoveableComponent, EntGotRemovedFromContainerMessage>(OnEntityRemovedFromContainer);

SubscribeLocalEvent<HandPlaceholderComponent, AfterInteractEvent>(AfterInteract);
SubscribeLocalEvent<HandPlaceholderComponent, BeforeRangedInteractEvent>(BeforeRangedInteract);
}

private void OnUnequipHand(Entity<HandPlaceholderRemoveableComponent> ent, ref GotUnequippedHandEvent args)
private void OnEntityRemovedFromContainer(Entity<HandPlaceholderRemoveableComponent> ent, ref EntGotRemovedFromContainerMessage args)
{
if (args.Handled)
return; // If this is happening in practice, this is a bug.

SpawnAndPickUpPlaceholder(ent, args.User);
RemCompDeferred<HandPlaceholderRemoveableComponent>(ent);
args.Handled = true;
}

private void OnDropped(Entity<HandPlaceholderRemoveableComponent> ent, ref DroppedEvent args)
{
if (args.Handled)
return; // If this is happening in practice, this is a bug.

SpawnAndPickUpPlaceholder(ent, args.User);
SpawnAndPickUpPlaceholder(ent, args.Container);
RemCompDeferred<HandPlaceholderRemoveableComponent>(ent);
args.Handled = true;
}

private void SpawnAndPickUpPlaceholder(Entity<HandPlaceholderRemoveableComponent> ent, EntityUid user)
private void SpawnAndPickUpPlaceholder(Entity<HandPlaceholderRemoveableComponent> ent, BaseContainer container)
{
if (_net.IsServer)
{
Expand All @@ -71,7 +56,7 @@ private void SpawnAndPickUpPlaceholder(Entity<HandPlaceholderRemoveableComponent
if (_proto.TryIndex(ent.Comp.Prototype, out var itemProto))
_metadata.SetEntityName(placeholder, itemProto.Name);

if (!_hands.TryPickup(user, placeholder)) // Can we get the hand this came from?
if (!_container.Insert(placeholder, container, force: true))
QueueDel(placeholder);
}
}
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/_NF/Standing/PreventDropOnDownedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Shared._NF.Standing;

/// <summary>
/// This component prevents an entity from dropping its held items when it falls over.
/// </summary>
[RegisterComponent]
public sealed partial class PreventDropOnDownedComponent : Component;
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
- PsionicInvisibility
- Normal
- type: JetpackUser # DeltaV: Lets cyborgs fly in space
- type: PreventDropOnDowned # Frontier: borgs don't drop items when falling (e.g. critical/dead)

- type: entity
abstract: true
Expand Down
Loading