diff --git a/Content.Shared/Storage/Components/MagnetPickupComponent.cs b/Content.Shared/Storage/Components/MagnetPickupComponent.cs index 3467439a6d..23b5a13ae2 100644 --- a/Content.Shared/Storage/Components/MagnetPickupComponent.cs +++ b/Content.Shared/Storage/Components/MagnetPickupComponent.cs @@ -1,11 +1,13 @@ using Content.Shared.Inventory; +using Robust.Shared.GameStates; namespace Content.Server.Storage.Components; /// /// Applies an ongoing pickup area around the attached entity. /// -[RegisterComponent, AutoGenerateComponentPause] +[NetworkedComponent] +[RegisterComponent, AutoGenerateComponentPause, AutoGenerateComponentState] public sealed partial class MagnetPickupComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField("nextScan")] @@ -13,10 +15,11 @@ public sealed partial class MagnetPickupComponent : Component public TimeSpan NextScan = TimeSpan.Zero; /// - /// What container slot the magnet needs to be in to work. + /// If true, ignores SlotFlags and can magnet pickup on hands/ground. /// - [ViewVariables(VVAccess.ReadWrite), DataField("slotFlags")] - public SlotFlags SlotFlags = SlotFlags.BELT; + [ViewVariables(VVAccess.ReadWrite), DataField] + [AutoNetworkedField] + public bool ForcePickup = true; [ViewVariables(VVAccess.ReadWrite), DataField("range")] public float Range = 1f; diff --git a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs index 21861f57da..8a7fdb57c8 100644 --- a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs @@ -1,5 +1,9 @@ using Content.Server.Storage.Components; +using Content.Shared.Examine; using Content.Shared.Inventory; +using Content.Shared.Item; +using Content.Shared.Item.ItemToggle; +using Content.Shared.Item.ItemToggle.Components; using Robust.Shared.Map; using Robust.Shared.Physics.Components; using Robust.Shared.Timing; @@ -16,6 +20,8 @@ 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!; // WD EDIT + [Dependency] private readonly SharedItemSystem _item = default!; // White Dream private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1); @@ -25,6 +31,8 @@ public override void Initialize() { base.Initialize(); _physicsQuery = GetEntityQuery(); + SubscribeLocalEvent(OnItemToggled); // White Dream + SubscribeLocalEvent(OnExamined); // WD EDIT SubscribeLocalEvent(OnMagnetMapInit); } @@ -33,6 +41,21 @@ private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, Map component.NextScan = _timing.CurTime; } + //WD EDIT start + private void OnExamined(Entity 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); + } + + private void OnItemToggled(Entity entity, ref ItemToggledEvent args) + { + _item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off"); + } + //WD EDIT end + public override void Update(float frameTime) { base.Update(frameTime); @@ -41,16 +64,23 @@ public override void Update(float frameTime) while (query.MoveNext(out var uid, out var comp, out var storage, out var xform, out var meta)) { - if (comp.NextScan > currentTime) + // WD EDIT START + if (!TryComp(uid, out var toggle)) continue; - comp.NextScan += ScanDelay; + if (!_itemToggle.IsActivated(uid, toggle)) + continue; + // WD EDIT END - if (!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef)) + if (comp.NextScan > currentTime) continue; - if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0) + comp.NextScan += ScanDelay; + + // WD EDIT START. Added ForcePickup. + if (!comp.ForcePickup && !_inventory.TryGetContainingSlot((uid, xform, meta), out _)) continue; + //WD EDIT END. // No space if (!_storage.HasSpace((uid, storage))) @@ -77,17 +107,14 @@ public override void Update(float frameTime) // the problem is that stack pickups delete the original entity, which is fine, but due to // game state handling we can't show a lerp animation for it. var nearXform = Transform(near); - var nearMap = nearXform.MapPosition; + var nearMap = _transform.GetMapCoordinates(near); var nearCoords = EntityCoordinates.FromMap(moverCoords.EntityId, nearMap, _transform, EntityManager); if (!_storage.Insert(uid, near, out var stacked, storageComp: storage, playSound: !playedSound)) continue; // Play pickup animation for either the stack entity or the original entity. - if (stacked != null) - _storage.PlayPickupAnimation(stacked.Value, nearCoords, finalCoords, nearXform.LocalRotation); - else - _storage.PlayPickupAnimation(near, nearCoords, finalCoords, nearXform.LocalRotation); + _storage.PlayPickupAnimation(stacked ?? near, nearCoords, finalCoords, nearXform.LocalRotation); playedSound = true; } diff --git a/Resources/Locale/en-US/storage/components/magnet-pickup-component.ftl b/Resources/Locale/en-US/storage/components/magnet-pickup-component.ftl new file mode 100644 index 0000000000..d56293dd5b --- /dev/null +++ b/Resources/Locale/en-US/storage/components/magnet-pickup-component.ftl @@ -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]. diff --git a/Resources/Locale/ru-RU/_white/storage/components/magnet-pickup-component.ftl b/Resources/Locale/ru-RU/_white/storage/components/magnet-pickup-component.ftl new file mode 100644 index 0000000000..9a58288220 --- /dev/null +++ b/Resources/Locale/ru-RU/_white/storage/components/magnet-pickup-component.ftl @@ -0,0 +1,4 @@ +## Выводится при осмотре предмета с MagnetPickupCompontent + +comp-magnet-pickup-examined-on = Магнит сейчас [color=darkgreen]включен[/color]. +comp-magnet-pickup-examined-off = Магнит сейчас [color=darkred]выключен[/color]. diff --git a/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag.yml b/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag.yml index a36bfaf676..469ba4c36f 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag.yml @@ -7,13 +7,16 @@ - type: MagnetPickup - type: Sprite sprite: Objects/Specific/Mining/ore_bag.rsi - state: icon + layers: + - state: orebag_off + map: [ "enum.ToggleVisuals.Layer" ] - type: Clothing sprite: Objects/Specific/Mining/ore_bag.rsi quickEquip: false slots: - belt - type: Item + heldPrefix: off size: Ginormous - type: Storage maxItemSize: Normal @@ -26,3 +29,21 @@ - ArtifactFragment - Ore - type: Dumpable + # WHITE EDIT START + - type: ItemToggle + soundActivate: + collection: sparks + params: + variation: 0.250 + soundDeactivate: + collection: sparks + params: + variation: 0.250 + - type: Appearance + - type: GenericVisualizer + visuals: + enum.ToggleVisuals.Toggled: + enum.ToggleVisuals.Layer: + True: { state: orebag_on } + False: { state: orebag_off } + # WHITE EDIT END diff --git a/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag_holding.yml b/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag_holding.yml index e8c7fa37dd..c0e21cb8a3 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag_holding.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Salvage/ore_bag_holding.yml @@ -8,7 +8,15 @@ range: 2 - type: Sprite sprite: Objects/Specific/Mining/ore_bag_holding.rsi - state: icon + layers: + - state: orebag_off + map: [ "enum.ToggleVisuals.Layer" ] + - type: GenericVisualizer + visuals: + enum.ToggleVisuals.Toggled: + enum.ToggleVisuals.Layer: + True: { state: orebag_on } + False: { state: orebag_off } - type: Clothing sprite: Objects/Specific/Mining/ore_bag_holding.rsi - type: Storage diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index de72dfcd5e..f1900a7153 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -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 # WHITE EDIT - type: entity parent: OreProcessor @@ -1412,4 +1413,4 @@ - type: MaterialStorage whitelist: tags: - - PrizeTicket \ No newline at end of file + - PrizeTicket diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json b/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json index 8d6202dde4..596d686f64 100644 --- a/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json +++ b/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json @@ -1,14 +1,14 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Homegrown by @ninruB#7795, inhand sprites by лазік#7305", + "copyright": "Homegrown by @ninruB#7795, inhand sprites by лазік#7305, ON state sprite by @kilath", "size": { "x": 32, "y": 32 }, "states": [ { - "name": "icon" + "name": "orebag_off" }, { "name": "equipped-BELT", @@ -21,6 +21,19 @@ { "name": "inhand-right", "directions": 4 + }, + { + "name": "orebag_on", + "delays": [ + [ + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1 + ] + ] } ] } diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/icon.png b/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/orebag_off.png similarity index 100% rename from Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/icon.png rename to Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/orebag_off.png diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/orebag_on.png b/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/orebag_on.png new file mode 100644 index 0000000000..b39ff0e6da Binary files /dev/null and b/Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/orebag_on.png differ diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/meta.json b/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/meta.json index 3b28912df0..8a3908f419 100644 --- a/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/meta.json +++ b/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/meta.json @@ -1,14 +1,14 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Taken from Paradise at https://github.com/ParadiseSS13/Paradise/blob/5ce5a66c814c4a60118d24885389357fd0240002/icons/obj/mining.dmi", + "copyright": "Taken from Paradise at https://github.com/ParadiseSS13/Paradise/blob/5ce5a66c814c4a60118d24885389357fd0240002/icons/obj/mining.dmi, ON state sprite by @kilath", "size": { "x": 32, "y": 32 }, "states": [ { - "name": "icon", + "name": "orebag_off", "delays": [ [ 0.1, @@ -19,6 +19,25 @@ ] ] }, + { + "name": "orebag_on", + "delays": [ + [ + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1 + ] + ] + }, { "name": "equipped-BELT", "directions": 4 diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/icon.png b/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/orebag_off.png similarity index 100% rename from Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/icon.png rename to Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/orebag_off.png diff --git a/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/orebag_on.png b/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/orebag_on.png new file mode 100644 index 0000000000..42382c71f4 Binary files /dev/null and b/Resources/Textures/Objects/Specific/Mining/ore_bag_holding.rsi/orebag_on.png differ