From 656ec38f99831487f0ccc4ccb627281842bed849 Mon Sep 17 00:00:00 2001 From: Veritius Date: Thu, 12 May 2022 23:12:35 +1000 Subject: [PATCH] Add power sinks (#8020) Co-authored-by: metalgearsloth --- Content.Client/Entry/IgnoredComponents.cs | 3 +- .../PowerSink/PowerSinkComponent.cs | 8 +++ Content.Server/PowerSink/PowerSinkSystem.cs | 56 ++++++++++++++++++ .../Locale/en-US/powersink/powersink.ftl | 1 + .../Prototypes/Catalog/uplink_catalog.yml | 6 ++ .../Entities/Objects/Power/powersink.yml | 46 ++++++++++++++ .../Objects/Power/powersink.rsi/meta.json | 14 +++++ .../Objects/Power/powersink.rsi/powersink.png | Bin 0 -> 7077 bytes 8 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 Content.Server/PowerSink/PowerSinkComponent.cs create mode 100644 Content.Server/PowerSink/PowerSinkSystem.cs create mode 100644 Resources/Locale/en-US/powersink/powersink.ftl create mode 100644 Resources/Prototypes/Entities/Objects/Power/powersink.yml create mode 100644 Resources/Textures/Objects/Power/powersink.rsi/meta.json create mode 100644 Resources/Textures/Objects/Power/powersink.rsi/powersink.png diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 48256031b0..c052a17946 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -348,7 +348,8 @@ namespace Content.Client.Entry "HealthAnalyzer", "Thirst", "CanEscapeInventory", - "Wires" + "PowerSink", + "Wires", }; } } diff --git a/Content.Server/PowerSink/PowerSinkComponent.cs b/Content.Server/PowerSink/PowerSinkComponent.cs new file mode 100644 index 0000000000..4654205a38 --- /dev/null +++ b/Content.Server/PowerSink/PowerSinkComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server.PowerSink +{ + /// + /// Absorbs power up to its capacity when anchored then explodes. + /// + [RegisterComponent] + public sealed class PowerSinkComponent : Component {} +} diff --git a/Content.Server/PowerSink/PowerSinkSystem.cs b/Content.Server/PowerSink/PowerSinkSystem.cs new file mode 100644 index 0000000000..f72713e52e --- /dev/null +++ b/Content.Server/PowerSink/PowerSinkSystem.cs @@ -0,0 +1,56 @@ +using Content.Server.Explosion.EntitySystems; +using Content.Server.Power.Components; +using Content.Shared.Body.Events; +using Content.Shared.Examine; +using Robust.Shared.Utility; + +namespace Content.Server.PowerSink +{ + public sealed class PowerSinkSystem : EntitySystem + { + [Dependency] private readonly ExplosionSystem _explosionSystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamine); + } + + private void OnExamine(EntityUid uid, PowerSinkComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange || !TryComp(uid, out var consumer)) + return; + + var drainAmount = (int) consumer.NetworkLoad.ReceivingPower / 1000; + args.PushMarkup( + Loc.GetString( + "powersink-examine-drain-amount", + ("amount", drainAmount), + ("markupDrainColor", "orange")) + ); + } + + public override void Update(float frameTime) + { + var toRemove = new RemQueue<(PowerSinkComponent Sink, BatteryComponent Battery)>(); + + // Realistically it's gonna be like <5 per station. + foreach (var (comp, networkLoad, battery, xform) in EntityManager.EntityQuery()) + { + if (!xform.Anchored) continue; + + battery.CurrentCharge += networkLoad.NetworkLoad.ReceivingPower / 1000; + if (battery.CurrentCharge < battery.MaxCharge) continue; + + toRemove.Add((comp, battery)); + } + + foreach (var (comp, battery) in toRemove) + { + _explosionSystem.QueueExplosion(comp.Owner, "Default", 5 * (battery.MaxCharge / 2500000), 0.5f, 10, canCreateVacuum: false); + EntityManager.RemoveComponent(comp.Owner, comp); + } + } + } +} diff --git a/Resources/Locale/en-US/powersink/powersink.ftl b/Resources/Locale/en-US/powersink/powersink.ftl new file mode 100644 index 0000000000..2d5b73be19 --- /dev/null +++ b/Resources/Locale/en-US/powersink/powersink.ftl @@ -0,0 +1 @@ +powersink-examine-drain-amount = The power sink is draining [color={$markupDrainColor}]{$amount} kW[/color]. diff --git a/Resources/Prototypes/Catalog/uplink_catalog.yml b/Resources/Prototypes/Catalog/uplink_catalog.yml index 71bac31e75..305c0ea1ec 100644 --- a/Resources/Prototypes/Catalog/uplink_catalog.yml +++ b/Resources/Prototypes/Catalog/uplink_catalog.yml @@ -255,6 +255,12 @@ itemId: ClothingBackpackDuffelSyndicateFilledMedical price: 5 +- type : uplinkListing + id: UplinkPowerSink + category: Tools + itemId: PowerSink + price: 5 + - type: uplinkListing id: UplinkCarpDehydrated category: Tools diff --git a/Resources/Prototypes/Entities/Objects/Power/powersink.yml b/Resources/Prototypes/Entities/Objects/Power/powersink.yml new file mode 100644 index 0000000000..a2db90d32a --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Power/powersink.yml @@ -0,0 +1,46 @@ +- type: entity + id: PowerSink + parent: BaseMachine + name: power sink + description: Drains immense amounts of electricity from the grid. + components: + - type: Item + size: 150 + - type: NodeContainer + examinable: true + nodes: + input: + !type:CableDeviceNode + nodeGroupID: HVPower + - type: Transform + anchored: true + - type: Physics + - type: Fixtures + fixtures: + - shape: + !type:PhysShapeAabb + bounds: "-0.40,-0.40,0.40,0.40" + mass: 15 + mask: + - MachineMask + layer: + - MachineLayer + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 25 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - type: PowerSink + - type: Battery + maxCharge: 7500000 + - type: ExaminableBattery + - type: PowerConsumer + voltage: High + drawRate: 1000000 + - type: Sprite + netsync: false + sprite: Objects/Power/powersink.rsi + state: powersink diff --git a/Resources/Textures/Objects/Power/powersink.rsi/meta.json b/Resources/Textures/Objects/Power/powersink.rsi/meta.json new file mode 100644 index 0000000000..d85868d1db --- /dev/null +++ b/Resources/Textures/Objects/Power/powersink.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "license": "CC-BY-NC-SA-3.0", + "copyright": "Taken from goonstation at commit https://github.com/goonstation/goonstation/commit/17c4392b75abd87a0f740e116c44dd4c7dfff6f7", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "powersink" + } + ] +} diff --git a/Resources/Textures/Objects/Power/powersink.rsi/powersink.png b/Resources/Textures/Objects/Power/powersink.rsi/powersink.png new file mode 100644 index 0000000000000000000000000000000000000000..9a8db0358adcfe7f42af7566137659f9a5afe515 GIT binary patch literal 7077 zcmeHKc{r5o`yVM}r|e>yWXTz3#tdUJA^S4OPK(BvVK6hA8QUnrgoq@Ckfnnnku55F zl&I{Ltp(Xak|f3VrOr8>>-YWVT-WdW-6}TP=4&?5~5l3Vy+&)ghcj}Z?D2qR)pkf44A%c z!rsA*&`gJ|L-U|fR_@1h?^lBt zrHfzR+Pl`$wop@_spWV~?u)1V@`;JWk_)Rk^Fv)$@yG6$g!#nZuX^Hq$lyWW0%BT| zc-}cWG5fG*r1yg9x9yPbHSszr`@n2i!qbHK6Soumpfc}E`_%R?*A6DcHsVG_IVbKe zh9FkQVrPzxN__H3v8el^FPk~P|9#^<6N!6wpe9-&cRHRnm-V`^U0PbK>)#cq-^{yl zeD;F8TTTjN+PAm!(bOfP;e%W4H_CRM40F?!cCy}TRC`m!*3Wmp5%P9@YQwxPON*33sM){sjhMI_DBebuDBMfI zoUoL6w_5|U`#_Rs8jnMSSj6e9oe0Uow|iqulNDTIdnXAoq6EuBX15iyBFvK9%~cAL zygzGuw80B97;Tl+Z+GKVZvUQSp;B4qX+$5NeH`JM?o)S0F~8-qD>biA@FZ)pn_!Jy z?w;{$7WzVXaKTuP*h^Njxq^RuPUDGA`%S*U3kS)aJem z_??Mo<+l2o-{C1@LZmgeyt6Dd)FJbLDtc0Py^MN|q)V4yLzf+tHIHreb&i)5;qSq? zd``$b;c1AXukWKOp0Pf`2$Rvima~c&E3;1=zP+R_}V) zR2gG46RXnbOK<$6ZM@4zm8H6pns}_hD+dniymIb+?qxpJ?wPGnAh>e*eaK*b$D^;J zB`y=I1PlefaT98=H*+OaK|OS|1eM!F3{&eBGRTWl00cd>0v5tpx=doP zLOnSG3ZG{`kR41M%uWoUs9YDxzia!E_#E%>ZCrA@n7+Tg?$B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