Skip to content

Commit

Permalink
Magnet (#568)
Browse files Browse the repository at this point in the history
* Magnet

* Ore

* Not Needed

* Bags + Magnets = Good

* Fix

* Update portable_generator.yml

* Update books_bag.yml
  • Loading branch information
dvir001 authored Nov 13, 2023
1 parent c3042bf commit 7d9b5e9
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Content.Shared.Tag;
using Content.Shared.Whitelist;

namespace Content.Server.Storage.Components;

/// <summary>
Expand All @@ -14,10 +11,4 @@ public sealed partial class MaterialReclaimerMagnetPickupComponent : Component

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

[ViewVariables(VVAccess.ReadWrite), DataField("whitelist")]
public EntityWhitelist? Whitelist;

[ViewVariables(VVAccess.ReadWrite), DataField("blacklist")]
public EntityWhitelist? Blacklist;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Content.Shared.Tag;
using Content.Shared.Whitelist;

namespace Content.Server.Storage.Components;

/// <summary>
Expand All @@ -14,10 +11,4 @@ public sealed partial class MaterialStorageMagnetPickupComponent : Component

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

[ViewVariables(VVAccess.ReadWrite), DataField("whitelist")]
public EntityWhitelist? Whitelist;

[ViewVariables(VVAccess.ReadWrite), DataField("blacklist")]
public EntityWhitelist? Blacklist;
}
5 changes: 1 addition & 4 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Content.Server.Storage.Components;
using Content.Shared.Hands;
using Content.Shared.Inventory;
using Content.Shared.Stacks;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Shared.Storage.EntitySystems;
Expand Down Expand Up @@ -39,7 +36,7 @@ private void OnMagnetUnpaused(EntityUid uid, MagnetPickupComponent component, re

private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, MapInitEvent args)
{
component.NextScan = _timing.CurTime + TimeSpan.FromSeconds(1f);
component.NextScan = _timing.CurTime;
}

public override void Update(float frameTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public sealed class MaterialReclaimerMagnetPickupSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedMaterialReclaimerSystem _storage = default!;

private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);
Expand Down Expand Up @@ -40,8 +39,8 @@ private void OnMagnetMapInit(EntityUid uid, MaterialReclaimerMagnetPickupCompone
public override void Update(float frameTime)
{
base.Update(frameTime);
var currentTime = _timing.CurTime;
var query = EntityQueryEnumerator<MaterialReclaimerMagnetPickupComponent, MaterialReclaimerComponent, TransformComponent>();
var currentTime = _timing.CurTime;

while (query.MoveNext(out var uid, out var comp, out var storage, out var xform))
{
Expand All @@ -54,12 +53,6 @@ public override void Update(float frameTime)

foreach (var near in _lookup.GetEntitiesInRange(uid, comp.Range, LookupFlags.Dynamic | LookupFlags.Sundries))
{
if (comp.Blacklist is { } blacklist && blacklist.IsValid(near, EntityManager) == true)
continue;

if (comp.Whitelist is { } whitelist && whitelist.IsValid(near, EntityManager) == false)
continue;

if (!_physicsQuery.TryGetComponent(near, out var physics) || physics.BodyStatus != BodyStatus.OnGround)
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public sealed class MaterialStorageMagnetPickupSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedMaterialStorageSystem _storage = default!;

private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);
Expand Down Expand Up @@ -40,8 +39,8 @@ private void OnMagnetMapInit(EntityUid uid, MaterialStorageMagnetPickupComponent
public override void Update(float frameTime)
{
base.Update(frameTime);
var currentTime = _timing.CurTime;
var query = EntityQueryEnumerator<MaterialStorageMagnetPickupComponent, MaterialStorageComponent, TransformComponent>();
var currentTime = _timing.CurTime;

while (query.MoveNext(out var uid, out var comp, out var storage, out var xform))
{
Expand All @@ -54,12 +53,6 @@ public override void Update(float frameTime)

foreach (var near in _lookup.GetEntitiesInRange(uid, comp.Range, LookupFlags.Dynamic | LookupFlags.Sundries))
{
if (comp.Blacklist is { } blacklist && blacklist.IsValid(near, EntityManager) == true)
continue;

if (comp.Whitelist is { } whitelist && whitelist.IsValid(near, EntityManager) == false)
continue;

if (!_physicsQuery.TryGetComponent(near, out var physics) || physics.BodyStatus != BodyStatus.OnGround)
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
- Bottle
- Syringe
- type: Dumpable
- type: MagnetPickup # Frontier
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@
- Produce
- Seed
- type: Dumpable
- type: MagnetPickup
- type: MagnetPickup # Frontier
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
- Book
- Document
- type: Dumpable
- type: MagnetPickup # Frontier
5 changes: 1 addition & 4 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -878,11 +878,8 @@
- IngotGold30
- IngotSilver30
- MaterialBananium10
- type: MaterialStorageMagnetPickup
- type: MaterialStorageMagnetPickup # Frontier
range: 0.30
whitelist:
tags:
- Ore

- type: entity
parent: BaseLathe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,5 @@
solution: output
- type: StaticPrice
price: 500
- type: MaterialReclaimerMagnetPickup
- type: MaterialReclaimerMagnetPickup # Frontier
range: 0.30
whitelist:
components:
- PhysicalComposition
- SpaceGarbage
tags:
- Trash
- Recyclable
blacklist:
components:
- Material
- Pda
- IdCard
tags:
- HighRiskItem
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
whitelist:
components:
- Mail
- type: MagnetPickup # Frontier

0 comments on commit 7d9b5e9

Please sign in to comment.