* feat: predict evaporation * refactor: move puddle update logic to shared * refactor: move more puddle stuff to Shared Still can't do stuff that creates puddles :( * refactor: move puddle transfers to shared * fix: various style fixes + switch to predicted variants * style: make some puddle stuff private instead of protected * refactor: move solution dumping to its own system * docs: clarify Drainable/Dumpable/Refillable docs Also whacks unneeded VVAccess's. * fix: audit usages of drainable+refillable I'm leaving spear and arrow for now... but I don't love it. * Added an item query I guess * Review changes * You can pour out waterguns * Review changes * oops --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
65 lines
2.3 KiB
C#
65 lines
2.3 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 (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution))
|
|
return;
|
|
|
|
if (Openable.IsClosed(entity.Owner))
|
|
return;
|
|
|
|
if (!entity.Comp.SpillWhenThrown)
|
|
return;
|
|
|
|
if (args.User != null)
|
|
{
|
|
AdminLogger.Add(LogType.Landed,
|
|
$"{ToPrettyString(entity.Owner):entity} spilled a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} on landing");
|
|
}
|
|
|
|
var drainedSolution = _solutionContainerSystem.Drain(entity.Owner, soln.Value, solution.Volume);
|
|
TrySplashSpillAt(entity.Owner, Transform(entity).Coordinates, drainedSolution, out _);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|