Skip to content

Commit

Permalink
[NEW] Added toggle to magnetPickupSystem / [FIX] ore processor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HellCatten committed Aug 23, 2024
1 parent b985fc9 commit 4df9d4c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Content.Server.Storage.Components;
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.Item.ItemToggle;
using Content.Shared.Item.ItemToggle.Components;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
Expand All @@ -16,6 +19,7 @@ public sealed class MagnetPickupSystem : EntitySystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!;

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

Expand All @@ -25,6 +29,7 @@ public override void Initialize()
{
base.Initialize();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<MagnetPickupComponent, ExaminedEvent>(onExamined);
SubscribeLocalEvent<MagnetPickupComponent, MapInitEvent>(OnMagnetMapInit);
}

Expand All @@ -33,6 +38,14 @@ private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, Map
component.NextScan = _timing.CurTime;
}

private void onExamined(Entity<MagnetPickupComponent> entity, ref ExaminedEvent args)
{
var onMsg = _itemToggle.IsActivated(entity.Owner)
? Loc.GetString("comp-magnet-pickup-examined-on")
: Loc.GetString("comp-magnet-pickup-examined-off");
args.PushMarkup(onMsg);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand All @@ -41,6 +54,11 @@ public override void Update(float frameTime)

while (query.MoveNext(out var uid, out var comp, out var storage, out var xform, out var meta))
{
TryComp<ItemToggleComponent>(uid, out var toggle);

if (!_itemToggle.IsActivated(uid, toggle))
continue;

if (comp.NextScan > currentTime)
continue;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Used when examining the MagnetPickupComponent

comp-magnet-pickup-examined-on = the magnet is currently [color=darkgreen]on[/color].
comp-magnet-pickup-examined-off = the magnet is currently [color=darkred]off[/color].
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@
- ArtifactFragment
- Ore
- type: Dumpable
- type: ItemToggle
soundActivate:
collection: sparks
params:
variation: 0.250
soundDeactivate:
collection: sparks
params:
variation: 0.250
3 changes: 2 additions & 1 deletion Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@
- type: MaterialStorageMagnetPickup # Delta V - Summary: Adds magnet pull from Frontier
magnetEnabled: True
range: 0.30 # Delta V - End Magnet Pull
- type: PlaceableSurface

- type: entity
parent: OreProcessor
Expand Down Expand Up @@ -1412,4 +1413,4 @@
- type: MaterialStorage
whitelist:
tags:
- PrizeTicket
- PrizeTicket

0 comments on commit 4df9d4c

Please sign in to comment.