Skip to content

Commit

Permalink
port ore bag magnet toggle from white dream (#2467)
Browse files Browse the repository at this point in the history
* add on textures for ore bags

* add code for toggling magnet and working in-hand

* update ore bag yml

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
  • Loading branch information
deltanedas authored Dec 18, 2024
1 parent 8ac8da7 commit dce230f
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Shared.DeltaV.Item.ItemToggle.Systems;
using Robust.Shared.GameStates;

namespace Content.Shared.DeltaV.Item.ItemToggle.Components;

/// <summary>
/// Adds examine text when the item is on or off.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(ItemToggleExamineSystem))]
public sealed partial class ItemToggleExamineComponent : Component
{
[DataField(required: true)]
public LocId On;

[DataField(required: true)]
public LocId Off;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.DeltaV.Item.ItemToggle.Components;
using Content.Shared.Examine;
using Content.Shared.Item.ItemToggle;

namespace Content.Shared.DeltaV.Item.ItemToggle.Systems;

public sealed class ItemToggleExamineSystem : EntitySystem
{
[Dependency] private readonly ItemToggleSystem _toggle = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ItemToggleExamineComponent, ExaminedEvent>(OnExamined);
}

private void OnExamined(Entity<ItemToggleExamineComponent> ent, ref ExaminedEvent args)
{
var msg = _toggle.IsActivated(ent.Owner) ? ent.Comp.On : ent.Comp.Off;
args.PushMarkup(Loc.GetString(msg));
}
}
15 changes: 12 additions & 3 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Storage.Components;
using Content.Shared.Inventory;
using Content.Shared.Item.ItemToggle; // DeltaV
using Content.Shared.Whitelist;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
Expand All @@ -15,6 +16,7 @@ public sealed class MagnetPickupSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly ItemToggleSystem _toggle = default!; // DeltaV
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
Expand Down Expand Up @@ -49,11 +51,18 @@ public override void Update(float frameTime)

comp.NextScan += ScanDelay;

if (!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef))
// Begin DeltaV Addition: Make ore bags use ItemToggle
if (!_toggle.IsActivated(uid))
continue;
// End DeltaV Addition

if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
continue;
// Begin DeltaV Removals: Allow ore bags to work inhand
//if (!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef))
// continue;

//if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
// continue;
// End DeltaV Removals

// No space
if (!_storage.HasSpace((uid, storage)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
- type: MagnetPickup
- type: Sprite
sprite: Objects/Specific/Mining/ore_bag.rsi
state: icon
#state: icon # DeltaV: use a layer instead
layers: # DeltaV
- state: icon
map: [ "enum.ToggleVisuals.Layer" ]
- type: Clothing
sprite: Objects/Specific/Mining/ore_bag.rsi
quickEquip: false
Expand All @@ -26,6 +29,24 @@
- ArtifactFragment
- Ore
- type: Dumpable
# Begin DeltaV Additions: toggle magnet from White Dream
- type: ItemToggle
soundActivate: &soundActivate
collection: sparks
params:
variation: 0.25
soundDeactivate: *soundActivate
- type: ItemToggleExamine
on: magnet-pickup-component-magnet-on
off: magnet-pickup-component-magnet-off
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ToggleVisuals.Toggled:
enum.ToggleVisuals.Layer:
True: { state: icon_on }
False: { state: icon }
# End DeltaV Additions
- type: ReverseEngineering # DeltaV
difficulty: 2
recipes:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Homegrown by @ninruB#7795, inhand sprites by lzk228(discord 455630609641897984)",
"copyright": "Homegrown by @ninruB#7795, inhand sprites by lzk228(discord 455630609641897984) | icon_on state by @kilath",
"size": {
"x": 32,
"y": 32
Expand All @@ -21,6 +21,19 @@
{
"name": "inhand-right",
"directions": 4
},
{
"name": "icon_on",
"delays": [
[
0.1,
0.1,
0.1,
0.1,
0.1,
0.1
]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"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 | icon_on state by PuroSlavKing (Github)",
"size": {
"x": 32,
"y": 32
Expand Down Expand Up @@ -106,6 +106,25 @@
0.1
]
]
},
{
"name": "icon_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
]
]
}
]
}

0 comments on commit dce230f

Please sign in to comment.