From 7d9b5e94bca807c3ce0ef89722152c4de41e320e Mon Sep 17 00:00:00 2001 From: Dvir <39403717+dvir001@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:17:25 +0200 Subject: [PATCH] Magnet (#568) * Magnet * Ore * Not Needed * Bags + Magnets = Good * Fix * Update portable_generator.yml * Update books_bag.yml --- .../MaterialReclaimerMagnetPickupComponent.cs | 9 --------- .../MaterialStorageMagnetPickupComponent.cs | 9 --------- .../Storage/EntitySystems/MagnetPickupSystem.cs | 5 +---- .../MaterialReclaimerMagnetPickupSystem.cs | 9 +-------- .../MaterialStorageMagnetPickupSystem.cs | 9 +-------- .../Objects/Specific/Chemistry/chem_bag.yml | 1 + .../Objects/Specific/Hydroponics/tools.yml | 2 +- .../Objects/Specific/Librarian/books_bag.yml | 1 + .../Entities/Structures/Machines/lathe.yml | 5 +---- .../Structures/Machines/material_reclaimer.yml | 16 +--------------- .../Entities/Objects/Specific/Mail/tools.yml | 1 + 11 files changed, 9 insertions(+), 58 deletions(-) diff --git a/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs b/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs index 86c3bb83fb8..8f407650eac 100644 --- a/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs +++ b/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs @@ -1,6 +1,3 @@ -using Content.Shared.Tag; -using Content.Shared.Whitelist; - namespace Content.Server.Storage.Components; /// @@ -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; } diff --git a/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs b/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs index e2ced955e8d..bf49a942134 100644 --- a/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs +++ b/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs @@ -1,6 +1,3 @@ -using Content.Shared.Tag; -using Content.Shared.Whitelist; - namespace Content.Server.Storage.Components; /// @@ -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; } diff --git a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs index 36c604d9403..fe623fb1410 100644 --- a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs @@ -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; @@ -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) diff --git a/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs index 391a45e6faf..eb4f55127e5 100644 --- a/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs @@ -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); @@ -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(); + var currentTime = _timing.CurTime; while (query.MoveNext(out var uid, out var comp, out var storage, out var xform)) { @@ -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; diff --git a/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs index 0be765f3998..d487985d875 100644 --- a/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs @@ -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); @@ -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(); + var currentTime = _timing.CurTime; while (query.MoveNext(out var uid, out var comp, out var storage, out var xform)) { @@ -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; diff --git a/Resources/Prototypes/Entities/Objects/Specific/Chemistry/chem_bag.yml b/Resources/Prototypes/Entities/Objects/Specific/Chemistry/chem_bag.yml index 8be5fecb4f1..dd97c011229 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Chemistry/chem_bag.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Chemistry/chem_bag.yml @@ -26,3 +26,4 @@ - Bottle - Syringe - type: Dumpable + - type: MagnetPickup # Frontier diff --git a/Resources/Prototypes/Entities/Objects/Specific/Hydroponics/tools.yml b/Resources/Prototypes/Entities/Objects/Specific/Hydroponics/tools.yml index d43470b7483..5fc36f6113f 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Hydroponics/tools.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Hydroponics/tools.yml @@ -137,4 +137,4 @@ - Produce - Seed - type: Dumpable - - type: MagnetPickup + - type: MagnetPickup # Frontier diff --git a/Resources/Prototypes/Entities/Objects/Specific/Librarian/books_bag.yml b/Resources/Prototypes/Entities/Objects/Specific/Librarian/books_bag.yml index 2ad28399a66..e1cd11ee55e 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Librarian/books_bag.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Librarian/books_bag.yml @@ -23,3 +23,4 @@ - Book - Document - type: Dumpable + - type: MagnetPickup # Frontier diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 5c7deae079a..cf8849fd6bf 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -878,11 +878,8 @@ - IngotGold30 - IngotSilver30 - MaterialBananium10 - - type: MaterialStorageMagnetPickup + - type: MaterialStorageMagnetPickup # Frontier range: 0.30 - whitelist: - tags: - - Ore - type: entity parent: BaseLathe diff --git a/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml b/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml index 290d7b8479f..2f9309dd77e 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml @@ -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 diff --git a/Resources/Prototypes/_Nyano/Entities/Objects/Specific/Mail/tools.yml b/Resources/Prototypes/_Nyano/Entities/Objects/Specific/Mail/tools.yml index b7c071b9593..faff6c97105 100644 --- a/Resources/Prototypes/_Nyano/Entities/Objects/Specific/Mail/tools.yml +++ b/Resources/Prototypes/_Nyano/Entities/Objects/Specific/Mail/tools.yml @@ -17,3 +17,4 @@ whitelist: components: - Mail + - type: MagnetPickup # Frontier