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
31 changes: 31 additions & 0 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using Content.Server.Storage.Components;
using Content.Shared.Examine;
using Content.Shared.Hands.EntitySystems;
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;
Expand All @@ -16,6 +21,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!;
HellCatten marked this conversation as resolved.
Show resolved Hide resolved

private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);

Expand All @@ -25,6 +32,8 @@ public override void Initialize()
{
base.Initialize();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<MagnetPickupComponent, ItemToggledEvent>(ToggleDone);
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
SubscribeLocalEvent<MagnetPickupComponent, ExaminedEvent>(onExamined); // WD EDIT
SubscribeLocalEvent<MagnetPickupComponent, MapInitEvent>(OnMagnetMapInit);
}

Expand All @@ -33,6 +42,20 @@ private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, Map
component.NextScan = _timing.CurTime;
}

//WD EDIT
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);
}

private void ToggleDone(Entity<MagnetPickupComponent> entity, ref ItemToggledEvent args)
{
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off");
}

HellCatten marked this conversation as resolved.
Show resolved Hide resolved
public override void Update(float frameTime)
{
base.Update(frameTime);
Expand All @@ -41,6 +64,14 @@ public override void Update(float frameTime)

while (query.MoveNext(out var uid, out var comp, out var storage, out var xform, out var meta))
{
// WD EDIT START
if (!TryComp<ItemToggleComponent>(uid, out var toggle))
continue;

if (!_itemToggle.IsActivated(uid, toggle))
continue;
// WD EDIT END

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,4 @@
## Выводится при осмотре предмета с 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 @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 # WHITE EDIT

- type: entity
parent: OreProcessor
Expand Down Expand Up @@ -1412,4 +1413,4 @@
- type: MaterialStorage
whitelist:
tags:
- PrizeTicket
- PrizeTicket
17 changes: 15 additions & 2 deletions Resources/Textures/Objects/Specific/Mining/ore_bag.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
]
]
}
]
}
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,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,
Expand All @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading