Files
tbd-station-14/Content.Server/GameObjects/Components/Items/FireExtinguisherComponent.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

52 lines
1.8 KiB
C#

using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
#nullable enable
namespace Content.Server.GameObjects.Components.Items
{
[RegisterComponent]
public class FireExtinguisherComponent : Component, IAfterInteract
{
public override string Name => "FireExtinguisher";
// Higher priority than sprays.
int IAfterInteract.Priority => 1;
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
{
if (eventArgs.Target == null || !eventArgs.CanReach)
{
return false;
}
if (eventArgs.Target.TryGetComponent(out ReagentTankComponent? tank)
&& eventArgs.Target.TryGetComponent(out ISolutionInteractionsComponent? targetSolution)
&& targetSolution.CanDrain
&& Owner.TryGetComponent(out SolutionContainerComponent? container))
{
var trans = ReagentUnit.Min(container.EmptyVolume, targetSolution.DrainAvailable);
if (trans > 0)
{
var drained = targetSolution.Drain(trans);
container.TryAddSolution(drained);
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/refill.ogg", Owner);
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("{0:TheName} is now refilled", Owner));
}
return true;
}
return false;
}
}
}