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

[Feature] Added Toggle to magnetPickupSystem / [FIX] Ore Processor Fix #15

Merged
merged 12 commits into from
Sep 3, 2024
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);
HellCatten marked this conversation as resolved.
Show resolved Hide resolved

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
@@ -0,0 +1,5 @@
## Used when examining the MagnetPickupComponent
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
## Выводится при осмотре предмета с MagnetPickupCompontent

comp-magnet-pickup-examined-on = Магнит сейчас [color=darkgreen]включен[/color].
comp-magnet-pickup-examined-off = Магнит сейчас [color=darkred]выключен[/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
Loading