mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 02:50:53 +01:00
* I’M SCREAMING INTO THE VOID AND IT’S NOT LISTENING * review * explodes pancakes with mind * graaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * Meteors RAAAAAAAAAAH * I'm so tired of solutions * whhop * revert --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Fluids.Components;
|
|
using Content.Shared.Spillable;
|
|
using Content.Shared.Throwing;
|
|
|
|
namespace Content.Server.Fluids.EntitySystems;
|
|
|
|
public sealed partial class PuddleSystem
|
|
{
|
|
protected override void InitializeSpillable()
|
|
{
|
|
base.InitializeSpillable();
|
|
|
|
SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand);
|
|
// Openable handles the event if it's closed
|
|
SubscribeLocalEvent<SpillableComponent, SolutionContainerOverflowEvent>(OnOverflow);
|
|
SubscribeLocalEvent<SpillableComponent, SpillDoAfterEvent>(OnDoAfter);
|
|
}
|
|
|
|
private void OnOverflow(Entity<SpillableComponent> entity, ref SolutionContainerOverflowEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
TrySpillAt(Transform(entity).Coordinates, args.Overflow, out _);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void SpillOnLand(Entity<SpillableComponent> entity, ref LandEvent args)
|
|
{
|
|
if (!entity.Comp.SpillWhenThrown || Openable.IsClosed(entity.Owner))
|
|
return;
|
|
|
|
if (TrySplashSpillAt(entity.Owner, Transform(entity).Coordinates, out _, out var solution) && args.User != null)
|
|
{
|
|
AdminLogger.Add(LogType.Landed,
|
|
$"{ToPrettyString(entity.Owner):entity} spilled a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} on landing");
|
|
}
|
|
}
|
|
|
|
private void OnDoAfter(Entity<SpillableComponent> entity, ref SpillDoAfterEvent args)
|
|
{
|
|
if (args.Handled || args.Cancelled || args.Args.Target == null)
|
|
return;
|
|
|
|
//solution gone by other means before doafter completes
|
|
if (!_solutionContainerSystem.TryGetDrainableSolution(entity.Owner, out var soln, out var solution) || solution.Volume == 0)
|
|
return;
|
|
|
|
var puddleSolution = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume);
|
|
TrySpillAt(Transform(entity).Coordinates, puddleSolution, out _);
|
|
args.Handled = true;
|
|
}
|
|
}
|