diff --git a/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs b/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs index 8f407650eac..e5096d00a26 100644 --- a/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs +++ b/Content.Shared/Storage/Components/MaterialReclaimerMagnetPickupComponent.cs @@ -11,4 +11,10 @@ public sealed partial class MaterialReclaimerMagnetPickupComponent : Component [ViewVariables(VVAccess.ReadWrite), DataField("range")] public float Range = 1f; + + /// + /// Frontier - Is the magnet currently enabled? + /// + [ViewVariables(VVAccess.ReadWrite), DataField("magnetEnabled")] + public bool MagnetEnabled = false; } diff --git a/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs b/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs index bf49a942134..999c96c1945 100644 --- a/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs +++ b/Content.Shared/Storage/Components/MaterialStorageMagnetPickupComponent.cs @@ -11,4 +11,10 @@ public sealed partial class MaterialStorageMagnetPickupComponent : Component [ViewVariables(VVAccess.ReadWrite), DataField("range")] public float Range = 1f; + + /// + /// Frontier - Is the magnet currently enabled? + /// + [ViewVariables(VVAccess.ReadWrite), DataField("magnetEnabled")] + public bool MagnetEnabled = false; } diff --git a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs index bda4453b1d4..f1db50f29ba 100644 --- a/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs @@ -88,7 +88,6 @@ public bool ToggleMagnet(EntityUid uid, MagnetPickupComponent comp) return comp.MagnetEnabled; } - public override void Update(float frameTime) { base.Update(frameTime); diff --git a/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs index eb4f55127e5..e7221f72347 100644 --- a/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MaterialReclaimerMagnetPickupSystem.cs @@ -2,6 +2,10 @@ using Content.Shared.Materials; using Robust.Shared.Physics.Components; using Robust.Shared.Timing; +using Content.Shared.Examine; // Frontier +using Content.Shared.Hands.Components; // Frontier +using Content.Shared.Verbs; // Frontier +using Robust.Shared.Utility; // Frontier namespace Content.Shared.Storage.EntitySystems; @@ -24,6 +28,8 @@ public override void Initialize() _physicsQuery = GetEntityQuery(); SubscribeLocalEvent(OnMagnetMapInit); SubscribeLocalEvent(OnMagnetUnpaused); + SubscribeLocalEvent(OnExamined); // Frontier + SubscribeLocalEvent>(AddToggleMagnetVerb); // Frontier } private void OnMagnetUnpaused(EntityUid uid, MaterialReclaimerMagnetPickupComponent component, ref EntityUnpausedEvent args) @@ -33,7 +39,48 @@ private void OnMagnetUnpaused(EntityUid uid, MaterialReclaimerMagnetPickupCompon private void OnMagnetMapInit(EntityUid uid, MaterialReclaimerMagnetPickupComponent component, MapInitEvent args) { - component.NextScan = _timing.CurTime + TimeSpan.FromSeconds(1f); + component.NextScan = _timing.CurTime + TimeSpan.FromSeconds(1); // Need to add 1 sec to fix a weird time bug with it that make it never start the magnet + } + + // Frontier, used to add the magnet toggle to the context menu + private void AddToggleMagnetVerb(EntityUid uid, MaterialReclaimerMagnetPickupComponent component, GetVerbsEvent args) + { + if (!args.CanAccess || !args.CanInteract) + return; + + if (!HasComp(args.User)) + return; + + AlternativeVerb verb = new() + { + Act = () => + { + ToggleMagnet(uid, component); + }, + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/Spare/poweronoff.svg.192dpi.png")), + Text = Loc.GetString("magnet-pickup-component-toggle-verb"), + Priority = 3 + }; + + args.Verbs.Add(verb); + } + + // Frontier, used to show the magnet state on examination + private void OnExamined(EntityUid uid, MaterialReclaimerMagnetPickupComponent component, ExaminedEvent args) + { + args.PushMarkup(Loc.GetString("magnet-pickup-component-on-examine-main", + ("stateText", Loc.GetString(component.MagnetEnabled + ? "magnet-pickup-component-magnet-on" + : "magnet-pickup-component-magnet-off")))); + } + + // Frontier, used to toggle the magnet on the ore bag/box + public bool ToggleMagnet(EntityUid uid, MaterialReclaimerMagnetPickupComponent comp) + { + var query = EntityQueryEnumerator(); + comp.MagnetEnabled = !comp.MagnetEnabled; + + return comp.MagnetEnabled; } public override void Update(float frameTime) @@ -49,6 +96,10 @@ public override void Update(float frameTime) comp.NextScan += ScanDelay; + // Frontier - magnet disabled + if (!comp.MagnetEnabled) + continue; + var parentUid = xform.ParentUid; foreach (var near in _lookup.GetEntitiesInRange(uid, comp.Range, LookupFlags.Dynamic | LookupFlags.Sundries)) diff --git a/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs b/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs index d487985d875..9978d4a1a75 100644 --- a/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs +++ b/Content.Shared/Storage/EntitySystems/MaterialStorageMagnetPickupSystem.cs @@ -2,6 +2,10 @@ using Content.Shared.Materials; using Robust.Shared.Physics.Components; using Robust.Shared.Timing; +using Content.Shared.Examine; // Frontier +using Content.Shared.Hands.Components; // Frontier +using Content.Shared.Verbs; // Frontier +using Robust.Shared.Utility; // Frontier namespace Content.Shared.Storage.EntitySystems; @@ -24,6 +28,8 @@ public override void Initialize() _physicsQuery = GetEntityQuery(); SubscribeLocalEvent(OnMagnetMapInit); SubscribeLocalEvent(OnMagnetUnpaused); + SubscribeLocalEvent(OnExamined); // Frontier + SubscribeLocalEvent>(AddToggleMagnetVerb); // Frontier } private void OnMagnetUnpaused(EntityUid uid, MaterialStorageMagnetPickupComponent component, ref EntityUnpausedEvent args) @@ -33,7 +39,48 @@ private void OnMagnetUnpaused(EntityUid uid, MaterialStorageMagnetPickupComponen private void OnMagnetMapInit(EntityUid uid, MaterialStorageMagnetPickupComponent component, MapInitEvent args) { - component.NextScan = _timing.CurTime + TimeSpan.FromSeconds(1f); + component.NextScan = _timing.CurTime + TimeSpan.FromSeconds(1); // Need to add 1 sec to fix a weird time bug with it that make it never start the magnet + } + + // Frontier, used to add the magnet toggle to the context menu + private void AddToggleMagnetVerb(EntityUid uid, MaterialStorageMagnetPickupComponent component, GetVerbsEvent args) + { + if (!args.CanAccess || !args.CanInteract) + return; + + if (!HasComp(args.User)) + return; + + AlternativeVerb verb = new() + { + Act = () => + { + ToggleMagnet(uid, component); + }, + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/Spare/poweronoff.svg.192dpi.png")), + Text = Loc.GetString("magnet-pickup-component-toggle-verb"), + Priority = 3 + }; + + args.Verbs.Add(verb); + } + + // Frontier, used to show the magnet state on examination + private void OnExamined(EntityUid uid, MaterialStorageMagnetPickupComponent component, ExaminedEvent args) + { + args.PushMarkup(Loc.GetString("magnet-pickup-component-on-examine-main", + ("stateText", Loc.GetString(component.MagnetEnabled + ? "magnet-pickup-component-magnet-on" + : "magnet-pickup-component-magnet-off")))); + } + + // Frontier, used to toggle the magnet on the ore bag/box + public bool ToggleMagnet(EntityUid uid, MaterialStorageMagnetPickupComponent comp) + { + var query = EntityQueryEnumerator(); + comp.MagnetEnabled = !comp.MagnetEnabled; + + return comp.MagnetEnabled; } public override void Update(float frameTime) @@ -49,6 +96,10 @@ public override void Update(float frameTime) comp.NextScan += ScanDelay; + // Frontier - magnet disabled + if (!comp.MagnetEnabled) + continue; + var parentUid = xform.ParentUid; foreach (var near in _lookup.GetEntitiesInRange(uid, comp.Range, LookupFlags.Dynamic | LookupFlags.Sundries)) diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index bf0c3ac85ff..f7fde74674e 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -49,6 +49,8 @@ price: 800 - type: ResearchClient - type: TechnologyDatabase + - type: MaterialStorageMagnetPickup # Frontier + range: 0.30 - type: entity id: Autolathe @@ -880,8 +882,6 @@ - IngotGold30 - IngotSilver30 - MaterialBananium10 - - type: MaterialStorageMagnetPickup # Frontier - range: 0.30 - 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 3e5a6930957..7925599add9 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/material_reclaimer.yml @@ -104,3 +104,4 @@ powerLoad: 500 # Allows us to not use the 1000 baseline - type: MaterialReclaimerMagnetPickup # Frontier range: 0.30 + magnetEnabled: true \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml index fcc4a717b8c..8b0f1f319f3 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml @@ -170,6 +170,8 @@ gasType: CarbonDioxide # 0.5 moles of gas for every sheet of plasma. moleRatio: 0.5 + - type: MaterialStorageMagnetPickup # Frontier + range: 0.30 - type: entity name: S.U.P.E.R.P.A.C.M.A.N.-type portable generator @@ -219,6 +221,8 @@ - type: UpgradePowerSupplier powerSupplyMultiplier: 1.25 scaling: Exponential + - type: MaterialStorageMagnetPickup # Frontier + range: 0.30 - type: entity name: J.R.P.A.C.M.A.N.-type portable generator