From 72b5ae94681e436c198ca894af8d489bd38e3083 Mon Sep 17 00:00:00 2001 From: py01 <60152240+collinlunn@users.noreply.github.com> Date: Sun, 24 Jan 2021 02:42:33 -0600 Subject: [PATCH] GasGeneratorComponent (#3029) * GasGeneratorComponent * gas generator sprite * component comment * replace the other typeof with nameof * Update Resources/Textures/Constructible/Atmos/gasgenerator.rsi/meta.json Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Resources/Prototypes/Entities/Constructible/Ground/gasgenerator.yml Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs Co-authored-by: Paul Ritter * Update Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs Co-authored-by: Paul Ritter * specifies physics component * comments Co-authored-by: py01 Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Paul Ritter --- Content.Client/IgnoredComponents.cs | 3 +- .../Atmos/Piping/GasCanisterPortComponent.cs | 4 +- .../Atmos/Piping/GasFilterComponent.cs | 2 +- .../Atmos/Piping/GasGeneratorComponent.cs | 105 ++++++++++++++++++ .../Atmos/Piping/Pumps/BasePumpComponent.cs | 4 +- .../Piping/Scrubbers/BaseSiphonComponent.cs | 4 +- .../Atmos/Piping/Vents/BaseVentComponent.cs | 4 +- .../Constructible/Ground/gasgenerator.yml | 45 ++++++++ .../Atmos/gasgenerator.rsi/gasGenerator.png | Bin 0 -> 1239 bytes .../Atmos/gasgenerator.rsi/meta.json | 14 +++ 10 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs create mode 100644 Resources/Prototypes/Entities/Constructible/Ground/gasgenerator.yml create mode 100644 Resources/Textures/Constructible/Atmos/gasgenerator.rsi/gasGenerator.png create mode 100644 Resources/Textures/Constructible/Atmos/gasgenerator.rsi/meta.json diff --git a/Content.Client/IgnoredComponents.cs b/Content.Client/IgnoredComponents.cs index 6823e56a43..101ce6c852 100644 --- a/Content.Client/IgnoredComponents.cs +++ b/Content.Client/IgnoredComponents.cs @@ -239,7 +239,8 @@ namespace Content.Client "Recyclable", "SecretStash", "Toilet", - "ClusterFlash" + "ClusterFlash", + "GasGenerator" }; } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs index cdc701d36d..a5fbc16b0c 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs @@ -83,13 +83,13 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping { if (!Owner.TryGetComponent(out var container)) { - Logger.Error($"{typeof(GasCanisterPortComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(GasCanisterPortComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); return; } _gasPort = container.Nodes.OfType().FirstOrDefault(); if (_gasPort == null) { - Logger.Error($"{typeof(GasCanisterPortComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(GasCanisterPortComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs index 8a6cd18f1d..461647fd43 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs @@ -171,7 +171,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters if (_inletPipe == null || _filterOutletPipe == null || _outletPipe == null) { - Logger.Error($"{typeof(GasFilterComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(GasFilterComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs new file mode 100644 index 0000000000..5a37d7a669 --- /dev/null +++ b/Content.Server/GameObjects/Components/Atmos/Piping/GasGeneratorComponent.cs @@ -0,0 +1,105 @@ +#nullable enable +using Content.Server.GameObjects.Components.NodeContainer; +using Content.Server.GameObjects.Components.NodeContainer.Nodes; +using Content.Shared.Atmos; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Log; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; +using System.Linq; + +namespace Content.Server.GameObjects.Components.Atmos.Piping +{ + /// + /// Generates gas in the attached pipe. + /// + [RegisterComponent] + public class GasGeneratorComponent : Component + { + public override string Name => "GasGenerator"; + + /// + /// If the generator is producing gas. + /// + [ViewVariables(VVAccess.ReadWrite)] + public bool GeneratorEnabled { get; set; } + + /// + /// What gas is being generated. + /// + [ViewVariables(VVAccess.ReadWrite)] + public Gas GeneratedGas { get; set; } + + /// + /// Molar rate of gas generation. + /// + [ViewVariables(VVAccess.ReadWrite)] + public float GasGenerationRate { get; set; } + + /// + /// The pipe pressure above which the generator stops producing gas. + /// + [ViewVariables(VVAccess.ReadWrite)] + public float GeneratorPressureCap { get; set; } + + /// + /// The pipe to which generated gas is added. + /// + [ViewVariables] + private PipeNode? Pipe { get; set; } + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + serializer.DataField(this, x => x.GeneratorEnabled, "generatorEnabled", true); + serializer.DataField(this, x => x.GeneratedGas, "generatedGas", Gas.Oxygen); + serializer.DataField(this, x => x.GasGenerationRate, "gasGenerationRate", 10); + serializer.DataField(this, x => x.GeneratorPressureCap, "generatorPressureCap", 10); + } + + public override void Initialize() + { + base.Initialize(); + Owner.EnsureComponentWarn(); + SetPipes(); + } + + public override void HandleMessage(ComponentMessage message, IComponent? component) + { + base.HandleMessage(message, component); + switch (message) + { + case PipeNetUpdateMessage: + Update(); + break; + } + } + + private void Update() + { + if (!GeneratorEnabled) + return; + + if (Pipe == null || Pipe.Air.Pressure > GeneratorPressureCap) + return; + + Pipe.Air.AdjustMoles(GeneratedGas, GasGenerationRate); + } + + private void SetPipes() + { + if (!Owner.TryGetComponent(out var container)) + { + Logger.Error($"{nameof(GasGeneratorComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); + return; + } + Pipe = container.Nodes.OfType().FirstOrDefault(); + if (Pipe == null) + { + Logger.Error($"{nameof(GasGeneratorComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + return; + } + } + } +} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs index a4c3d6a8e9..4b7eb31895 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs @@ -107,7 +107,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps if (!Owner.TryGetComponent(out var container)) { - Logger.Error($"{typeof(BasePumpComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BasePumpComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); return; } var pipeNodes = container.Nodes.OfType(); @@ -115,7 +115,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps _outletPipe = pipeNodes.Where(pipe => pipe.PipeDirection == _initialOutletDirection).FirstOrDefault(); if (_inletPipe == null || _outletPipe == null) { - Logger.Error($"{typeof(BasePumpComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BasePumpComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs index fe30881d58..a67e354a4d 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs @@ -80,13 +80,13 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers { if (!Owner.TryGetComponent(out var container)) { - Logger.Error($"{typeof(BaseSiphonComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BaseSiphonComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); return; } _scrubberOutlet = container.Nodes.OfType().FirstOrDefault(); if (_scrubberOutlet == null) { - Logger.Error($"{typeof(BaseSiphonComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BaseSiphonComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs index db4508959b..c9b9e48f86 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs @@ -80,13 +80,13 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents { if (!Owner.TryGetComponent(out var container)) { - Logger.Error($"{typeof(BaseVentComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BaseVentComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} did not have a {nameof(NodeContainerComponent)}."); return; } _ventInlet = container.Nodes.OfType().FirstOrDefault(); if (_ventInlet == null) { - Logger.Error($"{typeof(BaseVentComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); + Logger.Error($"{nameof(BaseVentComponent)} on {Owner?.Prototype?.ID}, Uid {Owner?.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } } diff --git a/Resources/Prototypes/Entities/Constructible/Ground/gasgenerator.yml b/Resources/Prototypes/Entities/Constructible/Ground/gasgenerator.yml new file mode 100644 index 0000000000..028b736c17 --- /dev/null +++ b/Resources/Prototypes/Entities/Constructible/Ground/gasgenerator.yml @@ -0,0 +1,45 @@ +- type: entity + abstract: true + id: GasGeneratorBase + placement: + mode: SnapgridCenter + components: + - type: Clickable + - type: InteractionOutline + - type: Physics + anchored: true + shapes: + - !type:PhysShapeAabb + bounds: "-0.5,-0.5,0.5,0.5" + layer: + - Impassable + - MobImpassable + - VaultImpassable + - Opaque + mask: + - Impassable + - MobImpassable + - VaultImpassable + - type: SnapGrid + offset: Center + - type: GasGenerator + +- type: entity + parent: GasGeneratorBase + id: GasGenerator + name: gas generator + description: Fabricates gas. + components: + - type: Sprite + netsync: false + sprite: Constructible/Atmos/gasgenerator.rsi + layers: + - sprite: Constructible/Atmos/pipe.rsi + state: pipeFourway + - state: gasGenerator + - type: NodeContainer + nodes: + - !type:PipeNode + nodeGroupID: Pipe + pipeDirection: Fourway + diff --git a/Resources/Textures/Constructible/Atmos/gasgenerator.rsi/gasGenerator.png b/Resources/Textures/Constructible/Atmos/gasgenerator.rsi/gasGenerator.png new file mode 100644 index 0000000000000000000000000000000000000000..038cde0c9ba42965e97848f54d6c7ac550be6718 GIT binary patch literal 1239 zcmV;|1StE7P)Am)6vcn@@iO*|v5{lq2rGO{BnsH9v@DB|)(VY<=#dc8($P@n&!M8DNe2~B!HN~d zW+|4WFkrjEK|pMc9M5>{nep2qcoYK}Phhv$Tg{ty=iD>*-Sh5+Z?syiChf&VX)i9y zTCFC(6-Q0uRIOIy0BdV&vR13f=H_O+-`w1!R;$UiwKe&*Z<0(&6MT7jnIH&QSXkiv z`SS!pz~je{`Sa;h0DifAnJZVWAcWw>ix+(O@BtwNjYflK&z>d5NZgzR?{qp`zkZz{ z22wIg5ZkuNX0vFTM!Vfc2od|t&CTIB4wXuUd_Iq17}V=^T-QZalj}Sc z0bSSWbUGA^Mb4f*%cV<~==b|H8Vx>v{K&Cm$N25mEjsNsZ{ED2*Xv;z2E*YnKBj|g zW)ZHetdP&=5kg>^CYelzLZN`~`%|ee6bk6N&hG9mzVDOCWaxIgJbLsf_W9aT%*?>V zOw&Y4iK?pX?(QPxp3H+FKnOt)1o*y><2dNLj^j9~a8q4G6H}DEACOWK1Oc#D@q@tt z&+`}#hbW3d6h$bCf~IMxs>;oqHxExB?M*hZ&!srA@p#Ph=g$vM0AP7}nS4GEz+f<# z+S7GC&O$buMNyQPgr;d&mPHgr+`fIAMx$|Hj00=nQ^CliM~`yi#0gy2Wi%S0>pDUR z!Z1YFbreNmJRTDS0jjEESr)pkv#_v0uh-+wojZv);mjg*9ET%Ej!-U_QB@To1m$uW z+qO{@h3)NaN~IDzJ3BazgYWx{$75c1WeN;2!gosEz6?SYEiG(d!kwW28T5oI!&nb@gRFah6hrfJ5+ zJ}=P8+V}l0uu>C%WEJesLN=SlFpL9LkYxW)6`VSCiosyO($W$;J3CXp|A`7L%c9@! zqiGsK2%60%uIo~-*MYs`C=?2Ko)^ypQcC9M=V!L#)V)B{G@>X1_Ud6j@T4D1RN{Fa zVHoZO_%{f+u1gd}XqrYgn+1sb{G?3-@t$Q_aY4?S2M*N@g%I?5z4-2*1enZ<6QvA? z!_=6m2(;U6T-S|tJs1p-Qj*W-V{AMFikG5uHySX#bS|S zu^9UZA?S9ybh}-`Fy!}7V_3dYfmSOKKUFXIX>}DKZY)bnOGqi{cDv+qISj)f3`5?% zd&fA6Sh;u+AaM>j6afI+w%Od+;IFMM1>om%=VbTQD*%dT&P=_xZJTDZnF=>Gfd}jB zaS&kYxwW;$)cf^y`NM?^sc=)NU~^+5Ezd)L^AD?#U