Files
tbd-station-14/Content.Server/Fluids/Components/SpillableComponent.cs
2021-11-02 12:03:23 +11:00

28 lines
943 B
C#

using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Interaction;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Fluids.Components
{
[RegisterComponent]
public class SpillableComponent : Component, IDropped
{
public override string Name => "Spillable";
[DataField("solution")]
public string SolutionName = "puddle";
void IDropped.Dropped(DroppedEventArgs eventArgs)
{
if (!eventArgs.Intentional
&& EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solutionComponent))
{
EntitySystem.Get<SolutionContainerSystem>()
.Drain(Owner.Uid, solutionComponent, solutionComponent.DrainAvailable)
.SpillAt(Owner.Transform.Coordinates, "PuddleSmear");
}
}
}
}