Skip to content

Commit

Permalink
Changed ContainingSlot/SlotDef checks. Added ForcePickup.
Browse files Browse the repository at this point in the history
  • Loading branch information
HellCatten committed Aug 30, 2024
1 parent 7d0ef55 commit f797483
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Content.Shared/Storage/Components/MagnetPickupComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public sealed partial class MagnetPickupComponent : Component
public TimeSpan NextScan = TimeSpan.Zero;

/// <summary>
/// What container slot the magnet needs to be in to work.
/// If true, ignores SlotFlags and can magnet pickup on hands/ground.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("slotFlags")]
public SlotFlags SlotFlags = SlotFlags.BELT;
[ViewVariables(VVAccess.ReadWrite)]
public bool ForcePickup = true;

[ViewVariables(VVAccess.ReadWrite), DataField("range")]
public float Range = 1f;
Expand Down
15 changes: 8 additions & 7 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class MagnetPickupSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!; // WD EDIT
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedItemSystem _item = default!; // White Dream

private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);

Expand All @@ -32,7 +32,7 @@ public override void Initialize()
{
base.Initialize();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<MagnetPickupComponent, ItemToggledEvent>(ToggleDone);
SubscribeLocalEvent<MagnetPickupComponent, ItemToggledEvent>(ToggleDone); // White Dream
SubscribeLocalEvent<MagnetPickupComponent, ExaminedEvent>(onExamined); // WD EDIT
SubscribeLocalEvent<MagnetPickupComponent, MapInitEvent>(OnMagnetMapInit);
}
Expand All @@ -42,7 +42,7 @@ private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, Map
component.NextScan = _timing.CurTime;
}

//WD EDIT
//WD EDIT start
private void onExamined(Entity<MagnetPickupComponent> entity, ref ExaminedEvent args)
{
var onMsg = _itemToggle.IsActivated(entity.Owner)
Expand All @@ -55,6 +55,7 @@ private void ToggleDone(Entity<MagnetPickupComponent> entity, ref ItemToggledEve
{
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off");
}
//WD EDIT end

public override void Update(float frameTime)
{
Expand All @@ -77,11 +78,11 @@ public override void Update(float frameTime)

comp.NextScan += ScanDelay;

if (!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef))
continue;

if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
// WD EDIT START. Added ForcePickup.
if (!comp.ForcePickup &&
!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef))
continue;
//WD EDIT END.

// No space
if (!_storage.HasSpace((uid, storage)))
Expand Down

0 comments on commit f797483

Please sign in to comment.