Skip to content

Commit

Permalink
Ore bag and box now use same component
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalHex committed Dec 9, 2023
1 parent 2491541 commit 21caf4d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 141 deletions.

This file was deleted.

24 changes: 21 additions & 3 deletions Content.Shared/Storage/Components/MagnetPickupComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,30 @@ public sealed partial class MagnetPickupComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField("nextScan")]
public TimeSpan NextScan = TimeSpan.Zero;

[ViewVariables(VVAccess.ReadWrite), DataField("range")]
public float Range = 1f;

/// <summary>
/// What container slot the magnet needs to be in to work.
/// Whether the magnet is attached to a fixture (e.g. ore box) or not (e.g. ore bag)
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("isFixture")]
public bool IsFixture = false;

/// <summary>
/// What container slot the magnet needs to be in to work (if not a fixture)
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("slotFlags")]
public SlotFlags SlotFlags = SlotFlags.BELT;

[ViewVariables(VVAccess.ReadWrite), DataField("range")]
public float Range = 1f;
/// <summary>
/// Is magnet active, when fixture is anchored?
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("pickupWhenAnchored")]
public bool PickupWhenAnchored = true;

/// <summary>
/// Is magnet active, when fixture is not anchored?
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("pickupWhenNotAnchored")]
public bool PickupWhenNotAnchored = true;
}
106 changes: 0 additions & 106 deletions Content.Shared/Storage/EntitySystems/ContainerMagnetPickupSystem.cs

This file was deleted.

13 changes: 10 additions & 3 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ public override void Update(float frameTime)
if (storage.StorageUsed >= storage.StorageCapacityMax)
continue;

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

if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
if (!comp.IsFixture)
{
if (!_inventory.TryGetContainingSlot(uid, out var slotDef))
continue;

if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
continue;
}
// Magnet disabled in current fixture anchor state
else if (xform.Anchored && !comp.PickupWhenAnchored || !xform.Anchored && !comp.PickupWhenNotAnchored)
continue;

var parentUid = xform.ParentUid;
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Entities/Structures/Storage/ore_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
storagebase: !type:Container
ents: [ ]
- type: Dumpable # Frontier
- type: ContainerMagnetPickup # Frontier
- type: MagnetPickup # Frontier
isFixture: true
pickupWhenNotAnchored: true
pickupWhenAnchored: false
range: 1.5 # Ore bag has a range of 1.0
Expand Down

0 comments on commit 21caf4d

Please sign in to comment.