From bf16698efad22f6bf2cfd7912f16b8920a1e5c1f Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 25 Aug 2023 20:40:42 +0200 Subject: [PATCH] Portable Generator Rework (#19302) --- Content.Client/DoAfter/DoAfterSystem.cs | 55 +++ .../Power/Generator/GeneratorWindow.xaml | 37 +- .../Power/Generator/GeneratorWindow.xaml.cs | 87 ++++- .../PortableGeneratorBoundUserInterface.cs | 62 ++++ .../SolidFuelGeneratorBoundUserInterface.cs | 42 --- Content.Client/Stylesheets/StyleNano.cs | 4 +- Content.Client/Stylesheets/StyleSpace.cs | 4 +- .../Materials/MaterialStorageSystem.cs | 62 +++- .../Components/BaseNetConnectorComponent.cs | 4 + .../Components/PowerSupplierComponent.cs | 6 +- .../EntitySystems/PowerNetConnectorSystem.cs | 2 +- .../Power/EntitySystems/PowerNetSystem.cs | 34 +- .../ChemicalFuelGeneratorAdapterComponent.cs | 34 +- .../Generator/GeneratorExhaustGasSystem.cs | 28 ++ .../Power/Generator/GeneratorSystem.cs | 278 +++++++++++---- .../Generator/PortableGeneratorSystem.cs | 190 ++++++++++ .../PowerSwitchableGeneratorSystem.cs | 111 ++++++ .../SolidFuelGeneratorAdapterComponent.cs | 25 +- Content.Server/Power/NodeGroups/ApcNet.cs | 24 +- .../Power/NodeGroups/BasePowerNet.cs | 51 +++ .../Power/NodeGroups/IBasePowerNet.cs | 4 + Content.Server/Power/NodeGroups/PowerNet.cs | 61 +--- Content.Server/Power/Nodes/CableDeviceNode.cs | 20 +- Content.Shared/FixedPoint/FixedPoint2.cs | 31 +- .../Materials/SharedMaterialStorageSystem.cs | 23 ++ .../Power/Generator/FuelGeneratorComponent.cs | 64 +--- .../Generator/GeneratorExhaustGasComponent.cs | 33 ++ .../PowerSwitchableGeneratorComponent.cs | 61 ++++ .../Power/Generator/SharedGeneratorSystem.cs | 1 + .../SharedPortableGeneratorComponent.cs | 143 ++++++++ .../SharedPortableGeneratorSystem.cs | 25 ++ .../SharedPowerSwitchableGeneratorSystem.cs | 23 ++ .../Shared/Chemistry/FixedPoint2_Tests.cs | 10 + Resources/Audio/Machines/attributions.yml | 5 + .../Audio/Machines/generator-tug-1-empty.ogg | Bin 0 -> 26330 bytes Resources/Audio/Machines/generator-tug-1.ogg | Bin 0 -> 26369 bytes .../Audio/Machines/generator-tug-2-empty.ogg | Bin 0 -> 26865 bytes Resources/Audio/Machines/generator-tug-2.ogg | Bin 0 -> 27407 bytes .../Audio/Machines/generator-tug-3-empty.ogg | Bin 0 -> 28833 bytes Resources/Audio/Machines/generator-tug-3.ogg | Bin 0 -> 28232 bytes Resources/Locale/en-US/guidebook/guides.ftl | 1 + .../node-container-component.ftl | 2 +- .../en-US/power/components/generator.ftl | 45 ++- .../Circuitboards/Machine/production.yml | 31 +- .../Entities/Structures/Machines/lathe.yml | 5 +- .../Power/Generation/generators.yml | 61 ---- .../Power/Generation/portable_generator.yml | 327 ++++++++++++++++++ .../Prototypes/Guidebook/engineering.yml | 6 + .../Prototypes/Recipes/Lathes/electronics.yml | 16 +- Resources/Prototypes/Research/industrial.yml | 7 +- .../Prototypes/SoundCollections/generator.yml | 15 + .../Engineering/PortableGenerator.xml | 42 +++ .../Guidebook/Engineering/Shuttlecraft.xml | 4 +- .../portable_generator.rsi/meta.json | 192 +++++----- .../portable_generator.rsi/portgen0.png | Bin 0 -> 766 bytes .../portable_generator.rsi/portgen0_0.png | Bin 522 -> 0 bytes .../portable_generator.rsi/portgen0_1.png | Bin 4960 -> 0 bytes .../portable_generator.rsi/portgen0on.png | Bin 0 -> 1143 bytes .../portable_generator.rsi/portgen1.png | Bin 0 -> 773 bytes .../portable_generator.rsi/portgen1_0.png | Bin 522 -> 0 bytes .../portable_generator.rsi/portgen1_1.png | Bin 5194 -> 0 bytes .../portable_generator.rsi/portgen1on.png | Bin 0 -> 1159 bytes .../portable_generator.rsi/portgen1rad.png | Bin 0 -> 1412 bytes .../portable_generator.rsi/portgen2.png | Bin 0 -> 760 bytes .../portable_generator.rsi/portgen2_0.png | Bin 515 -> 0 bytes .../portable_generator.rsi/portgen2_1.png | Bin 4690 -> 0 bytes .../portable_generator.rsi/portgen2on.png | Bin 0 -> 1147 bytes .../portable_generator.rsi/portgen3.png | Bin 0 -> 629 bytes .../portable_generator.rsi/portgen3on.png | Bin 0 -> 886 bytes .../portgen3on_unlit.png | Bin 0 -> 178 bytes .../portgen_on_unlit.png | Bin 0 -> 297 bytes Resources/migration.yml | 6 + SpaceStation14.sln.DotSettings | 2 + 73 files changed, 1933 insertions(+), 473 deletions(-) create mode 100644 Content.Client/Power/Generator/PortableGeneratorBoundUserInterface.cs delete mode 100644 Content.Client/Power/Generator/SolidFuelGeneratorBoundUserInterface.cs create mode 100644 Content.Server/Power/Generator/GeneratorExhaustGasSystem.cs create mode 100644 Content.Server/Power/Generator/PortableGeneratorSystem.cs create mode 100644 Content.Server/Power/Generator/PowerSwitchableGeneratorSystem.cs create mode 100644 Content.Server/Power/NodeGroups/BasePowerNet.cs create mode 100644 Content.Shared/Power/Generator/GeneratorExhaustGasComponent.cs create mode 100644 Content.Shared/Power/Generator/PowerSwitchableGeneratorComponent.cs create mode 100644 Content.Shared/Power/Generator/SharedPortableGeneratorComponent.cs create mode 100644 Content.Shared/Power/Generator/SharedPortableGeneratorSystem.cs create mode 100644 Content.Shared/Power/Generator/SharedPowerSwitchableGeneratorSystem.cs create mode 100644 Resources/Audio/Machines/generator-tug-1-empty.ogg create mode 100644 Resources/Audio/Machines/generator-tug-1.ogg create mode 100644 Resources/Audio/Machines/generator-tug-2-empty.ogg create mode 100644 Resources/Audio/Machines/generator-tug-2.ogg create mode 100644 Resources/Audio/Machines/generator-tug-3-empty.ogg create mode 100644 Resources/Audio/Machines/generator-tug-3.ogg create mode 100644 Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml create mode 100644 Resources/Prototypes/SoundCollections/generator.yml create mode 100644 Resources/ServerInfo/Guidebook/Engineering/PortableGenerator.xml create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen0.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen0_0.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen0_1.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen0on.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen1.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen1_0.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen1_1.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen1on.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen1rad.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen2.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen2_0.png delete mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen2_1.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen2on.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen3.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen3on.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen3on_unlit.png create mode 100644 Resources/Textures/Structures/Power/Generation/portable_generator.rsi/portgen_on_unlit.png diff --git a/Content.Client/DoAfter/DoAfterSystem.cs b/Content.Client/DoAfter/DoAfterSystem.cs index 761747b8e9..8c2d8344d3 100644 --- a/Content.Client/DoAfter/DoAfterSystem.cs +++ b/Content.Client/DoAfter/DoAfterSystem.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Content.Shared.DoAfter; using Content.Shared.Hands.Components; using Robust.Client.Graphics; @@ -51,4 +52,58 @@ public sealed class DoAfterSystem : SharedDoAfterSystem var handsQuery = GetEntityQuery(); Update(playerEntity.Value, active, comp, time, xformQuery, handsQuery); } + + /// + /// Try to find an active do-after being executed by the local player. + /// + /// The entity the do after must be targeting () + /// The found do-after. + /// The event to be raised on the found do-after when it completes. + /// The progress of the found do-after, from 0 to 1. + /// The type of event that must be raised by the found do-after. + /// True if a do-after was found. + public bool TryFindActiveDoAfter( + EntityUid entity, + [NotNullWhen(true)] out Shared.DoAfter.DoAfter? doAfter, + [NotNullWhen(true)] out T? @event, + out float progress) + where T : DoAfterEvent + { + var playerEntity = _player.LocalPlayer?.ControlledEntity; + + doAfter = null; + @event = null; + progress = default; + + if (!TryComp(playerEntity, out ActiveDoAfterComponent? active)) + return false; + + if (_metadata.EntityPaused(playerEntity.Value)) + return false; + + var comp = Comp(playerEntity.Value); + + var time = GameTiming.CurTime; + + foreach (var candidate in comp.DoAfters.Values) + { + if (candidate.Cancelled) + continue; + + if (candidate.Args.Target != entity) + continue; + + if (candidate.Args.Event is not T candidateEvent) + continue; + + @event = candidateEvent; + doAfter = candidate; + var elapsed = time - doAfter.StartTime; + progress = (float) Math.Min(1, elapsed.TotalSeconds / doAfter.Args.Delay.TotalSeconds); + + return true; + } + + return false; + } } diff --git a/Content.Client/Power/Generator/GeneratorWindow.xaml b/Content.Client/Power/Generator/GeneratorWindow.xaml index 86da3835e2..bae63a09ed 100644 --- a/Content.Client/Power/Generator/GeneratorWindow.xaml +++ b/Content.Client/Power/Generator/GeneratorWindow.xaml @@ -1,22 +1,39 @@  + MinSize="450 235" + SetSize="450 235" + Resizable="False" + Title="{Loc 'portable-generator-ui-title'}"> - + +