Fix sinks and toilets not draining (#33691)

* Fix AutoDrain

Per the system comments, AutoDrain is designed to automatically move
puddles into the drain (like a floor drain). Drains without AutoDrain
are still supposed to gradually empty the buffer, but not remove puddles
(like sinks and toilets).

However, a logic error in the original implementation causes drains with
AutoDrain set to false to simply not work. Hence sinks never emptied.

* Update documentation
This commit is contained in:
Partmedia
2024-12-03 18:42:16 -08:00
committed by GitHub
parent 87182635b6
commit cf202e805d
2 changed files with 31 additions and 35 deletions

View File

@@ -134,13 +134,6 @@ public sealed class DrainSystem : SharedDrainSystem
}
drain.Accumulator -= drain.DrainFrequency;
// Disable ambient sound from emptying manually
if (!drain.AutoDrain)
{
_ambientSoundSystem.SetAmbience(uid, false);
continue;
}
if (!managerQuery.TryGetComponent(uid, out var manager))
continue;
@@ -160,6 +153,8 @@ public sealed class DrainSystem : SharedDrainSystem
// This will ensure that UnitsPerSecond is per second...
var amount = drain.UnitsPerSecond * drain.DrainFrequency;
if (drain.AutoDrain)
{
_puddles.Clear();
_lookup.GetEntitiesInRange(Transform(uid).Coordinates, drain.Range, _puddles);
@@ -197,6 +192,7 @@ public sealed class DrainSystem : SharedDrainSystem
QueueDel(puddle);
}
}
}
_solutionContainerSystem.UpdateChemicals(drain.Solution.Value);
}

View File

@@ -27,8 +27,8 @@ public sealed partial class DrainComponent : Component
public float Accumulator = 0f;
/// <summary>
/// Does this drain automatically absorb surrouding puddles? Or is it a drain designed to empty
/// solutions in it manually?
/// If true, automatically transfers solutions from nearby puddles and drains them. True for floor drains;
/// false for things like toilets and sinks.
/// </summary>
[DataField]
public bool AutoDrain = true;