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

Fix air devices ignoring settings after power cycle #34887

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

VerinSenpai
Copy link

@VerinSenpai VerinSenpai commented Feb 5, 2025

About the PR

Fixes #34852

Why / Balance

Vents and scrubbers currently revert to their default settings when the power cycles. Alongside being annoying, this means they're no longer in sync with their connected air alarm. For example, if an alarm is set to fill, the vent should be enabled and the scrubber disabled. However after a power cycle, the scrubber will be back online, which at the very least gives the impression the alarm is no longer on fill.

Technical details

Reworks GasVentPumpSystem and GasVentScrubberSystem to use ApcPowerReceiverComponent to determine power state.

Media

I don't think this is needed? I can add a video if need be.

Requirements

Breaking changes

None

Changelog
🆑

  • fix: Air alarm devices now return to their previous settings after a power cycle.

also corrected onpowerchanged methods to update powered arg.
@github-actions github-actions bot added size/S Denotes a PR that changes 10-99 lines. S: Needs Review Status: Requires additional reviews before being fully accepted S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Feb 5, 2025
Comment on lines 13 to 16
{
[DataField]
public bool Powered { get; set; } = false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the power components please.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretend I'm stupid. don't suppose theres an example of this >.>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running myself ragged trying to find an existing powered component. The only thing I'm seeing that has a powered variable is ApcPowerReceiverComponent. Is that what you're referring to? I also noticed that the particle accelerator is enabling/disabling power in a similar manner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe for the most part you can do a trycomp to check power like so.

TryComp<ApcPowerReceiverComponent>(uid, out var power) && power.Powered

You can see an example in GasPressurePumpSystem, where we check if the device is not powered, if so we stop making sound and return early.

private void OnPumpUpdated(EntityUid uid, GasPressurePumpComponent pump, ref AtmosDeviceUpdateEvent args)
    {
        if (!pump.Enabled
            || (TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
            || !_nodeContainer.TryGetNodes(uid, pump.InletName, pump.OutletName, out PipeNode? inlet, out PipeNode? outlet))
        {
            _ambientSoundSystem.SetAmbience(uid, false);
            return;
        }

Here's an example for checking if a scrubber is powered:

            else if (!scrubber.Enabled || TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
            {
                _ambientSoundSystem.SetAmbience(uid, false);
                _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Off, appearance);
            }

That might work. Feel free to shoot me if it doesn't sloth (godo)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it may be something along those lines but thought that may be a bit bloated. I'll write it up and give it a shot. Thanks Roomba.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've got it right? Do I have to use an if statement for the trycomp in OnPowerChanged? That bugs me a tad.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore that last message, we're no longer setting anything but the visual state in OnPowerChange.

Comment on lines 11 to 14
{
[DataField]
public bool Enabled { get; set; } = false;
public bool Powered { get; set; } = false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

@metalgearsloth metalgearsloth added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted labels Feb 5, 2025
@ArtisticRoomba
Copy link
Contributor

crazy first PR verin

@ArtisticRoomba ArtisticRoomba added T: Bugfix Type: Bugs and/or bugfixes P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. D3: Low Difficulty: Some codebase knowledge required. S: Needs Review Status: Requires additional reviews before being fully accepted Changes: Atmospherics Code Changes: Might require knowledge of atmospherics code & calculations. A: Engineering Area: Engineering department, including Atmospherics. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Feb 5, 2025
@VerinSenpai
Copy link
Author

crazy first PR verin

Roomba!! please!! I'm gonna cry.... Metal wants me to use a powered component but I can't find one ;(

@github-actions github-actions bot removed the S: Awaiting Changes Status: Changes are required before another review can happen label Feb 5, 2025
@VerinSenpai
Copy link
Author

VerinSenpai commented Feb 5, 2025

Appears to function as desired. I did spot another issue though while writing this. If a powered air alarm is changed to a different setting while a vent/scrubber is not powered, the state of the vent/scrubber doesn't update. To be clear, it will power as desired, but it won't change from its previous setting to the new one.

@VerinSenpai
Copy link
Author

Gonna correct myself on that. Seems the setting changes, but the appearance doesn't.

@ArtisticRoomba
Copy link
Contributor

I think I have a reason as to why that's happening

Copy link
Contributor

@ArtisticRoomba ArtisticRoomba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works as intended.

@VerinSenpai
Copy link
Author

VerinSenpai commented Feb 6, 2025

drats, I've encountered another issue. The number of devices connected to an air alarm doesn't change when one device gets depowered.

@ArtisticRoomba
Copy link
Contributor

Have you pressed the Resync button and observed this behavior? The device list only updates very, very infrequently.

@VerinSenpai
Copy link
Author

I must be tripping. Hang tight, double checking now.

@VerinSenpai
Copy link
Author

ignore me, I'm just paranoid

@ArtisticRoomba
Copy link
Contributor

I get that you're been working on your frezon setups for the (just merged!) frezon buff, but man, don't get high on your own supply (godo).

@VerinSenpai
Copy link
Author

My first ever merge conflict on a project that isn't mine ;(

I'm weeping tears of joy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: Engineering Area: Engineering department, including Atmospherics. Changes: Atmospherics Code Changes: Might require knowledge of atmospherics code & calculations. D3: Low Difficulty: Some codebase knowledge required. P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. S: Needs Review Status: Requires additional reviews before being fully accepted size/S Denotes a PR that changes 10-99 lines. T: Bugfix Type: Bugs and/or bugfixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Air alarm settings cease to control connected devices after a power cycle.
4 participants